# garibudimanoj-ops/financial-management-ai architecture

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

- Interactive diagram: https://gitdiagram.com/garibudimanoj-ops/financial-management-ai
- Repository: https://github.com/garibudimanoj-ops/financial-management-ai

## Overview

Financial Management AI is a multi-tenant bookkeeping and operations application with a CA co-pilot. A principal workflow is submitting a financial document, parsing it into a draft transaction for human review, and then using ledger reports to inspect balances and performance. The repository also exposes customer, invoice, inventory, purchasing, expense, and point-of-sale capabilities. The graph connects components only where the README or supplied source index/excerpts show the relationship; several business UI and service paths are represented without inferred call edges because their implementations were not sampled.

Main entry points: [`src/lib/prisma.ts`](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/lib/prisma.ts) (Application database), [`src/app/api/ai/ingest/route.ts`](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/app/api/ai/ingest/route.ts) (Document ingestion API), [`src/app/api/ca-assistant/chat/route.ts`](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/app/api/ca-assistant/chat/route.ts) (CA assistant chat), [`src/lib/invoices/service.ts`](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/lib/invoices/service.ts) (Invoice management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and tenancy"]
  node_auth["Authentication and RBAC<br/>[auth.ts]"]
  node_authui["Sign-in and onboarding<br/>[page.tsx]"]
end

subgraph group_operations["Business operations"]
  node_customers["Customer records<br/>[service.ts]"]
  node_invoices["Invoice management<br/>[service.ts]"]
  node_pos["Point of sale<br/>[POSTerminal.tsx]"]
  node_inventory["Inventory management<br/>[service.ts]"]
  node_purchases["Purchasing and suppliers<br/>[purchaseService.ts]"]
  node_expenses["Expense management<br/>[expenseService.ts]"]
end

subgraph group_ledger["Accounting and reports"]
  node_txnapi["Transaction API<br/>[route.ts]"]
  node_transactions["Double-entry transactions"]
  node_journal["Journal bridge<br/>[journalBridge.ts]"]
  node_reports["Financial reports<br/>[reportService.ts]"]
  node_reportapi["Report API endpoints<br/>[route.ts]"]
  node_reportui["Report screens<br/>[page.tsx]"]
end

subgraph group_copilot["CA co-pilot"]
  node_ingest["Document ingestion API<br/>[route.ts]"]
  node_parser["Financial document parser<br/>[documentParser.ts]"]
  node_orchestrator["Draft orchestration<br/>[llmOrchestrator.ts]"]
  node_compute["Deterministic computations"]
  node_assistant["CA assistant chat<br/>[route.ts]"]
end

subgraph group_platform["Shared platform"]
  node_db[("Application database<br/>[prisma.ts]")]
  node_audit["Audit logging<br/>[audit.ts]"]
end

node_user(("Business user"))
node_gemini{{"Google Gemini"}}

node_user -.->|"signs in"| node_authui
node_authui -.->|"authenticates"| node_auth
node_auth -->|"checks membership"| node_db
node_user -->|"uploads document"| node_ingest
node_ingest -->|"checks permission"| node_auth
node_ingest -->|"parses document"| node_parser
node_ingest -->|"builds draft"| node_orchestrator
node_orchestrator -->|"delegates calculations"| node_compute
node_ingest -->|"saves draft"| node_db
node_user -.->|"asks question"| node_assistant
node_assistant -->|"checks access"| node_auth
node_assistant -->|"reads business evidence"| node_db
node_assistant -->|"generates response"| node_gemini
node_assistant -->|"records audit event"| node_audit
node_user -->|"submits transaction"| node_txnapi
node_txnapi -->|"validates transaction"| node_transactions
node_user -->|"requests report"| node_reportapi
node_reportapi -->|"computes report"| node_reports
node_reports -->|"reads ledger entries"| node_db
node_user -.->|"views reports"| node_reportui
node_invoices -->|"uses customer records"| node_customers
node_invoices -->|"bridges to ledger"| node_journal
node_purchases -->|"bridges to ledger"| node_journal
node_expenses -->|"bridges to ledger"| node_journal
node_invoices -->|"persists records"| node_db
node_inventory -->|"persists stock"| node_db
node_purchases -->|"persists purchases"| node_db
node_expenses -->|"persists expenses"| node_db
node_customers -->|"reads and writes"| node_db
node_pos -.->|"uses sales flow"| node_invoices
node_pos -.->|"uses stock flow"| node_inventory

click node_auth "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/lib/auth.ts"
click node_authui "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/app/login/page.tsx"
click node_customers "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/lib/customers/service.ts"
click node_invoices "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/lib/invoices/service.ts"
click node_pos "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/components/pos/POSTerminal.tsx"
click node_inventory "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/lib/inventory/service.ts"
click node_purchases "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/services/purchases/purchaseService.ts"
click node_expenses "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/services/expenses/expenseService.ts"
click node_txnapi "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/app/api/transactions/route.ts"
click node_transactions "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/services/accounting/transactionService.ts"
click node_journal "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/services/accounting/journalBridge.ts"
click node_reports "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/services/accounting/reportService.ts"
click node_reportapi "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/app/api/reports/trial-balance/route.ts"
click node_reportui "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/app/reports/page.tsx"
click node_ingest "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/app/api/ai/ingest/route.ts"
click node_parser "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/services/ai/documentParser.ts"
click node_orchestrator "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/services/ai/llmOrchestrator.ts"
click node_compute "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/services/ai/computationEngine.ts"
click node_assistant "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/app/api/ca-assistant/chat/route.ts"
click node_db "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/lib/prisma.ts"
click node_audit "https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/lib/audit.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_auth,node_authui,node_user toneBlue
class node_customers,node_invoices,node_pos,node_inventory,node_purchases,node_expenses toneAmber
class node_txnapi,node_transactions,node_journal,node_reports,node_reportapi,node_reportui toneMint
class node_ingest,node_parser,node_orchestrator,node_compute,node_assistant toneRose
class node_db,node_audit,node_gemini toneIndigo
```

## Components

### Access and tenancy

- [Authentication and RBAC](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [Sign-in and onboarding](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/app/login/page.tsx): `src/app/login/page.tsx`

### Business operations

- [Customer records](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/lib/customers/service.ts): `src/lib/customers/service.ts`
- [Invoice management](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/lib/invoices/service.ts): `src/lib/invoices/service.ts`
- [Point of sale](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/components/pos/POSTerminal.tsx): `src/components/pos/POSTerminal.tsx`
- [Inventory management](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/lib/inventory/service.ts): `src/lib/inventory/service.ts`
- [Purchasing and suppliers](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/services/purchases/purchaseService.ts): `src/services/purchases/purchaseService.ts`
- [Expense management](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/services/expenses/expenseService.ts): `src/services/expenses/expenseService.ts`

### Accounting and reports

- [Transaction API](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/app/api/transactions/route.ts): `src/app/api/transactions/route.ts`
- [Double-entry transactions](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/services/accounting/transactionService.ts): `src/services/accounting/transactionService.ts`
- [Journal bridge](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/services/accounting/journalBridge.ts): `src/services/accounting/journalBridge.ts`
- [Financial reports](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/services/accounting/reportService.ts): `src/services/accounting/reportService.ts`
- [Report API endpoints](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/app/api/reports/trial-balance/route.ts): `src/app/api/reports/trial-balance/route.ts`
- [Report screens](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/app/reports/page.tsx): `src/app/reports/page.tsx`

### CA co-pilot

- [Document ingestion API](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/app/api/ai/ingest/route.ts): `src/app/api/ai/ingest/route.ts`
- [Financial document parser](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/services/ai/documentParser.ts): `src/services/ai/documentParser.ts`
- [Draft orchestration](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/services/ai/llmOrchestrator.ts): `src/services/ai/llmOrchestrator.ts`
- [Deterministic computations](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/services/ai/computationEngine.ts): `src/services/ai/computationEngine.ts`
- [CA assistant chat](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/app/api/ca-assistant/chat/route.ts): `src/app/api/ca-assistant/chat/route.ts`

### Shared platform

- [Application database](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/lib/prisma.ts): `src/lib/prisma.ts`
- [Audit logging](https://github.com/garibudimanoj-ops/financial-management-ai/blob/main/src/lib/audit.ts): `src/lib/audit.ts`

### Other components

- **Business user**
- **Google Gemini**

## Connections

- Business user → Sign-in and onboarding: signs in
- Sign-in and onboarding → Authentication and RBAC: authenticates
- Authentication and RBAC → Application database: checks membership (evidence: `src/lib/auth.ts`)
- Business user → Document ingestion API: uploads document (evidence: `README.md`)
- Document ingestion API → Authentication and RBAC: checks permission (evidence: `src/app/api/ai/ingest/route.ts`)
- Document ingestion API → Financial document parser: parses document (evidence: `src/app/api/ai/ingest/route.ts`)
- Document ingestion API → Draft orchestration: builds draft (evidence: `src/app/api/ai/ingest/route.ts`)
- Draft orchestration → Deterministic computations: delegates calculations (evidence: `src/services/ai/llmOrchestrator.ts`)
- Document ingestion API → Application database: saves draft (evidence: `src/app/api/ai/ingest/route.ts`)
- Business user → CA assistant chat: asks question
- CA assistant chat → Authentication and RBAC: checks access (evidence: `src/app/api/ca-assistant/chat/route.ts`)
- CA assistant chat → Application database: reads business evidence (evidence: `src/app/api/ca-assistant/chat/route.ts`)
- CA assistant chat → Google Gemini: generates response (evidence: `src/app/api/ca-assistant/chat/route.ts`)
- CA assistant chat → Audit logging: records audit event (evidence: `src/app/api/ca-assistant/chat/route.ts`)
- Business user → Transaction API: submits transaction (evidence: `README.md`)
- Transaction API → Double-entry transactions: validates transaction (evidence: `src/app/api/transactions/route.ts`)
- Business user → Report API endpoints: requests report (evidence: `README.md`)
- Report API endpoints → Financial reports: computes report (evidence: `src/app/api/reports/trial-balance/route.ts`)
- Financial reports → Application database: reads ledger entries (evidence: `src/services/accounting/reportService.ts`)
- Business user → Report screens: views reports
- Invoice management → Customer records: uses customer records (evidence: `src/lib/invoices/service.ts`)
- Invoice management → Journal bridge: bridges to ledger (evidence: `src/lib/invoices/service.ts`)
- Purchasing and suppliers → Journal bridge: bridges to ledger (evidence: `src/services/purchases/purchaseService.ts`)
- Expense management → Journal bridge: bridges to ledger (evidence: `src/services/expenses/expenseService.ts`)
- Invoice management → Application database: persists records (evidence: `src/lib/invoices/service.ts`)
- Inventory management → Application database: persists stock (evidence: `src/lib/inventory/service.ts`)
- Purchasing and suppliers → Application database: persists purchases (evidence: `src/services/purchases/purchaseService.ts`)
- Expense management → Application database: persists expenses (evidence: `src/services/expenses/expenseService.ts`)
- Customer records → Application database: reads and writes (evidence: `src/lib/customers/service.ts`)
- Point of sale → Invoice management: uses sales flow
- Point of sale → Inventory management: uses stock flow
