# alexyach1973/capstone architecture

> Architecture diagram of the GitHub repository alexyach1973/capstone, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alexyach1973/capstone
- Repository: https://github.com/alexyach1973/capstone

## Overview

##### Project Type and Purpose
- This is an Android mobile application designed for both human and zombie survivors. Its purpose is to help users identify and record danger points (like radiation, chemical hazards, etc.), display the hazards through a web view, store and manage the hazard “database” via a Content Provider, and offer real-time observation using location services and a Bound Service.
- The README highlights three main modules – DANGER, DATABASE, and OBSERVE – each corresponding to distinct activities and functionalities.

##### Analyzing the File Structure and Architectural Clues
- The file tree shows a typical Android project structure with:
- Gradle build files (build.gradle, settings.gradle, gradle-wrapper files) indicating standard build configuration.
- Multiple activity classes: MainActivity, as well as separate activities for Danger, Database, Position, and Observe.
- Classes supporting the database functionality, including DBContract, DataBaseHelper, DataBase, DangerProvider for a Content Provider, and classes catering to location and broadcast mechanisms (CurrentLocation, BroadcastReceiver registration pattern hinted in the README and files like PositionBindService and PositionRequestHandler).
- Tests (unit tests and Espresso tests) indicate the project’s robustness and testing strategy.

A. Main UI Components (Activities):
- MainActivity: Represents the app’s starting point with navigation options.
- Danger Activity: Displays hazard details using a WebView that links to external Wikipedia pages.
- Database Activity: Shows the list of hazard points stored in the SQLite database, and includes controls like “REFRESH”, “ADD”, and “DELETE ALL.”
- Activity: Supports creation or updating of a database entry by capturing the current position (latitude and longitude) along with the danger details.
- Observe Activity: Displays the list of danger points along with calculated distances to the current location. Also linked to maps for detailed views.

B. Data Management:
- Content Provider (DangerProvider): Interfaces with the underlying SQLite database. Also include:
- DBContract: Defines the database schema.
- DataBaseHelper: Manages the creation and version management of the SQLite database.
- DataBase class for direct database interactions if applicable.

C. Location and Service Layer:
- Broadcast Receiver: Dynamically registered (using ACTION_POSITION_RECEIVER) to determine the current location via LocationManager.
- Bound Service: Represented by PositionBindService and PositionRequestHandler. This service is responsible for managing the distance calculations to recorded danger points in real-time for the Observe activity.
- CurrentLocation and Position classes: These handle acquisition and representation of location data.

D. External Dependencies and Resources:
- Mention the integration with external resources (Wikipedia links) in the DANGER module.
- Google Maps integration is invoked both in Position and Observe activities.
- Utilize external libraries and frameworks typical to Android development (depicted as “Android SDK Components” such as Activities, Services, Content Providers).

- That the BroadcastReceiver is dynamically registered (important for understanding how the location is updated) and how it feeds data to activities.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Main UI Layer"
        MA["MainActivity"]:::ui
        DA["DangerActivity"]:::ui
        DLayout["DangerLayout"]:::ui
        DBA["DatabaseActivity"]:::ui
        DBLayout["DatabaseLayout"]:::ui
        PA["PositionActivity"]:::ui
        PALayout["PositionLayout"]:::ui
        OA["ObserveActivity"]:::ui
        OALayout["ObserveLayout"]:::ui
    end

    subgraph "Data Management Layer"
        DP["DangerProvider"]:::data
        DC["DBContract"]:::data
        DHelper["DataBaseHelper"]:::data
        DBase["DataBase"]:::data
    end

    subgraph "Service & Location Layer"
        PBS["PositionBindService"]:::service
        PRH["PositionRequestHandler"]:::service
        CL["CurrentLocation"]:::service
        BR["BroadcastReceiver"]:::service
    end

    subgraph "External Integrations"
        GM["GoogleMaps"]:::external
        WP["Wikipedia"]:::external
    end

    subgraph "Testing"
        ET["EspressoTest"]:::test
    end

    %% UI Navigation
    MA -->|"navigatesTo"| DA
    MA -->|"navigatesTo"| DBA
    MA -->|"navigatesTo"| PA
    MA -->|"navigatesTo"| OA

    %% UI Internal Layouts
    DA -->|"layout"| DLayout
    DBA -->|"layout"| DBLayout
    PA -->|"layout"| PALayout
    OA -->|"layout"| OALayout

    %% Data Management Flow
    DBA -->|"CRUD"| DP
    DP --> DC
    DP --> DHelper
    DP --> DBase

    %% External Integrations
    DA -->|"webview"| WP
    PA -->|"mapAction"| GM

    %% Service & Location Interactions
    OA -->|"distanceCalc"| PBS
    PBS -->|"handles"| PRH
    BR --> CL
    CL --> PBS

    %% Testing Relation
    DBA -->|"testedBy"| ET

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef data fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef service fill:#A9DFBF,stroke:#1E8449,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef test fill:#D2B4DE,stroke:#5B2C6F,stroke-width:2px;

click MA "https://github.com/alexyach1973/capstone/blob/master/app/src/main/java/org/coursera/sustainableapps/caostoneproject/MainActivity.java"
click DA "https://github.com/alexyach1973/capstone/blob/master/app/src/main/java/org/coursera/sustainableapps/caostoneproject/Danger.java"
click DLayout "https://github.com/alexyach1973/capstone/blob/master/app/src/main/res/layout/activity_danger.xml"
click DBA "https://github.com/alexyach1973/capstone/blob/master/app/src/main/res/layout/activity_data_base.xml"
click ET "https://github.com/alexyach1973/capstone/blob/master/app/src/androidTest/java/org/coursera/sustainableapps/caostoneproject/EspressoDataBaseActivityTest.java"
click PA "https://github.com/alexyach1973/capstone/blob/master/app/src/main/java/org/coursera/sustainableapps/caostoneproject/Position.java"
click PALayout "https://github.com/alexyach1973/capstone/blob/master/app/src/main/res/layout/activity_position.xml"
click OA "https://github.com/alexyach1973/capstone/blob/master/app/src/main/java/org/coursera/sustainableapps/caostoneproject/Observe.java"
click OALayout "https://github.com/alexyach1973/capstone/blob/master/app/src/main/res/layout/activity_observe.xml"
click DP "https://github.com/alexyach1973/capstone/blob/master/app/src/main/java/org/coursera/sustainableapps/caostoneproject/DangerProvider.java"
click DC "https://github.com/alexyach1973/capstone/blob/master/app/src/main/java/org/coursera/sustainableapps/caostoneproject/DBContract.java"
click DHelper "https://github.com/alexyach1973/capstone/blob/master/app/src/main/java/org/coursera/sustainableapps/caostoneproject/DataBaseHelper.java"
click DBase "https://github.com/alexyach1973/capstone/blob/master/app/src/main/java/org/coursera/sustainableapps/caostoneproject/DataBase.java"
click PBS "https://github.com/alexyach1973/capstone/blob/master/app/src/main/java/org/coursera/sustainableapps/caostoneproject/PositionBindService.java"
click PRH "https://github.com/alexyach1973/capstone/blob/master/app/src/main/java/org/coursera/sustainableapps/caostoneproject/PositionRequestHandler.java"
click CL "https://github.com/alexyach1973/capstone/blob/master/app/src/main/java/org/coursera/sustainableapps/caostoneproject/CurrentLocation.java"
```
