# shashwatorg-2025/mobileapplication architecture

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

- Interactive diagram: https://gitdiagram.com/shashwatorg-2025/mobileapplication
- Repository: https://github.com/shashwatorg-2025/mobileapplication

## Overview

##### Project Type and Purpose
- This is a full-stack mobile application (React Native + Expo) focused on reporting and tracking emergency alerts in a community.
- The mobile client handles user authentication, report submission, map visualization, and profile management.
- An external REST API (not in this repo) provides authentication, alert storage, and retrieval.

##### File Structure Analysis
- Top-level files:
- App.js / index.js – App entry points (Expo bootstrap + root navigator)
- package.json, .eslintrc.js, .prettierrc.js – Project configuration
- src/ directory:
- screens/ – Seven screen-level components (Login, SignUp, Dashboard, Map, MapWeb, MyReports, Alerts, ManageProfile, ReportAlert)
- components/ – Reusable UI pieces (LoadingSpinner, ErrorMessage, map-specific overlays and markers)
- navigation/ – AppNavigator.js defines the navigation graph (stack and tab flows)
- services/ – API wrappers (authService.js, alertService.js, mapService.js)
- utils/ – Helper functions (mapUtils.js)

##### Key Insights from README
- Uses Expo CLI, React Navigation, AsyncStorage for token storage
- Environment variables (.env) for API_BASE_URL and GOOGLE_MAPS_API_KEY
- All network calls are centralized in services/ using async/await
- UI follows functional components with React Hooks

##### Main Components
a. Mobile Client
- Presentation Layer: Screen components and reusable UI components
- Navigation Layer: React Navigation controlling screen transitions
- Service Layer: authService, alertService, mapService calling REST endpoints
- Local Storage: AsyncStorage for persisting tokens and possibly cached data
b. External Services
- Backend REST API
– /auth (login, signup)
– /alerts (create, list, update)
- Google Maps (map tiles, geolocation, markers)
c. Data Stores (on the server side, inferred)
- User Database
- Alerts Database

##### Relationships and Interactions
- User interacts with Screens → Screens invoke Service layer → Service layer issues HTTP requests to Backend API → API reads/writes to Databases → API responses are returned to the client
- MapScreen loads map tiles from Google Maps API and overlays alert markers fetched via mapService
- authService stores JWT or auth token in AsyncStorage; screens check token on startup, navigate accordingly

##### Architectural Patterns and Principles
- Layered architecture (Presentation → Navigation → Services → External APIs)
- Separation of concerns: UI logic in screens/components, API logic in services
- Single source of truth for network configuration via environment variables
- Modular directory structure for scalability and testability

