# animesh-0041/expense-tracker-fe architecture

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

- Interactive diagram: https://gitdiagram.com/animesh-0041/expense-tracker-fe
- Repository: https://github.com/animesh-0041/expense-tracker-fe

## Overview

##### Project type and purpose
- This is a mobile expense-tracker application built with Expo/React Native (using Expo Router’s file-based “app/” directory), targeting Android (native Android folder & Gradle config present) and leveraging Supabase as its backend service.
- Purpose: Allow users to sign up, log in, record income/expenses, view dashboards (charts, lists), receive push notifications, and manage security (PIN, AsyncStorage).

##### File structure
- Top level:
- android/            → Native Android project (Kotlin MainActivity & Application, Gradle build, resources).
- app.json            → Expo configuration.
- app/                → Expo Router screens (file-based routing).
- api/                → Client-side API wrappers (.api.ts) for auth, transactions, notifications, feedback.
- components/         → Reusable UI components & common controls.
- context/            → React Context providers (AuthContext, Dialog, Snackbar).
- hooks/              → Custom hooks (data fetching: useAuth, useTransaction, etc.; device readiness, AsyncStorage).
- services/           → HTTP request setup (authRequest/publicRequest) and Supabase client.
- notifications/      → Push notification setup, permissions, listeners, scheduler.
- utils/, constants/, data/ → Helper functions, theme & API endpoint constants, mock data.
- No separate backend code—uses Supabase (external) for database/auth.

##### README
- Minimal (“expense-tracker”) – confirms it’s a simple expense-tracking mobile app.

a. Main components:
- Mobile App (UI Layer – Screens & Components)
- Navigation (Expo Router)
- State & Business Logic (React Context + Hooks)
- Service Layer (services/api & Supabase Client)
- External Backend (Supabase: Auth, Database, Storage)
- Local Data Storage (AsyncStorage & Secure PIN Storage)
- Notifications Subsystem (Permissions, Scheduler, Listeners)
- Native Android Runtime (Kotlin MainActivity/Application)
b. Relationships & interactions:
- UI Screens → invoke Hooks/Context → call Service Layer → HTTP to Supabase → responses back up.
- Notification scheduler & listeners register with native modules (Android Runtime) → push events into the App.
- AsyncStorage used by hooks and contexts for persisting tokens, PIN, preferences.
c. Architectural patterns/design principles:
- Separation of concerns: UI (components/screens) vs. state (Context/hooks) vs. data access (services) vs. external services.
- File-based routing (Expo Router) organizes screens under “app/”.
- Dependency inversion: API endpoints configured centrally (constants/apiEndPoints).
- React Context for cross-cutting concerns (auth state, dialogs, snackbars).
- Modular notifications: clear division between scheduler, listeners, utils.
d. Relevant technologies/frameworks:
- Expo & React Native with Expo Router
- TypeScript & React Context API
- React Query (implied by “use…“ hooks under hooks/queries)
- Supabase client (services/supabaseClient.ts)
- AsyncStorage and React Native Notifications
- Kotlin/Gradle for native Android bootstrap

