# atifansari0345/spendly architecture

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

- Interactive diagram: https://gitdiagram.com/atifansari0345/spendly
- Repository: https://github.com/atifansari0345/spendly

## Overview

Spendly is a full-stack personal expense tracker. The primary workflow is account sign-in, then viewing and managing account-scoped expenses and categories; the dashboard, analytics, reports, and settings provide distinct ways to review and configure that data. The provider coordinates client state and remote repositories, while server-side actions and MongoDB support persistence. README documents Better Auth and MongoDB; unsampled data-action and persistence wiring is shown as unverified rather than inferred as direct calls.

Main entry points: [`src/app/spendly-provider.tsx`](https://github.com/atifansari0345/spendly/blob/main/src/app/spendly-provider.tsx) (Spendly state), [`src/app/(shell)/reports/page.tsx`](https://github.com/atifansari0345/spendly/blob/main/src/app/(shell)/reports/page.tsx) (Reports and export), [`src/lib/mongo`](https://github.com/atifansari0345/spendly/tree/main/src/lib/mongo) (MongoDB persistence), [`src/app/(shell)/expenses/page.tsx`](https://github.com/atifansari0345/spendly/blob/main/src/app/(shell)/expenses/page.tsx) (Expense page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_account["Account and shell"]
  node_login["Sign-in<br/>[page.tsx]"]
  node_signup["Sign-up<br/>[page.tsx]"]
  node_authui["Auth forms"]
  node_authroute["Auth endpoint<br/>[route.ts]"]
  node_auth["Better Auth<br/>[auth.ts]"]
  node_session["Session access<br/>[session.ts]"]
  node_shell["App shell<br/>[app-shell.tsx]"]
end

subgraph group_spending["Expense management"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_expensespage["Expense page<br/>[page.tsx]"]
  node_expenseui["Expense list and form"]
  node_provider["Spendly state"]
  node_expensemodel["Expense model<br/>[expense.ts]"]
  node_categories["Category settings"]
end

subgraph group_insights["Insights and reports"]
  node_analytics["Analytics<br/>[page.tsx]"]
  node_metrics["Expense metrics<br/>[expense-metrics.ts]"]
  node_reports["Reports and export<br/>[page.tsx]"]
  node_excel["Excel export<br/>[to-excel.ts]"]
end

subgraph group_persistence["Application data"]
  node_actions["Server actions<br/>[data-actions.ts]"]
  node_repos["Remote repositories"]
  node_mongo[("MongoDB persistence")]
end

node_user(("User"))
node_mongodb[("MongoDB service")]

node_user -->|"opens"| node_login
node_user -->|"opens"| node_signup
node_login -->|"renders"| node_authui
node_signup -->|"renders"| node_authui
node_authroute -->|"routes to"| node_auth
node_auth -->|"uses database"| node_mongo
node_session -->|"reads session"| node_auth
node_user -->|"views"| node_dashboard
node_user -->|"manages"| node_expensespage
node_user -->|"explores"| node_analytics
node_user -->|"reviews"| node_reports
node_user -->|"configures"| node_categories
node_dashboard -->|"reads state"| node_provider
node_expensespage -->|"reads state"| node_provider
node_expensespage -->|"renders"| node_expenseui
node_analytics -->|"reads state"| node_provider
node_analytics -->|"calculates"| node_metrics
node_reports -->|"reads state"| node_provider
node_reports -->|"calculates"| node_metrics
node_reports -->|"exports"| node_excel
node_expenseui -->|"uses state"| node_provider
node_provider -->|"creates repositories"| node_repos
node_provider -->|"calls actions"| node_actions
node_categories -->|"uses state"| node_provider
node_provider -->|"holds expenses"| node_expensemodel
node_actions -.->|"persists data"| node_mongo
node_repos -.->|"accesses records"| node_mongo
node_mongo -.->|"stores data"| node_mongodb
node_user -->|"uses interface"| node_shell

click node_login "https://github.com/atifansari0345/spendly/blob/main/src/app/login/page.tsx"
click node_signup "https://github.com/atifansari0345/spendly/blob/main/src/app/sign-up/page.tsx"
click node_authui "https://github.com/atifansari0345/spendly/tree/main/src/features/auth/ui"
click node_authroute "https://github.com/atifansari0345/spendly/blob/main/src/app/api/auth/%5B...all%5D/route.ts"
click node_auth "https://github.com/atifansari0345/spendly/blob/main/src/lib/auth.ts"
click node_session "https://github.com/atifansari0345/spendly/blob/main/src/lib/session.ts"
click node_shell "https://github.com/atifansari0345/spendly/blob/main/src/components/app-shell.tsx"
click node_dashboard "https://github.com/atifansari0345/spendly/blob/main/src/app/(shell)/page.tsx"
click node_expensespage "https://github.com/atifansari0345/spendly/blob/main/src/app/(shell)/expenses/page.tsx"
click node_expenseui "https://github.com/atifansari0345/spendly/tree/main/src/features/expenses/ui"
click node_provider "https://github.com/atifansari0345/spendly/blob/main/src/app/spendly-provider.tsx"
click node_expensemodel "https://github.com/atifansari0345/spendly/blob/main/src/features/expenses/models/expense.ts"
click node_categories "https://github.com/atifansari0345/spendly/blob/main/src/features/settings/ui/category-manager.tsx"
click node_analytics "https://github.com/atifansari0345/spendly/blob/main/src/app/(shell)/analytics/page.tsx"
click node_metrics "https://github.com/atifansari0345/spendly/blob/main/src/lib/analytics/expense-metrics.ts"
click node_reports "https://github.com/atifansari0345/spendly/blob/main/src/app/(shell)/reports/page.tsx"
click node_excel "https://github.com/atifansari0345/spendly/blob/main/src/lib/export/to-excel.ts"
click node_actions "https://github.com/atifansari0345/spendly/blob/main/src/app/data-actions.ts"
click node_repos "https://github.com/atifansari0345/spendly/blob/main/src/features/expenses/data/remote-repositories.ts"
click node_mongo "https://github.com/atifansari0345/spendly/tree/main/src/lib/mongo"

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_login,node_signup,node_authui,node_authroute,node_auth,node_session,node_shell,node_user toneBlue
class node_dashboard,node_expensespage,node_expenseui,node_provider,node_expensemodel,node_categories,node_mongodb toneAmber
class node_analytics,node_metrics,node_reports,node_excel toneMint
class node_actions,node_repos,node_mongo toneRose
```

## Components

### Account and shell

- [Sign-in](https://github.com/atifansari0345/spendly/blob/main/src/app/login/page.tsx): `src/app/login/page.tsx`
- [Sign-up](https://github.com/atifansari0345/spendly/blob/main/src/app/sign-up/page.tsx): `src/app/sign-up/page.tsx`
- [Auth forms](https://github.com/atifansari0345/spendly/tree/main/src/features/auth/ui): `src/features/auth/ui`
- [Auth endpoint](https://github.com/atifansari0345/spendly/blob/main/src/app/api/auth/%5B...all%5D/route.ts): `src/app/api/auth/[...all]/route.ts`
- [Better Auth](https://github.com/atifansari0345/spendly/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [Session access](https://github.com/atifansari0345/spendly/blob/main/src/lib/session.ts): `src/lib/session.ts`
- [App shell](https://github.com/atifansari0345/spendly/blob/main/src/components/app-shell.tsx): `src/components/app-shell.tsx`

### Expense management

- [Dashboard](https://github.com/atifansari0345/spendly/blob/main/src/app/(shell)/page.tsx): `src/app/(shell)/page.tsx`
- [Expense page](https://github.com/atifansari0345/spendly/blob/main/src/app/(shell)/expenses/page.tsx): `src/app/(shell)/expenses/page.tsx`
- [Expense list and form](https://github.com/atifansari0345/spendly/tree/main/src/features/expenses/ui): `src/features/expenses/ui`
- [Spendly state](https://github.com/atifansari0345/spendly/blob/main/src/app/spendly-provider.tsx): `src/app/spendly-provider.tsx`
- [Expense model](https://github.com/atifansari0345/spendly/blob/main/src/features/expenses/models/expense.ts): `src/features/expenses/models/expense.ts`
- [Category settings](https://github.com/atifansari0345/spendly/blob/main/src/features/settings/ui/category-manager.tsx): `src/features/settings/ui/category-manager.tsx`

### Insights and reports

- [Analytics](https://github.com/atifansari0345/spendly/blob/main/src/app/(shell)/analytics/page.tsx): `src/app/(shell)/analytics/page.tsx`
- [Expense metrics](https://github.com/atifansari0345/spendly/blob/main/src/lib/analytics/expense-metrics.ts): `src/lib/analytics/expense-metrics.ts`
- [Reports and export](https://github.com/atifansari0345/spendly/blob/main/src/app/(shell)/reports/page.tsx): `src/app/(shell)/reports/page.tsx`
- [Excel export](https://github.com/atifansari0345/spendly/blob/main/src/lib/export/to-excel.ts): `src/lib/export/to-excel.ts`

### Application data

- [Server actions](https://github.com/atifansari0345/spendly/blob/main/src/app/data-actions.ts): `src/app/data-actions.ts`
- [Remote repositories](https://github.com/atifansari0345/spendly/blob/main/src/features/expenses/data/remote-repositories.ts): `src/features/expenses/data/remote-repositories.ts`
- [MongoDB persistence](https://github.com/atifansari0345/spendly/tree/main/src/lib/mongo): `src/lib/mongo`

### Other components

- **User**
- **MongoDB service**

## Connections

- User → Sign-in: opens (evidence: `src/app/login/page.tsx`)
- User → Sign-up: opens (evidence: `src/app/sign-up/page.tsx`)
- Sign-in → Auth forms: renders (evidence: `src/app/login/page.tsx`)
- Sign-up → Auth forms: renders (evidence: `src/app/sign-up/page.tsx`)
- Auth endpoint → Better Auth: routes to (evidence: `src/app/api/auth/[...all]/route.ts`)
- Better Auth → MongoDB persistence: uses database (evidence: `src/lib/auth.ts`)
- Session access → Better Auth: reads session (evidence: `src/lib/session.ts`)
- User → Dashboard: views (evidence: `README.md`)
- User → Expense page: manages (evidence: `README.md`)
- User → Analytics: explores (evidence: `README.md`)
- User → Reports and export: reviews (evidence: `README.md`)
- User → Category settings: configures (evidence: `README.md`)
- Dashboard → Spendly state: reads state (evidence: `src/app/(shell)/page.tsx`)
- Expense page → Spendly state: reads state (evidence: `src/app/(shell)/expenses/page.tsx`)
- Expense page → Expense list and form: renders (evidence: `src/app/(shell)/expenses/page.tsx`)
- Analytics → Spendly state: reads state (evidence: `src/app/(shell)/analytics/page.tsx`)
- Analytics → Expense metrics: calculates (evidence: `src/app/(shell)/analytics/page.tsx`)
- Reports and export → Spendly state: reads state (evidence: `src/app/(shell)/reports/page.tsx`)
- Reports and export → Expense metrics: calculates (evidence: `src/app/(shell)/reports/page.tsx`)
- Reports and export → Excel export: exports (evidence: `src/app/(shell)/reports/page.tsx`)
- Expense list and form → Spendly state: uses state (evidence: `src/features/expenses/ui/expense-list.tsx`)
- Spendly state → Remote repositories: creates repositories (evidence: `src/app/spendly-provider.tsx`)
- Spendly state → Server actions: calls actions (evidence: `src/app/spendly-provider.tsx`)
- Category settings → Spendly state: uses state (evidence: `src/features/settings/ui/category-manager.tsx`)
- Spendly state → Expense model: holds expenses (evidence: `src/app/spendly-provider.tsx`)
- Server actions → MongoDB persistence: persists data
- Remote repositories → MongoDB persistence: accesses records
- MongoDB persistence → MongoDB service: stores data (evidence: `README.md`)
- User → App shell: uses interface (evidence: `README.md`)
