# rohitpvt/fairtab architecture

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

- Interactive diagram: https://gitdiagram.com/rohitpvt/fairtab
- Repository: https://github.com/rohitpvt/fairtab

## Overview

FairTab is an offline-first group finance app: users authenticate, organize groups and members, record shared expenses and receipts, then inspect balances and settle debts. Its domain also includes budgets, recurring expense drafts, analytics and smart insights. The map separates the client, shared financial logic, cloud operations and persistence/integrations. Edges are limited to relationships supported by the README or shown source references and excerpts; unsampled feature implementations are represented at their exact directories, with uncertain links omitted.

Main entry points: [`functions/src/index.ts`](https://github.com/rohitpvt/fairtab/blob/main/functions/src/index.ts) (Cloud operations), [`src/App.tsx`](https://github.com/rohitpvt/fairtab/blob/main/src/App.tsx) (App routes), [`src/features/receipts/OCRReviewPage.tsx`](https://github.com/rohitpvt/fairtab/blob/main/src/features/receipts/OCRReviewPage.tsx) (Receipt OCR review), [`src/infrastructure/offline/syncManager.ts`](https://github.com/rohitpvt/fairtab/blob/main/src/infrastructure/offline/syncManager.ts) (Offline sync queue)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_app["App routes<br/>[App.tsx]"]
  node_auth["Authentication<br/>[AuthProvider.tsx]"]
  node_groups["Groups and roles"]
  node_expenses["Expense ledger"]
  node_receipts["Receipt OCR review<br/>[OCRReviewPage.tsx]"]
  node_settlements["Debt settlement"]
  node_budgets["Budgets"]
  node_recurring["Recurring expenses"]
  node_analytics["Analytics and insights"]
  node_dashboard["Personal dashboard"]
  node_invitations["Invitations"]
end

subgraph group_domain["Financial domain"]
  node_domainmath["Ledger calculations"]
  node_domainanalytics["Insight engines<br/>[insightsEngine.ts]"]
  node_domainanalyticsengine["Analytics engine<br/>[analyticsEngine.ts]"]
end

subgraph group_backend["Cloud operations"]
  node_api["API routing<br/>[index.ts]"]
  node_cloud["Cloud operations<br/>[index.ts]"]
  node_expenseops["Expense operations"]
  node_budgetops["Budget operations"]
  node_groupops["Group operations<br/>[groupOperations.ts]"]
  node_invitationops["Invitation operations"]
  node_receiptops["Receipt operations"]
  node_recurringops["Recurring operations"]
  node_settlementops["Settlement operations"]
end

subgraph group_storage["Persistence and integrations"]
  node_firebase[("Firebase services<br/>[firebase.ts]")]
  node_groupservice["Group service<br/>[groupService.ts]"]
  node_receiptsvc["Receipt service<br/>[receiptService.ts]"]
  node_offline["Offline sync queue<br/>[syncManager.ts]"]
  node_receiptstore["Receipt storage<br/>[receiptStorage.ts]"]
end

node_user(("App user"))
node_s3[("S3 object storage")]

node_user -->|"uses"| node_app
node_app -->|"wraps routes"| node_auth
node_auth -->|"observes auth"| node_firebase
node_app -->|"routes to"| node_groups
node_app -->|"routes to"| node_expenses
node_app -->|"routes to"| node_receipts
node_app -->|"routes to"| node_settlements
node_groups -.->|"manages groups"| node_groupservice
node_expenses -.->|"queues writes"| node_offline
node_offline -->|"syncs operations"| node_firebase
node_offline -->|"syncs receipts"| node_receiptstore
node_offline -->|"calls service"| node_receiptsvc
node_receipts -->|"uploads and reads"| node_receiptstore
node_receiptstore -->|"requests URLs"| node_receiptsvc
node_receiptstore -->|"transfers files"| node_s3
node_receipts -.->|"requests OCR"| node_receiptops
node_api -->|"dispatches handlers"| node_cloud
node_cloud -->|"exports handlers"| node_expenseops
node_cloud -->|"exports handlers"| node_budgetops
node_cloud -->|"exports handlers"| node_groupops
node_cloud -->|"exports handlers"| node_invitationops
node_cloud -->|"exports handlers"| node_receiptops
node_cloud -->|"exports handlers"| node_recurringops
node_cloud -->|"exports handlers"| node_settlementops
node_expenseops -->|"validates splits"| node_domainmath
node_budgetops -->|"uses calculations"| node_domainanalyticsengine
node_recurringops -->|"creates expenses"| node_expenseops
node_settlementops -->|"uses expense logic"| node_expenseops
node_analytics -.->|"shows insights"| node_domainanalytics
node_domainanalytics -->|"computes progress"| node_domainanalyticsengine
node_dashboard -.->|"summarizes balances"| node_domainmath
node_settlements -.->|"simplifies debts"| node_domainmath
node_budgets -.->|"manages budgets"| node_budgetops
node_recurring -.->|"manages drafts"| node_recurringops
node_invitations -.->|"manages invites"| node_invitationops
node_groups -.->|"manages groups"| node_groupops
node_settlements -.->|"records payments"| node_settlementops
node_receipts -->|"allocates splits"| node_domainmath

click node_app "https://github.com/rohitpvt/fairtab/blob/main/src/App.tsx"
click node_auth "https://github.com/rohitpvt/fairtab/blob/main/src/features/auth/AuthProvider.tsx"
click node_groups "https://github.com/rohitpvt/fairtab/tree/main/src/features/groups"
click node_expenses "https://github.com/rohitpvt/fairtab/tree/main/src/features/expenses"
click node_receipts "https://github.com/rohitpvt/fairtab/blob/main/src/features/receipts/OCRReviewPage.tsx"
click node_settlements "https://github.com/rohitpvt/fairtab/tree/main/src/features/settlements"
click node_budgets "https://github.com/rohitpvt/fairtab/tree/main/src/features/budgets"
click node_recurring "https://github.com/rohitpvt/fairtab/tree/main/src/features/recurring"
click node_analytics "https://github.com/rohitpvt/fairtab/tree/main/src/features/analytics"
click node_dashboard "https://github.com/rohitpvt/fairtab/tree/main/src/features/dashboard"
click node_invitations "https://github.com/rohitpvt/fairtab/tree/main/src/features/invitations"
click node_domainmath "https://github.com/rohitpvt/fairtab/tree/main/packages/domain/src/expenses"
click node_domainanalytics "https://github.com/rohitpvt/fairtab/blob/main/packages/domain/src/expenses/insightsEngine.ts"
click node_api "https://github.com/rohitpvt/fairtab/blob/main/api/index.ts"
click node_cloud "https://github.com/rohitpvt/fairtab/blob/main/functions/src/index.ts"
click node_expenseops "https://github.com/rohitpvt/fairtab/blob/main/functions/src/expenseOperations.ts"
click node_budgetops "https://github.com/rohitpvt/fairtab/blob/main/functions/src/budgetOperations.ts"
click node_groupops "https://github.com/rohitpvt/fairtab/blob/main/functions/src/groupOperations.ts"
click node_invitationops "https://github.com/rohitpvt/fairtab/blob/main/functions/src/invitationOperations.ts"
click node_receiptops "https://github.com/rohitpvt/fairtab/blob/main/functions/src/receiptOperations.ts"
click node_recurringops "https://github.com/rohitpvt/fairtab/blob/main/functions/src/recurringOperations.ts"
click node_settlementops "https://github.com/rohitpvt/fairtab/blob/main/functions/src/settlementOperations.ts"
click node_firebase "https://github.com/rohitpvt/fairtab/blob/main/src/infrastructure/firebase/firebase.ts"
click node_groupservice "https://github.com/rohitpvt/fairtab/blob/main/src/infrastructure/firebase/groupService.ts"
click node_receiptsvc "https://github.com/rohitpvt/fairtab/blob/main/src/infrastructure/firebase/receiptService.ts"
click node_offline "https://github.com/rohitpvt/fairtab/blob/main/src/infrastructure/offline/syncManager.ts"
click node_receiptstore "https://github.com/rohitpvt/fairtab/blob/main/src/infrastructure/storage/receiptStorage.ts"
click node_domainanalyticsengine "https://github.com/rohitpvt/fairtab/blob/main/packages/domain/src/expenses/analyticsEngine.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_app,node_auth,node_groups,node_expenses,node_receipts,node_settlements,node_budgets,node_recurring,node_analytics,node_dashboard,node_invitations,node_user toneBlue
class node_domainmath,node_domainanalytics,node_domainanalyticsengine,node_s3 toneAmber
class node_api,node_cloud,node_expenseops,node_budgetops,node_groupops,node_invitationops,node_receiptops,node_recurringops,node_settlementops toneMint
class node_firebase,node_groupservice,node_receiptsvc,node_offline,node_receiptstore toneRose
```

## Components

### Client experience

- [App routes](https://github.com/rohitpvt/fairtab/blob/main/src/App.tsx): `src/App.tsx`
- [Authentication](https://github.com/rohitpvt/fairtab/blob/main/src/features/auth/AuthProvider.tsx): `src/features/auth/AuthProvider.tsx`
- [Groups and roles](https://github.com/rohitpvt/fairtab/tree/main/src/features/groups): `src/features/groups`
- [Expense ledger](https://github.com/rohitpvt/fairtab/tree/main/src/features/expenses): `src/features/expenses`
- [Receipt OCR review](https://github.com/rohitpvt/fairtab/blob/main/src/features/receipts/OCRReviewPage.tsx): `src/features/receipts/OCRReviewPage.tsx`
- [Debt settlement](https://github.com/rohitpvt/fairtab/tree/main/src/features/settlements): `src/features/settlements`
- [Budgets](https://github.com/rohitpvt/fairtab/tree/main/src/features/budgets): `src/features/budgets`
- [Recurring expenses](https://github.com/rohitpvt/fairtab/tree/main/src/features/recurring): `src/features/recurring`
- [Analytics and insights](https://github.com/rohitpvt/fairtab/tree/main/src/features/analytics): `src/features/analytics`
- [Personal dashboard](https://github.com/rohitpvt/fairtab/tree/main/src/features/dashboard): `src/features/dashboard`
- [Invitations](https://github.com/rohitpvt/fairtab/tree/main/src/features/invitations): `src/features/invitations`

### Financial domain

- [Ledger calculations](https://github.com/rohitpvt/fairtab/tree/main/packages/domain/src/expenses): `packages/domain/src/expenses`
- [Insight engines](https://github.com/rohitpvt/fairtab/blob/main/packages/domain/src/expenses/insightsEngine.ts): `packages/domain/src/expenses/insightsEngine.ts`
- [Analytics engine](https://github.com/rohitpvt/fairtab/blob/main/packages/domain/src/expenses/analyticsEngine.ts): `packages/domain/src/expenses/analyticsEngine.ts`

### Cloud operations

- [API routing](https://github.com/rohitpvt/fairtab/blob/main/api/index.ts): `api/index.ts`
- [Cloud operations](https://github.com/rohitpvt/fairtab/blob/main/functions/src/index.ts): `functions/src/index.ts`
- [Expense operations](https://github.com/rohitpvt/fairtab/blob/main/functions/src/expenseOperations.ts): `functions/src/expenseOperations.ts`
- [Budget operations](https://github.com/rohitpvt/fairtab/blob/main/functions/src/budgetOperations.ts): `functions/src/budgetOperations.ts`
- [Group operations](https://github.com/rohitpvt/fairtab/blob/main/functions/src/groupOperations.ts): `functions/src/groupOperations.ts`
- [Invitation operations](https://github.com/rohitpvt/fairtab/blob/main/functions/src/invitationOperations.ts): `functions/src/invitationOperations.ts`
- [Receipt operations](https://github.com/rohitpvt/fairtab/blob/main/functions/src/receiptOperations.ts): `functions/src/receiptOperations.ts`
- [Recurring operations](https://github.com/rohitpvt/fairtab/blob/main/functions/src/recurringOperations.ts): `functions/src/recurringOperations.ts`
- [Settlement operations](https://github.com/rohitpvt/fairtab/blob/main/functions/src/settlementOperations.ts): `functions/src/settlementOperations.ts`

### Persistence and integrations

- [Firebase services](https://github.com/rohitpvt/fairtab/blob/main/src/infrastructure/firebase/firebase.ts): `src/infrastructure/firebase/firebase.ts`
- [Group service](https://github.com/rohitpvt/fairtab/blob/main/src/infrastructure/firebase/groupService.ts): `src/infrastructure/firebase/groupService.ts`
- [Receipt service](https://github.com/rohitpvt/fairtab/blob/main/src/infrastructure/firebase/receiptService.ts): `src/infrastructure/firebase/receiptService.ts`
- [Offline sync queue](https://github.com/rohitpvt/fairtab/blob/main/src/infrastructure/offline/syncManager.ts): `src/infrastructure/offline/syncManager.ts`
- [Receipt storage](https://github.com/rohitpvt/fairtab/blob/main/src/infrastructure/storage/receiptStorage.ts): `src/infrastructure/storage/receiptStorage.ts`

### Other components

- **App user**
- **S3 object storage**

## Connections

- App user → App routes: uses
- App routes → Authentication: wraps routes (evidence: `src/App.tsx`)
- Authentication → Firebase services: observes auth (evidence: `src/features/auth/AuthProvider.tsx`)
- App routes → Groups and roles: routes to (evidence: `src/App.tsx`)
- App routes → Expense ledger: routes to (evidence: `src/App.tsx`)
- App routes → Receipt OCR review: routes to (evidence: `src/App.tsx`)
- App routes → Debt settlement: routes to (evidence: `src/App.tsx`)
- Groups and roles → Group service: manages groups (evidence: `src/infrastructure/firebase/groupService.ts`)
- Expense ledger → Offline sync queue: queues writes
- Offline sync queue → Firebase services: syncs operations (evidence: `src/infrastructure/offline/syncManager.ts`)
- Offline sync queue → Receipt storage: syncs receipts (evidence: `src/infrastructure/offline/syncManager.ts`)
- Offline sync queue → Receipt service: calls service (evidence: `src/infrastructure/offline/syncManager.ts`)
- Receipt OCR review → Receipt storage: uploads and reads (evidence: `src/features/receipts/OCRReviewPage.tsx`)
- Receipt storage → Receipt service: requests URLs (evidence: `src/infrastructure/storage/receiptStorage.ts`)
- Receipt storage → S3 object storage: transfers files (evidence: `src/infrastructure/storage/receiptStorage.ts`)
- Receipt OCR review → Receipt operations: requests OCR
- API routing → Cloud operations: dispatches handlers (evidence: `api/index.ts`)
- Cloud operations → Expense operations: exports handlers (evidence: `functions/src/index.ts`)
- Cloud operations → Budget operations: exports handlers (evidence: `functions/src/index.ts`)
- Cloud operations → Group operations: exports handlers (evidence: `functions/src/index.ts`)
- Cloud operations → Invitation operations: exports handlers (evidence: `functions/src/index.ts`)
- Cloud operations → Receipt operations: exports handlers (evidence: `functions/src/index.ts`)
- Cloud operations → Recurring operations: exports handlers (evidence: `functions/src/index.ts`)
- Cloud operations → Settlement operations: exports handlers (evidence: `functions/src/index.ts`)
- Expense operations → Ledger calculations: validates splits (evidence: `functions/src/expenseOperations.ts`)
- Budget operations → Analytics engine: uses calculations (evidence: `functions/src/budgetOperations.ts`)
- Recurring operations → Expense operations: creates expenses (evidence: `functions/src/recurringOperations.ts`)
- Settlement operations → Expense operations: uses expense logic (evidence: `functions/src/settlementOperations.ts`)
- Analytics and insights → Insight engines: shows insights
- Insight engines → Analytics engine: computes progress (evidence: `packages/domain/src/expenses/insightsEngine.ts`)
- Personal dashboard → Ledger calculations: summarizes balances
- Debt settlement → Ledger calculations: simplifies debts
- Budgets → Budget operations: manages budgets
- Recurring expenses → Recurring operations: manages drafts
- Invitations → Invitation operations: manages invites
- Groups and roles → Group operations: manages groups
- Debt settlement → Settlement operations: records payments
- Receipt OCR review → Ledger calculations: allocates splits (evidence: `src/features/receipts/OCRReviewPage.tsx`)