##### Elements
- UI → Context/Hooks → Services → Supabase → backflow.
- App → Notification Scheduler → Device OS → Event → App.
- UI → AsyncStorage and AsyncStorage → UI.
- Green for service layer (services/, api/).
- Orange for external entities (Supabase, Device OS).
- Rounded rectangle for native Android.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer" 
        direction TB
        Screens["Screens (app/)"]:::frontend
        Components["Reusable Components (components/)"]:::frontend
        Navigation["Navigation (app/_layout.tsx)"]:::frontend
    end

    %% State & Business Logic
    subgraph "State & Business Logic"
        direction TB
        Contexts["React Context (context/)"]:::frontend
        Hooks["Custom Hooks (hooks/)"]:::frontend
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        APIWrappers["Client-Side API Wrappers (api/)"]:::services
        HTTPRequests["HTTP Requests (services/api/)"]:::services
        SupabaseClient["Supabase Client (services/supabaseClient.ts)"]:::services
    end

    %% Local Storage
    subgraph "Local Data Storage"
        direction TB
        AsyncStorage["AsyncStorage Helpers (utils/asyncStorage.ts)"]:::storage
        PINStorage["Secure PIN Storage (utils/pinStorage.ts)"]:::storage
    end

    %% Notifications
    subgraph "Notifications Subsystem"
        direction TB
        NotificationsCore["Core (notifications/index.ts)"]:::services
        Permissions["Permissions (notifications/permissions.ts)"]:::services
        Listeners["Listeners (notifications/listeners.ts)"]:::services
        Scheduler["Scheduler (notifications/scheduler.ts)"]:::services
    end

    %% External & Native
    Supabase["Supabase (Auth, Database, Storage)"]:::external
    DeviceOS["Device OS"]:::external
    AndroidNative["Android Runtime (MainActivity.kt/MainApplication.kt)"]:::native

    %% Connections
    Screens -->|"use"| Contexts
    Screens -->|"use"| Hooks
    Components -->|"used by"| Screens
    Navigation -->|"routes to"| Screens

    Contexts -->|"invoke"| HTTPRequests
    Hooks -->|"invoke"| HTTPRequests
    Contexts -->|"use"| AsyncStorage
    Hooks -->|"use"| AsyncStorage
    Screens -->|"persist PIN"| PINStorage

    HTTPRequests -->|"wraps"| APIWrappers
    APIWrappers -->|"calls"| SupabaseClient
    SupabaseClient -->|"HTTP"| Supabase

    NotificationsCore -->|"requests perms"| Permissions
    NotificationsCore -->|"schedules"| Scheduler
    Scheduler -->|"uses OS sched"| DeviceOS
    DeviceOS -->|"push event"| Listeners
    Listeners -->|"notifies"| NotificationsCore
    NotificationsCore -->|"emits"| Hooks

    AndroidNative -->|"hosts App & Notifications"| NotificationsCore
    AndroidNative -->|"entrypoint for"| Screens

    AsyncStorage -->|"data available"| Screens

    %% Click Events
    click Screens "https://github.com/animesh-0041/expense-tracker-fe/tree/main/app/"
    click Components "https://github.com/animesh-0041/expense-tracker-fe/tree/main/components/"
    click Navigation "https://github.com/animesh-0041/expense-tracker-fe/blob/main/app/_layout.tsx"
    click Contexts "https://github.com/animesh-0041/expense-tracker-fe/tree/main/context/"
    click Hooks "https://github.com/animesh-0041/expense-tracker-fe/tree/main/hooks/"
    click HTTPRequests "https://github.com/animesh-0041/expense-tracker-fe/blob/main/services/api/authRequest.ts"
    click SupabaseClient "https://github.com/animesh-0041/expense-tracker-fe/blob/main/services/supabaseClient.ts"
    click APIWrappers "https://github.com/animesh-0041/expense-tracker-fe/tree/main/api/"
    click AsyncStorage "https://github.com/animesh-0041/expense-tracker-fe/blob/main/utils/asyncStorage.ts"
    click PINStorage "https://github.com/animesh-0041/expense-tracker-fe/blob/main/utils/pinStorage.ts"
    click NotificationsCore "https://github.com/animesh-0041/expense-tracker-fe/blob/main/notifications/index.ts"
    click Permissions "https://github.com/animesh-0041/expense-tracker-fe/blob/main/notifications/permissions.ts"
    click Listeners "https://github.com/animesh-0041/expense-tracker-fe/blob/main/notifications/listeners.ts"
    click Scheduler "https://github.com/animesh-0041/expense-tracker-fe/blob/main/notifications/scheduler.ts"
    click Supabase "https://github.com/animesh-0041/expense-tracker-fe/blob/main/constants/apiEndPoints.ts"
    click AndroidNative "https://github.com/animesh-0041/expense-tracker-fe/blob/main/android/app/src/main/java/com/prajwal16/boltexponativewind/MainActivity.kt"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6,stroke-width:1px
    classDef services fill:#D0FFE0,stroke:#228B22,color:#228B22,stroke-width:1px
    classDef external fill:#FFE0D0,stroke:#FF8C00,color:#FF8C00,stroke-width:1px
    classDef storage fill:#E0E0E0,stroke:#696969,color:#696969,stroke-width:1px
    classDef native fill:#F0F0F0,stroke:#808080,color:#808080,stroke-width:1px
```
