# ms-tech-geek/expense-tracker architecture

> Architecture diagram of the GitHub repository ms-tech-geek/expense-tracker, 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/ms-tech-geek/expense-tracker
- Repository: https://github.com/ms-tech-geek/expense-tracker

## Overview

Based on our analysis of the file tree and README, this project is a full-stack expense tracking application that leverages a React/TypeScript frontend (built with Vite) along with Capacitor to enable native mobile functionality (as seen in the Android folder). The application connects to an external Supabase backend (for both database and authentication needs).

##### Main Components
- Frontend Application:
- Located in the "src" directory with core React components (Auth, Expenses, Layout, Privacy, Settings) that handle user interactions.
- Built using React and Vite and styled with Tailwind CSS (configurations in tailwind.config.js).
- It communicates with Supabase through the client library defined in "src/lib/supabase.ts".
- Native Mobile Layer:
- Found within the "android" folder. This directory contains native Android project files generated by Capacitor.
- Capacitor configuration (capacitor.config.ts) ties the web code with the native Android wrapper, allowing the React app to run as a mobile app.
- External Services:
- Supabase serves as the backend for authentication (email-based) and data persistence.
- Migrations under the "supabase/migrations" directory define the database schema evolution.

##### Relationships and Interactions
- The React frontend interacts with Supabase via REST or GraphQL, using the dedicated client library to perform CRUD operations for expenses, and authentication flows.
- UI components (in "src/components") orchestrate the data flow and route user inputs such as expense creation, deletion, or data querying.
- The mobile wrapper (in the Android project) hosts the web app via Capacitor, bridging web and native functionalities.
- The external Supabase service receives migration-defined schemas and handles email authentication as configured.

##### Architectural Patterns and Principles
- Component-based Architecture: The frontend is modularized into clear, reusable components (e.g., Auth, Expenses, Layout).
- Separation of Concerns: UI logic is separated from data fetching (hooks under "src/hooks") and business logic (utils in "src/utils").
- Cross-Platform Integration: The use of Capacitor for native mobile support illustrates a hybrid app approach where a single codebase serves both web and native platforms.
- External Service Integration: Database and authentication responsibilities are delegated to Supabase.

##### Relevant Technologies
- Frontend: React, TypeScript, Vite, Tailwind CSS.
- Backend/Database: Supabase (real-time database and authentication service).
- Native Mobile: Capacitor (bridging web and native Android functionality).
- Build and Configuration: Various configuration files (e.g., tsconfig.json, vite.config.ts, android build files).

##### Elements
- Clearly labeled components:
- "Frontend (React/Vite Application)" with sub-components (Auth, Expenses, Layout, etc.)
- "Mobile Wrapper (Android with Capacitor)"
- "Supabase Backend" (Authentication & Database)
- Data flow from user interactions (through UI) to the Supabase backend.
- Dependency relationships between the frontend and external services.
- Bootstrapping of the web app inside the Capacitor native container.
- For example, rectangles for frontend modules, ovals for external services, and clouds for Supabase.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend (React/Vite Application)
    subgraph "Frontend (React/Vite Application)"
        FE["Main App (React/Vite)"]
        Auth["Auth Component"]
        Expenses["Expenses Component"]
        Layout["Layout Component"]
        Privacy["Privacy Component"]
        Settings["Settings Component"]
        API["Supabase Client"]
        Styling["Tailwind Styling"]
    end

    %% Native Mobile Layer
    subgraph "Native Mobile Layer"
        MobileWrapper["Android Project"]
        Capacitor["Capacitor Config"]
    end

    %% External Services
    SupabaseBackend["Supabase Backend"]
    Migrations["Database Migrations"]

    %% Relationships within Frontend
    FE -->|"uses"| Auth
    FE -->|"uses"| Expenses
    FE -->|"uses"| Layout
    FE -->|"uses"| Privacy
    FE -->|"uses"| Settings
    FE -->|"integrates"| API
    FE -->|"styledby"| Styling

    %% Mobile Integration
    MobileWrapper -->|"hosts"| FE
    Capacitor -->|"configures"| FE

    %% Communication with External Services
    API -->|"calls"| SupabaseBackend
    SupabaseBackend -->|"appliesSchema"| Migrations

    %% Click Events
    click FE "https://github.com/ms-tech-geek/expense-tracker/tree/main/src/"
    click Auth "https://github.com/ms-tech-geek/expense-tracker/tree/main/src/components/Auth"
    click Expenses "https://github.com/ms-tech-geek/expense-tracker/tree/main/src/components/Expenses"
    click Layout "https://github.com/ms-tech-geek/expense-tracker/tree/main/src/components/Layout"
    click Privacy "https://github.com/ms-tech-geek/expense-tracker/tree/main/src/components/Privacy"
    click Settings "https://github.com/ms-tech-geek/expense-tracker/tree/main/src/components/Settings"
    click API "https://github.com/ms-tech-geek/expense-tracker/blob/main/src/lib/supabase.ts"
    click Styling "https://github.com/ms-tech-geek/expense-tracker/blob/main/tailwind.config.js"
    click MobileWrapper "https://github.com/ms-tech-geek/expense-tracker/tree/main/android/"
    click Capacitor "https://github.com/ms-tech-geek/expense-tracker/blob/main/capacitor.config.ts"
    click Migrations "https://github.com/ms-tech-geek/expense-tracker/tree/main/supabase/migrations"

    %% Styles
    classDef frontend fill:#fcefa9,stroke:#333,stroke-width:2px;
    classDef mobile fill:#c1f5ff,stroke:#333,stroke-width:2px;
    classDef external fill:#ffb3ba,stroke:#333,stroke-width:2px;

    class FE,Auth,Expenses,Layout,Privacy,Settings,API,Styling frontend;
    class MobileWrapper,Capacitor mobile;
    class SupabaseBackend,Migrations external;
```
