# shaikabdulkhadar1/ai-budget-management-app architecture

> Architecture diagram of the GitHub repository shaikabdulkhadar1/ai-budget-management-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shaikabdulkhadar1/ai-budget-management-app
- Repository: https://github.com/shaikabdulkhadar1/ai-budget-management-app

## Overview

##### Project type and purpose
- This is a cross-platform mobile full-stack application (“AI-Budget Tracker”) built with React Native/Expo on the frontend and a cloud backend (Firebase / Supabase) plus external AI/OCR services.
- Purpose: let users track income/expenses, set budgets, get AI-powered insights (via Gemini 2.5 Flash), and optionally scan receipts (OCR).

##### File structure
- Top-level:
- README.md, firestore.* files → Firebase rules & indexes
- frontend/ → all React Native code
- frontend/ hierarchy shows:
- App.tsx, navigation/ → app entry & screen routing
- components/ → UI pieces (ExpenseCard, etc.)
- src/contexts → React Context for Auth
- src/lib/firebase & src/lib/supabase → wrappers for data/auth backends
- src/screens → feature screens (Dashboard, AddExpense, Profile, etc.)
- src/services → business logic API calls (transactionService, userService)
- src/utils → formatting helpers
- No custom Node/Express folder—backend is serverless (Firestore or Supabase) plus third-party AI/OCR.

##### README for additional insights
- Confirms tech stack: React Native, TypeScript, Firebase/Node + Express (but code shows serverless Firebase or Supabase), AI via Gemini REST API, OCR via Cloud Vision or Tesseract.
- Features/auth flow, charting, prediction, and prompt patterns.

##### Final guidance
- Break the system into as many discrete pieces as possible (UI screens, state layer, API wrappers, external services).
- Data flows end-to-end: from user tapping “Add Expense” to Firestore write, to AI prompt, to visualization.
- Be very detailed: annotate the transport mechanisms (HTTPS, WebSocket), authentication tokens, error handling paths.
- Iterate with the team to refine details (e.g., exact Firestore collections, Supabase functions, caching strategies).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client (Mobile App)"
        direction TB
        App["App.tsx"]:::clientMod
        Navigator["AppNavigator"]:::clientMod
        Components["UI Components"]:::clientMod
        Screens["Screens"]:::clientMod
        AuthContext["AuthContext"]:::clientMod
        LocalStorage["Local Storage (AsyncStorage / SecureStore)"]:::storage
        subgraph "Service Config"
            direction TB
            FirebaseConfig["Firebase Config"]:::clientMod
            SupabaseConfig["Supabase Config"]:::clientMod
            SupabaseAuth["Supabase Auth Wrapper"]:::clientMod
            SupabaseDB["Supabase Database Wrapper"]:::clientMod
            Polyfills["Polyfills"]:::clientMod
        end
        subgraph "Services"
            direction TB
            TransactionService["TransactionService"]:::clientMod
            UserService["UserService"]:::clientMod
        end
        Utils["Utils"]:::clientMod
    end

    %% Cloud Services
    subgraph "Cloud Services"
        direction TB
        AuthService["Firebase Auth / Supabase Auth"]:::cloudMod
        Database["Firestore / Supabase DB"]:::database
    end

    %% External APIs
    subgraph "External APIs"
        direction TB
        AIEngine["Gemini 2.5 Flash API"]:::externalApi
        OCRService["OCR Service (Cloud Vision / Tesseract)"]:::externalApi
    end

    %% Connections
    App --> Navigator
    App --> AuthContext
    App --> Components
    App --> Screens
    App --> LocalStorage

    Navigator --> Screens

    Screens --> TransactionService
    Screens --> UserService
    Screens --> OCRService

    TransactionService -->|HTTPS REST| AIEngine
    TransactionService -->|CRUD via SDK/REST| Database
    TransactionService --> AuthService

    UserService -->|Auth calls| AuthService
    UserService -->|Profile CRUD| Database

    OCRService -->|Parsed Data| TransactionService

    AuthContext -->|Stores Token| LocalStorage
    LocalStorage -->|Retrieves Token| AuthContext

    FirebaseConfig --> AuthService
    SupabaseConfig --> AuthService
    SupabaseAuth --> AuthService
    SupabaseDB --> Database
    Polyfills --> App

    Utils --> TransactionService
    Utils --> UserService

    %% Click Events
    click App "https://github.com/shaikabdulkhadar1/ai-budget-management-app/blob/main/frontend/App.tsx"
    click Navigator "https://github.com/shaikabdulkhadar1/ai-budget-management-app/blob/main/frontend/navigation/AppNavigator.tsx"
    click Components "https://github.com/shaikabdulkhadar1/ai-budget-management-app/blob/main/frontend/components/ExpenseCard.tsx"
    click Screens "https://github.com/shaikabdulkhadar1/ai-budget-management-app/tree/main/frontend/src/screens/"
    click AuthContext "https://github.com/shaikabdulkhadar1/ai-budget-management-app/blob/main/frontend/src/contexts/AuthContext.tsx"
    click FirebaseConfig "https://github.com/shaikabdulkhadar1/ai-budget-management-app/blob/main/frontend/src/lib/firebase/config.ts"
    click SupabaseConfig "https://github.com/shaikabdulkhadar1/ai-budget-management-app/blob/main/frontend/src/lib/supabase/config.ts"
    click SupabaseAuth "https://github.com/shaikabdulkhadar1/ai-budget-management-app/blob/main/frontend/src/lib/supabase/auth.ts"
    click SupabaseDB "https://github.com/shaikabdulkhadar1/ai-budget-management-app/blob/main/frontend/src/lib/supabase/database.ts"
    click Polyfills "https://github.com/shaikabdulkhadar1/ai-budget-management-app/blob/main/frontend/src/lib/polyfills.ts"
    click TransactionService "https://github.com/shaikabdulkhadar1/ai-budget-management-app/blob/main/frontend/src/services/transactionService.ts"
    click UserService "https://github.com/shaikabdulkhadar1/ai-budget-management-app/blob/main/frontend/src/services/userService.ts"
    click Utils "https://github.com/shaikabdulkhadar1/ai-budget-management-app/blob/main/frontend/src/utils/formatters.ts"

    %% Styles
    classDef clientMod fill:#d0e6ff,stroke:#333,color:#000
    classDef cloudMod fill:#d0ffd6,stroke:#333,color:#000
    classDef externalApi fill:#ffd1a6,stroke:#333,color:#000
    classDef database fill:#ccffcc,stroke:#333,color:#000
    classDef storage fill:#e6e6e6,stroke:#333,color:#000
```