##### Detailed Capture of Architectural Elements
- Map overlays (AlertMarker, GridOverlay) as sub-components of MapScreen
- Call out the two platforms (iOS/Android) under the Expo umbrella

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Mobile App"
        subgraph "UI Layer"
            Login["LoginScreen"]:::ui
            SignUp["SignUpScreen"]:::ui
            Dashboard["DashboardScreen"]:::ui
            MyReports["MyReportsScreen"]:::ui
            Alerts["AlertsScreen"]:::ui
            ManageProfile["ManageProfileScreen"]:::ui
            ReportAlert["ReportAlertScreen"]:::ui
            subgraph "Map Components"
                MapMobile["MapScreen"]:::ui
                MapWeb["MapScreenWeb"]:::ui
                AlertMarker["AlertMarker"]:::ui
                GridOverlay["GridOverlay"]:::ui
            end
            ErrorMsg["ErrorMessage"]:::ui
            Spinner["LoadingSpinner"]:::ui
        end
        subgraph "Navigation Layer"
            Navigator["AppNavigator"]:::nav
        end
        subgraph "Service Layer"
            AuthService["authService"]:::service
            AlertService["alertService"]:::service
            MapService["mapService"]:::service
            Utils["mapUtils"]:::service
        end
        Storage["AsyncStorage"]:::storage
    end

    subgraph "External Services"
        API["Backend REST API"]:::external
        GoogleMaps["Google Maps API"]:::external
    end

    subgraph "Databases"
        UserDB["User Database"]:::db
        AlertsDB["Alerts Database"]:::db
    end

    %% Navigation flows
    Navigator --> Login
    Navigator --> SignUp
    Navigator --> Dashboard
    Navigator --> MyReports
    Navigator --> Alerts
    Navigator --> ManageProfile
    Navigator --> ReportAlert
    Navigator --> MapMobile
    Navigator --> MapWeb

    %% Screen to Service calls
    Login -->|"POST /auth/login"| AuthService
    SignUp -->|"POST /auth/signup"| AuthService
    ManageProfile -->|"PUT /auth/profile"| AuthService

    Dashboard -->|"GET /alerts"| AlertService
    MyReports -->|"GET /alerts/my"| AlertService
    Alerts -->|"GET /alerts"| AlertService
    ReportAlert -->|"POST /alerts"| AlertService

    MapMobile -->|"GET /alerts"| MapService
    MapWeb -->|"GET /alerts"| MapService

    %% Service to external
    AuthService -->|"POST /auth/login/signup"| API
    AlertService -->|"GET/POST /alerts"| API
    MapService -->|"GET /alerts"| API
    MapService -->|"Tiles & Geocode"| GoogleMaps

    %% API to Databases
    API -->|"user data"| UserDB
    API -->|"alerts data"| AlertsDB

    %% Storage interactions
    AuthService -->|"store token"| Storage
    AuthService -->|"retrieve token"| Storage

    %% Utility usage
    Utils --> MapService

    classDef ui fill:#AEDFF7,stroke:#0366d6,color:#0366d6
    classDef nav fill:#CDE7B0,stroke:#6A8E23,color:#6A8E23
    classDef service fill:#C8F7C5,stroke:#2E8B57,color:#2E8B57
    classDef storage fill:#FFF4A3,stroke:#DAA520,color:#DAA520
    classDef external fill:#FDD1B4,stroke:#D35400,color:#D35400
    classDef db fill:#F5C7F7,stroke:#A020F0,color:#A020F0

    %% Click Events
    click Login "https://github.com/shashwatorg-2025/mobileapplication/blob/main/src/screens/LoginScreen.js"
    click SignUp "https://github.com/shashwatorg-2025/mobileapplication/blob/main/src/screens/SignUpScreen.js"
    click Dashboard "https://github.com/shashwatorg-2025/mobileapplication/blob/main/src/screens/DashboardScreen.js"
    click MapMobile "https://github.com/shashwatorg-2025/mobileapplication/blob/main/src/screens/MapScreen.js"
    click MapWeb "https://github.com/shashwatorg-2025/mobileapplication/blob/main/src/screens/MapScreenWeb.js"
    click MyReports "https://github.com/shashwatorg-2025/mobileapplication/blob/main/src/screens/MyReportsScreen.js"
    click Alerts "https://github.com/shashwatorg-2025/mobileapplication/blob/main/src/screens/AlertsScreen.js"
    click ManageProfile "https://github.com/shashwatorg-2025/mobileapplication/blob/main/src/screens/ManageProfileScreen.js"
    click ReportAlert "https://github.com/shashwatorg-2025/mobileapplication/blob/main/src/screens/ReportAlertScreen.js"
    click ErrorMsg "https://github.com/shashwatorg-2025/mobileapplication/blob/main/src/components/ErrorMessage.js"
    click Spinner "https://github.com/shashwatorg-2025/mobileapplication/blob/main/src/components/LoadingSpinner.js"
    click AlertMarker "https://github.com/shashwatorg-2025/mobileapplication/blob/main/src/components/map/AlertMarker.js"
    click GridOverlay "https://github.com/shashwatorg-2025/mobileapplication/blob/main/src/components/map/GridOverlay.js"
    click Navigator "https://github.com/shashwatorg-2025/mobileapplication/blob/main/src/navigation/AppNavigator.js"
    click AuthService "https://github.com/shashwatorg-2025/mobileapplication/blob/main/src/services/authService.js"
    click AlertService "https://github.com/shashwatorg-2025/mobileapplication/blob/main/src/services/alertService.js"
    click MapService "https://github.com/shashwatorg-2025/mobileapplication/blob/main/src/services/mapService.js"
    click Utils "https://github.com/shashwatorg-2025/mobileapplication/blob/main/src/utils/mapUtils.js"
```
