# fbrusatti/applert architecture

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

- Interactive diagram: https://gitdiagram.com/fbrusatti/applert
- Repository: https://github.com/fbrusatti/applert

## Overview

##### Project Type & Overall Purpose
- This is a mobile application intended for real-time emergency notifications.
- It combines user authentication, real-time alert management, location services, and push notification integration.

##### Identifying the Main Components
a. User Interface & Navigation:
- The project uses Expo Router for navigating between screens.
- The file structure under the “app” directory shows different route groupings (e.g., (app), (auth), (tabs)). Identify each screen type:
- (auth): Contains the login screen for user authentication.
- (app): Houses the primary functional pages such as dashboard, alert details ([id].tsx), category details, and alert creation pages.
- (tabs): Likely represents the tab-based navigation layout.
- Components directory holds reusable UI components (AlertItem, Button, CategoryCard, etc.) which are rendered within these screens.

b. Business Logic & State Management:
- The “store” directory contains Zustand-based implementations for managing alerts and authentication.
- This layer encapsulates the app’s state logic and session management, ensuring that features like persisted auth state (via AsyncStorage) are enforced.

c. Services & External APIs:
- While not explicitly depicted in the file tree, the README references integration with Expo Location API and Expo Notifications. These services would be part of the external interactions.

d. Core Architectural Elements:
- Routing and Layout: The use of Expo Router and defined layouts (see _layout.tsx in both “app” and “tabs”) suggests an organized navigation structure.
- Component Abstraction: Reusable components (found in “components”) indicate adherence to modular design.
- Persistent State: With Zustand managing auth and alert states, the design should show how the state management layer interacts with both the UI and storage systems.

a. Create separate sections for:
- Frontend (UI): Illustrate screens/pages, navigation flows, and how components are reused.
- Routing & Layout: Show the routing structure with different paths (auth routes vs. app routes vs. tab navigation).

b. Relationships & Data Flow:
- Communication between parent layouts (app/_layout.tsx) and nested routed components.

c. Architectural Patterns and Design Principles:
- Separation of concerns: UI (components and layout), Business Logic (stores), and External Integration (Expo APIs).
- Modularity by grouping file subcomponents (for alerts, categories, and authentication) and showing their integration points with the central state management unit.
- How Expo Router organizes the mobile app into various navigational contexts (authenticated vs. non-authenticated screens).

d. Specific Technologies & Frameworks:
- React Native (Expo) for the core mobile interface.
- Expo Router for page routing.
- Zustand for state management, with AsyncStorage used for persisting authentication.
- Integration of Expo Location and Expo Notifications for external services.

## Diagram (Mermaid)

```mermaid
graph TD
    %% User Interface Layer
    subgraph "User Interface (React Native)"
        A["Login Screen"]:::ui
        B1["Dashboard Screen"]:::ui
        B2["Alert Details"]:::ui
        B3["Create Alert"]:::ui
        B4["Category Details"]:::ui
        C["Tab Layout"]:::ui
        D["Global Layout"]:::ui
        E["Reusable UI Components"]:::ui
        F["Expo Router (Navigation)"]:::router
    end

    %% State Management Layer
    subgraph "State Management"
        S1["Zustand Auth Store"]:::state
        S2["Zustand Alert Store"]:::state
        S3["AsyncStorage"]:::state
    end

    %% External Services Layer
    subgraph "External Services"
        X1["Expo Location API"]:::external
        X2["Expo Notifications API"]:::external
    end

    %% Supporting Modules Layer
    subgraph "Supporting Modules"
        M1["Constants (Colors)"]:::support
        M2a["Alert Types"]:::support
        M2b["Auth Types"]:::support
    end

    %% Connections from Routing to UI screens
    F --> A
    F --> B1
    F --> B2
    F --> B3
    F --> B4
    F --> C
    F --> D

    %% UI interactions with State Management
    A -->|"authFlow"| S1
    B1 -->|"alertData"| S2
    B2 -->|"alertData"| S2
    B3 -->|"alertData"| S2
    B4 -->|"alertData"| S2

    %% State persistence and external interactions
    S1 <-->|"persist"| S3
    S2 -->|"pushAlerts"| X2
    S2 -->|"locationUpdate"| X1

    %% Reusable UI Components dependencies
    E -->|"uses"| M1
    E -->|"uses"| M2a
    E -->|"uses"| M2b

    %% Click Events
    click A "https://github.com/fbrusatti/applert/blob/master/app/(auth)/login.tsx"
    click B1 "https://github.com/fbrusatti/applert/blob/master/app/(app)/dashboard.tsx"
    click B2 "https://github.com/fbrusatti/applert/blob/master/app/(app)/alert/[id].tsx"
    click B3 "https://github.com/fbrusatti/applert/blob/master/app/(app)/create-alert.tsx"
    click B4 "https://github.com/fbrusatti/applert/blob/master/app/(app)/category/[id].tsx"
    click C "https://github.com/fbrusatti/applert/blob/master/app/(tabs)/_layout.tsx"
    click D "https://github.com/fbrusatti/applert/blob/master/app/_layout.tsx"
    click E "https://github.com/fbrusatti/applert/tree/master/components"
    click S1 "https://github.com/fbrusatti/applert/blob/master/store/auth-store.ts"
    click S2 "https://github.com/fbrusatti/applert/blob/master/store/alert-store.ts"
    click M1 "https://github.com/fbrusatti/applert/blob/master/constants/colors.ts"
    click M2a "https://github.com/fbrusatti/applert/blob/master/types/alert.ts"
    click M2b "https://github.com/fbrusatti/applert/blob/master/types/auth.ts"

    %% Styles
    classDef ui fill:#AEDFF7,stroke:#1E90FF,stroke-width:2px;
    classDef router fill:#D1E8E2,stroke:#14919b,stroke-width:2px;
    classDef state fill:#FDE9A9,stroke:#E0A106,stroke-width:2px;
    classDef external fill:#F6ADB1,stroke:#E25856,stroke-width:2px;
    classDef support fill:#D3BDF0,stroke:#8A2BE2,stroke-width:2px;
```
