# abrahymzy/smart-expense-app architecture

> Architecture diagram of the GitHub repository abrahymzy/smart-expense-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abrahymzy/smart-expense-app
- Repository: https://github.com/abrahymzy/smart-expense-app

## Overview

Smart Expense is a personal expense-tracking web app. A user enters an expense by text or voice; the app parses it, asks for clarification or review when needed, then saves it locally and synchronizes signed-in users’ expenses and categories with Firebase (or uses a server API fallback). Dashboard, transaction, report, category-management, and account flows are represented. Source excerpts show the main page’s orchestration and selected integrations; unsampled details are omitted where their connections cannot be verified.

Main entry points: [`src/app/page.tsx`](https://github.com/abrahymzy/smart-expense-app/blob/main/src/app/page.tsx) (Expense workspace), [`src/types/expense.ts`](https://github.com/abrahymzy/smart-expense-app/blob/main/src/types/expense.ts) (Expense data model), [`src/context/AuthContext.tsx`](https://github.com/abrahymzy/smart-expense-app/blob/main/src/context/AuthContext.tsx) (Auth session), [`src/lib/firebase/firestore.ts`](https://github.com/abrahymzy/smart-expense-app/blob/main/src/lib/firebase/firestore.ts) (Firebase expense store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Expense capture"]
  node_workspace["Expense workspace<br/>[page.tsx]"]
  node_text_input["Text entry"]
  node_voice["Voice recognition<br/>[speech.ts]"]
  node_parser["Local parser<br/>[local-parser.ts]"]
  node_ai_parse["AI parse endpoint<br/>[route.ts]"]
  node_clarification["Clarification prompt"]
  node_review["Expense review<br/>[ReviewModal.tsx]"]
end

subgraph group_tracking["Expense management"]
  node_expense_types["Expense data model<br/>[expense.ts]"]
  node_dashboard["Dashboard<br/>[DashboardView.tsx]"]
  node_transactions["Transactions"]
  node_reports["Reports<br/>[ReportsView.tsx]"]
  node_expense_edit["Expense editing"]
  node_categories["Category management"]
  node_currency["Currency formatting<br/>[currency.ts]"]
end

subgraph group_identity["Identity"]
  node_auth_ui["Sign-in interface<br/>[AuthModal.tsx]"]
  node_auth_context["Auth session<br/>[AuthContext.tsx]"]
  node_firebase_auth["Firebase authentication<br/>[auth.ts]"]
  node_auth_api["Account API routes"]
  node_auth_types["User data model<br/>[auth.ts]"]
end

subgraph group_persistence["Storage and sync"]
  node_offline_db[("Local expense store<br/>[indexed-db.ts]")]
  node_firestore[("Firebase expense store<br/>[firestore.ts]")]
  node_sync_api["Sync API<br/>[route.ts]"]
  node_server_db[("Server data store<br/>[db.ts]")]
  node_firebase_config["Firebase configuration<br/>[config.ts]"]
end

node_user(("User"))

node_user -->|"uses"| node_workspace
node_workspace -->|"renders"| node_text_input
node_workspace -->|"invokes"| node_voice
node_workspace -->|"parses locally"| node_parser
node_workspace -.->|"requests parsing"| node_ai_parse
node_ai_parse -->|"falls back to"| node_parser
node_workspace -->|"renders"| node_clarification
node_workspace -->|"renders"| node_review
node_workspace -->|"renders"| node_dashboard
node_workspace -->|"renders"| node_transactions
node_workspace -->|"renders"| node_reports
node_workspace -->|"renders"| node_expense_edit
node_workspace -->|"renders"| node_categories
node_dashboard -->|"formats amounts"| node_currency
node_reports -->|"formats amounts"| node_currency
node_transactions -->|"formats amounts"| node_currency
node_workspace -->|"reads and writes"| node_offline_db
node_workspace -->|"syncs expenses"| node_firestore
node_workspace -->|"syncs categories"| node_firestore
node_workspace -->|"uses fallback"| node_sync_api
node_sync_api -->|"syncs expenses"| node_server_db
node_workspace -->|"renders"| node_auth_ui
node_auth_ui -->|"uses session"| node_auth_context
node_auth_context -->|"delegates sign-in"| node_firebase_auth
node_auth_context -->|"requests fallback auth"| node_auth_api
node_auth_api -->|"handles accounts"| node_server_db
node_auth_context -->|"uses user model"| node_auth_types
node_firebase_auth -->|"uses configuration"| node_firebase_config
node_workspace -->|"checks setup"| node_firebase_config
node_firestore -->|"uses configuration"| node_firebase_config
node_offline_db -->|"stores expenses"| node_expense_types
node_firestore -->|"stores expenses"| node_expense_types
node_server_db -->|"stores expenses"| node_expense_types
node_dashboard -->|"reads expense data"| node_expense_types
node_transactions -->|"reads expense data"| node_expense_types
node_expense_edit -->|"edits expense data"| node_expense_types
node_categories -->|"uses category model"| node_expense_types

click node_workspace "https://github.com/abrahymzy/smart-expense-app/blob/main/src/app/page.tsx"
click node_text_input "https://github.com/abrahymzy/smart-expense-app/blob/main/src/components/ExpenseInputBar.tsx"
click node_voice "https://github.com/abrahymzy/smart-expense-app/blob/main/src/lib/speech.ts"
click node_parser "https://github.com/abrahymzy/smart-expense-app/blob/main/src/lib/parser/local-parser.ts"
click node_ai_parse "https://github.com/abrahymzy/smart-expense-app/blob/main/src/app/api/ai/parse/route.ts"
click node_clarification "https://github.com/abrahymzy/smart-expense-app/blob/main/src/components/ClarificationModal.tsx"
click node_review "https://github.com/abrahymzy/smart-expense-app/blob/main/src/components/ReviewModal.tsx"
click node_expense_types "https://github.com/abrahymzy/smart-expense-app/blob/main/src/types/expense.ts"
click node_dashboard "https://github.com/abrahymzy/smart-expense-app/blob/main/src/components/DashboardView.tsx"
click node_transactions "https://github.com/abrahymzy/smart-expense-app/blob/main/src/components/TransactionsView.tsx"
click node_reports "https://github.com/abrahymzy/smart-expense-app/blob/main/src/components/ReportsView.tsx"
click node_expense_edit "https://github.com/abrahymzy/smart-expense-app/blob/main/src/components/ExpenseEditModal.tsx"
click node_categories "https://github.com/abrahymzy/smart-expense-app/blob/main/src/components/CategoriesModal.tsx"
click node_currency "https://github.com/abrahymzy/smart-expense-app/blob/main/src/lib/currency.ts"
click node_auth_ui "https://github.com/abrahymzy/smart-expense-app/blob/main/src/components/AuthModal.tsx"
click node_auth_context "https://github.com/abrahymzy/smart-expense-app/blob/main/src/context/AuthContext.tsx"
click node_firebase_auth "https://github.com/abrahymzy/smart-expense-app/blob/main/src/lib/firebase/auth.ts"
click node_auth_api "https://github.com/abrahymzy/smart-expense-app/tree/main/src/app/api/auth"
click node_auth_types "https://github.com/abrahymzy/smart-expense-app/blob/main/src/types/auth.ts"
click node_offline_db "https://github.com/abrahymzy/smart-expense-app/blob/main/src/lib/db/indexed-db.ts"
click node_firestore "https://github.com/abrahymzy/smart-expense-app/blob/main/src/lib/firebase/firestore.ts"
click node_sync_api "https://github.com/abrahymzy/smart-expense-app/blob/main/src/app/api/sync/route.ts"
click node_server_db "https://github.com/abrahymzy/smart-expense-app/blob/main/src/lib/server/db.ts"
click node_firebase_config "https://github.com/abrahymzy/smart-expense-app/blob/main/src/lib/firebase/config.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_workspace,node_text_input,node_voice,node_parser,node_ai_parse,node_clarification,node_review,node_user toneBlue
class node_expense_types,node_dashboard,node_transactions,node_reports,node_expense_edit,node_categories,node_currency toneAmber
class node_auth_ui,node_auth_context,node_firebase_auth,node_auth_api,node_auth_types toneMint
class node_offline_db,node_firestore,node_sync_api,node_server_db,node_firebase_config toneRose
```

## Components

### Expense capture

- [Expense workspace](https://github.com/abrahymzy/smart-expense-app/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Text entry](https://github.com/abrahymzy/smart-expense-app/blob/main/src/components/ExpenseInputBar.tsx): `src/components/ExpenseInputBar.tsx`
- [Voice recognition](https://github.com/abrahymzy/smart-expense-app/blob/main/src/lib/speech.ts): `src/lib/speech.ts`
- [Local parser](https://github.com/abrahymzy/smart-expense-app/blob/main/src/lib/parser/local-parser.ts): `src/lib/parser/local-parser.ts`
- [AI parse endpoint](https://github.com/abrahymzy/smart-expense-app/blob/main/src/app/api/ai/parse/route.ts): `src/app/api/ai/parse/route.ts`
- [Clarification prompt](https://github.com/abrahymzy/smart-expense-app/blob/main/src/components/ClarificationModal.tsx): `src/components/ClarificationModal.tsx`
- [Expense review](https://github.com/abrahymzy/smart-expense-app/blob/main/src/components/ReviewModal.tsx): `src/components/ReviewModal.tsx`

### Expense management

- [Expense data model](https://github.com/abrahymzy/smart-expense-app/blob/main/src/types/expense.ts): `src/types/expense.ts`
- [Dashboard](https://github.com/abrahymzy/smart-expense-app/blob/main/src/components/DashboardView.tsx): `src/components/DashboardView.tsx`
- [Transactions](https://github.com/abrahymzy/smart-expense-app/blob/main/src/components/TransactionsView.tsx): `src/components/TransactionsView.tsx`
- [Reports](https://github.com/abrahymzy/smart-expense-app/blob/main/src/components/ReportsView.tsx): `src/components/ReportsView.tsx`
- [Expense editing](https://github.com/abrahymzy/smart-expense-app/blob/main/src/components/ExpenseEditModal.tsx): `src/components/ExpenseEditModal.tsx`
- [Category management](https://github.com/abrahymzy/smart-expense-app/blob/main/src/components/CategoriesModal.tsx): `src/components/CategoriesModal.tsx`
- [Currency formatting](https://github.com/abrahymzy/smart-expense-app/blob/main/src/lib/currency.ts): `src/lib/currency.ts`

### Identity

- [Sign-in interface](https://github.com/abrahymzy/smart-expense-app/blob/main/src/components/AuthModal.tsx): `src/components/AuthModal.tsx`
- [Auth session](https://github.com/abrahymzy/smart-expense-app/blob/main/src/context/AuthContext.tsx): `src/context/AuthContext.tsx`
- [Firebase authentication](https://github.com/abrahymzy/smart-expense-app/blob/main/src/lib/firebase/auth.ts): `src/lib/firebase/auth.ts`
- [Account API routes](https://github.com/abrahymzy/smart-expense-app/tree/main/src/app/api/auth): `src/app/api/auth`
- [User data model](https://github.com/abrahymzy/smart-expense-app/blob/main/src/types/auth.ts): `src/types/auth.ts`

### Storage and sync

- [Local expense store](https://github.com/abrahymzy/smart-expense-app/blob/main/src/lib/db/indexed-db.ts): `src/lib/db/indexed-db.ts`
- [Firebase expense store](https://github.com/abrahymzy/smart-expense-app/blob/main/src/lib/firebase/firestore.ts): `src/lib/firebase/firestore.ts`
- [Sync API](https://github.com/abrahymzy/smart-expense-app/blob/main/src/app/api/sync/route.ts): `src/app/api/sync/route.ts`
- [Server data store](https://github.com/abrahymzy/smart-expense-app/blob/main/src/lib/server/db.ts): `src/lib/server/db.ts`
- [Firebase configuration](https://github.com/abrahymzy/smart-expense-app/blob/main/src/lib/firebase/config.ts): `src/lib/firebase/config.ts`

### Other components

- **User**

## Connections

- User → Expense workspace: uses (evidence: `src/app/page.tsx`)
- Expense workspace → Text entry: renders (evidence: `src/app/page.tsx`)
- Expense workspace → Voice recognition: invokes (evidence: `src/app/page.tsx`)
- Expense workspace → Local parser: parses locally (evidence: `src/app/page.tsx`)
- Expense workspace → AI parse endpoint: requests parsing
- AI parse endpoint → Local parser: falls back to (evidence: `src/app/api/ai/parse/route.ts`)
- Expense workspace → Clarification prompt: renders (evidence: `src/app/page.tsx`)
- Expense workspace → Expense review: renders (evidence: `src/app/page.tsx`)
- Expense workspace → Dashboard: renders (evidence: `src/app/page.tsx`)
- Expense workspace → Transactions: renders (evidence: `src/app/page.tsx`)
- Expense workspace → Reports: renders (evidence: `src/app/page.tsx`)
- Expense workspace → Expense editing: renders (evidence: `src/app/page.tsx`)
- Expense workspace → Category management: renders (evidence: `src/app/page.tsx`)
- Dashboard → Currency formatting: formats amounts (evidence: `src/components/DashboardView.tsx`)
- Reports → Currency formatting: formats amounts (evidence: `src/components/ReportsView.tsx`)
- Transactions → Currency formatting: formats amounts (evidence: `src/components/TransactionsView.tsx`)
- Expense workspace → Local expense store: reads and writes (evidence: `src/app/page.tsx`)
- Expense workspace → Firebase expense store: syncs expenses (evidence: `src/app/page.tsx`)
- Expense workspace → Firebase expense store: syncs categories (evidence: `src/app/page.tsx`)
- Expense workspace → Sync API: uses fallback (evidence: `src/app/page.tsx`)
- Sync API → Server data store: syncs expenses (evidence: `src/app/api/sync/route.ts`)
- Expense workspace → Sign-in interface: renders (evidence: `src/app/page.tsx`)
- Sign-in interface → Auth session: uses session (evidence: `src/components/AuthModal.tsx`)
- Auth session → Firebase authentication: delegates sign-in (evidence: `src/context/AuthContext.tsx`)
- Auth session → Account API routes: requests fallback auth (evidence: `src/context/AuthContext.tsx`)
- Account API routes → Server data store: handles accounts (evidence: `src/app/api/auth/login/route.ts`)
- Auth session → User data model: uses user model (evidence: `src/context/AuthContext.tsx`)
- Firebase authentication → Firebase configuration: uses configuration (evidence: `src/lib/firebase/auth.ts`)
- Expense workspace → Firebase configuration: checks setup (evidence: `src/app/page.tsx`)
- Firebase expense store → Firebase configuration: uses configuration (evidence: `src/lib/firebase/firestore.ts`)
- Local expense store → Expense data model: stores expenses (evidence: `src/lib/db/indexed-db.ts`)
- Firebase expense store → Expense data model: stores expenses (evidence: `src/lib/firebase/firestore.ts`)
- Server data store → Expense data model: stores expenses (evidence: `src/lib/server/db.ts`)
- Dashboard → Expense data model: reads expense data (evidence: `src/components/DashboardView.tsx`)
- Transactions → Expense data model: reads expense data (evidence: `src/components/TransactionsView.tsx`)
- Expense editing → Expense data model: edits expense data (evidence: `src/components/ExpenseEditModal.tsx`)
- Category management → Expense data model: uses category model (evidence: `src/components/CategoriesModal.tsx`)
