# datle04/fintrack architecture

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

- Interactive diagram: https://gitdiagram.com/datle04/fintrack
- Repository: https://github.com/datle04/fintrack

## Overview

FinTrack is an Express backend for personal-finance tracking. A user authenticates, records transactions, and can review budgets, savings goals, dashboards, reports, and analytics; transaction changes can trigger budget checks and goal recalculation. Admin APIs provide oversight, while chat, uploads, email, and real-time notifications extend the product. The graph follows the documented route mounting and sampled calls; several feature controllers and integrations are represented at their exact tree paths, but their internal wiring is not inferred where source excerpts were unavailable.

Main entry points: [`src/app.ts`](https://github.com/datle04/fintrack/blob/main/src/app.ts) (Express app), [`src/models`](https://github.com/datle04/fintrack/tree/main/src/models) (Finance models), [`src/controllers/transaction.controller.ts`](https://github.com/datle04/fintrack/blob/main/src/controllers/transaction.controller.ts) (Transactions), [`src/controllers/auth.controller.ts`](https://github.com/datle04/fintrack/blob/main/src/controllers/auth.controller.ts) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and access"]
  node_app["Express app<br/>[app.ts]"]
  node_authroutes["Auth routes<br/>[auth.routes.ts]"]
  node_auth["Authentication<br/>[auth.controller.ts]"]
  node_adminroutes["Admin routes<br/>[admin.routes.ts]"]
  node_adminusers["Admin user controls<br/>[user.controller.ts]"]
end

subgraph group_finance["Finance workflows"]
  node_txroutes["Transaction routes"]
  node_tx["Transactions"]
  node_budgets["Budget features"]
  node_budgetservice["Budget alert checks<br/>[budget.service.ts]"]
  node_goals["Savings goals<br/>[goal.controller.ts]"]
  node_goalservice["Goal progress<br/>[goal.service.ts]"]
end

subgraph group_insights["Insights and reports"]
  node_dashboard["Dashboard"]
  node_analytics["Analytics"]
  node_reports["Reports"]
end

subgraph group_platform["Persistence and operations"]
  node_models["Finance models"]
  node_mongo[("MongoDB")]
  node_jobs["Scheduled jobs"]
  node_socket["Socket sessions<br/>[sessionTracker.ts]"]
  node_notifications["Notifications"]
end

subgraph group_integrations["External integrations"]
  node_chat["Chat proxy"]
  node_ai{{"AI service"}}
  node_upload["Upload handling"]
  node_cloudinary{{"Cloudinary"}}
  node_email["Email delivery<br/>[email.service.ts]"]
  node_mailservice{{"Email provider"}}
end

node_user(("FinTrack user"))
node_admin(("Administrator"))

node_user -->|"requests API"| node_app
node_admin -->|"admin requests"| node_app
node_app -->|"mounts routes"| node_authroutes
node_app -->|"mounts routes"| node_adminroutes
node_app -->|"mounts routes"| node_txroutes
node_app -->|"mounts budget routes"| node_budgets
node_app -->|"mounts goal routes"| node_goals
node_app -->|"mounts dashboard routes"| node_dashboard
node_app -->|"mounts analytics routes"| node_analytics
node_app -->|"mounts report routes"| node_reports
node_app -->|"mounts chat routes"| node_chat
node_app -->|"mounts upload routes"| node_upload
node_authroutes -->|"dispatches"| node_auth
node_adminroutes -->|"dispatches"| node_adminusers
node_auth -->|"reads and writes"| node_models
node_tx -->|"reads and writes"| node_models
node_tx -->|"checks budget"| node_budgetservice
node_tx -->|"recalculates progress"| node_goalservice
node_budgetservice -->|"reads budget and transactions"| node_models
node_goals -->|"reads and writes"| node_models
node_goals -->|"recalculates progress"| node_goalservice
node_dashboard -->|"reads finance data"| node_models
node_analytics -->|"reads finance data"| node_models
node_reports -->|"report data"| node_models
node_models -->|"persists data"| node_mongo
node_jobs -->|"scheduled data work"| node_models
node_app -->|"sets up tracking"| node_socket
node_adminusers -->|"sends notification"| node_notifications
node_notifications -->|"emits events"| node_socket
node_chat -.->|"proxies requests"| node_ai
node_upload -.->|"uploads files"| node_cloudinary
node_auth -->|"sends OTP"| node_email
node_email -.->|"delivers email"| node_mailservice

click node_app "https://github.com/datle04/fintrack/blob/main/src/app.ts"
click node_authroutes "https://github.com/datle04/fintrack/blob/main/src/routes/auth.routes.ts"
click node_auth "https://github.com/datle04/fintrack/blob/main/src/controllers/auth.controller.ts"
click node_adminroutes "https://github.com/datle04/fintrack/blob/main/src/routes/admin.routes.ts"
click node_adminusers "https://github.com/datle04/fintrack/blob/main/src/controllers/admin/user.controller.ts"
click node_txroutes "https://github.com/datle04/fintrack/blob/main/src/routes/transaction.routes.ts"
click node_tx "https://github.com/datle04/fintrack/blob/main/src/controllers/transaction.controller.ts"
click node_budgets "https://github.com/datle04/fintrack/blob/main/src/controllers/budget.controller.ts"
click node_budgetservice "https://github.com/datle04/fintrack/blob/main/src/services/budget.service.ts"
click node_goals "https://github.com/datle04/fintrack/blob/main/src/controllers/goal.controller.ts"
click node_goalservice "https://github.com/datle04/fintrack/blob/main/src/services/goal.service.ts"
click node_dashboard "https://github.com/datle04/fintrack/blob/main/src/controllers/dashboard.controller.ts"
click node_analytics "https://github.com/datle04/fintrack/blob/main/src/controllers/analytics.controller.ts"
click node_reports "https://github.com/datle04/fintrack/blob/main/src/controllers/report.controller.ts"
click node_models "https://github.com/datle04/fintrack/tree/main/src/models"
click node_jobs "https://github.com/datle04/fintrack/tree/main/src/cron"
click node_socket "https://github.com/datle04/fintrack/blob/main/src/socket/sessionTracker.ts"
click node_notifications "https://github.com/datle04/fintrack/blob/main/src/services/notification.service.ts"
click node_chat "https://github.com/datle04/fintrack/blob/main/src/controllers/chatProxy.controller.ts"
click node_upload "https://github.com/datle04/fintrack/blob/main/src/controllers/upload.controller.ts"
click node_email "https://github.com/datle04/fintrack/blob/main/src/services/email.service.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_authroutes,node_auth,node_adminroutes,node_adminusers,node_user toneBlue
class node_txroutes,node_tx,node_budgets,node_budgetservice,node_goals,node_goalservice toneAmber
class node_dashboard,node_analytics,node_reports toneMint
class node_models,node_mongo,node_jobs,node_socket,node_notifications toneRose
class node_chat,node_ai,node_upload,node_cloudinary,node_email,node_mailservice,node_admin toneIndigo
```

## Components

### API and access

- [Express app](https://github.com/datle04/fintrack/blob/main/src/app.ts): `src/app.ts`
- [Auth routes](https://github.com/datle04/fintrack/blob/main/src/routes/auth.routes.ts): `src/routes/auth.routes.ts`
- [Authentication](https://github.com/datle04/fintrack/blob/main/src/controllers/auth.controller.ts): `src/controllers/auth.controller.ts`
- [Admin routes](https://github.com/datle04/fintrack/blob/main/src/routes/admin.routes.ts): `src/routes/admin.routes.ts`
- [Admin user controls](https://github.com/datle04/fintrack/blob/main/src/controllers/admin/user.controller.ts): `src/controllers/admin/user.controller.ts`

### Finance workflows

- [Transaction routes](https://github.com/datle04/fintrack/blob/main/src/routes/transaction.routes.ts): `src/routes/transaction.routes.ts`
- [Transactions](https://github.com/datle04/fintrack/blob/main/src/controllers/transaction.controller.ts): `src/controllers/transaction.controller.ts`
- [Budget features](https://github.com/datle04/fintrack/blob/main/src/controllers/budget.controller.ts): `src/controllers/budget.controller.ts`
- [Budget alert checks](https://github.com/datle04/fintrack/blob/main/src/services/budget.service.ts): `src/services/budget.service.ts`
- [Savings goals](https://github.com/datle04/fintrack/blob/main/src/controllers/goal.controller.ts): `src/controllers/goal.controller.ts`
- [Goal progress](https://github.com/datle04/fintrack/blob/main/src/services/goal.service.ts): `src/services/goal.service.ts`

### Insights and reports

- [Dashboard](https://github.com/datle04/fintrack/blob/main/src/controllers/dashboard.controller.ts): `src/controllers/dashboard.controller.ts`
- [Analytics](https://github.com/datle04/fintrack/blob/main/src/controllers/analytics.controller.ts): `src/controllers/analytics.controller.ts`
- [Reports](https://github.com/datle04/fintrack/blob/main/src/controllers/report.controller.ts): `src/controllers/report.controller.ts`

### Persistence and operations

- [Finance models](https://github.com/datle04/fintrack/tree/main/src/models): `src/models`
- **MongoDB**
- [Scheduled jobs](https://github.com/datle04/fintrack/tree/main/src/cron): `src/cron`
- [Socket sessions](https://github.com/datle04/fintrack/blob/main/src/socket/sessionTracker.ts): `src/socket/sessionTracker.ts`
- [Notifications](https://github.com/datle04/fintrack/blob/main/src/services/notification.service.ts): `src/services/notification.service.ts`

### External integrations

- [Chat proxy](https://github.com/datle04/fintrack/blob/main/src/controllers/chatProxy.controller.ts): `src/controllers/chatProxy.controller.ts`
- **AI service**
- [Upload handling](https://github.com/datle04/fintrack/blob/main/src/controllers/upload.controller.ts): `src/controllers/upload.controller.ts`
- **Cloudinary**
- [Email delivery](https://github.com/datle04/fintrack/blob/main/src/services/email.service.ts): `src/services/email.service.ts`
- **Email provider**

### Other components

- **FinTrack user**
- **Administrator**

## Connections

- FinTrack user → Express app: requests API
- Administrator → Express app: admin requests
- Express app → Auth routes: mounts routes
- Express app → Admin routes: mounts routes
- Express app → Transaction routes: mounts routes
- Express app → Budget features: mounts budget routes
- Express app → Savings goals: mounts goal routes
- Express app → Dashboard: mounts dashboard routes
- Express app → Analytics: mounts analytics routes
- Express app → Reports: mounts report routes
- Express app → Chat proxy: mounts chat routes
- Express app → Upload handling: mounts upload routes
- Auth routes → Authentication: dispatches
- Admin routes → Admin user controls: dispatches
- Authentication → Finance models: reads and writes
- Transactions → Finance models: reads and writes
- Transactions → Budget alert checks: checks budget
- Transactions → Goal progress: recalculates progress
- Budget alert checks → Finance models: reads budget and transactions
- Savings goals → Finance models: reads and writes
- Savings goals → Goal progress: recalculates progress
- Dashboard → Finance models: reads finance data
- Analytics → Finance models: reads finance data
- Reports → Finance models: report data
- Finance models → MongoDB: persists data
- Scheduled jobs → Finance models: scheduled data work
- Express app → Socket sessions: sets up tracking
- Admin user controls → Notifications: sends notification
- Notifications → Socket sessions: emits events
- Chat proxy → AI service: proxies requests
- Upload handling → Cloudinary: uploads files
- Authentication → Email delivery: sends OTP
- Email delivery → Email provider: delivers email
