# 21d4n/expense-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/21d4n/expense-tracker
- Repository: https://github.com/21d4n/expense-tracker

## Overview

Expense Tracker is a Next.js personal-finance app: users register or log in, then view per-user income, expenses, balance, and transaction history; they can create, edit, delete, and filter transactions. Server actions and pages enforce ownership and use Prisma for persistence. The sampled code confirms the dashboard query and authentication flow; transaction-action internals and several route implementations were not sampled, so those links reflect documented capabilities rather than inferred call details.

Main entry points: [`src/app/dashboard/page.tsx`](https://github.com/21d4n/expense-tracker/blob/main/src/app/dashboard/page.tsx) (Dashboard page), [`src/lib/auth.ts`](https://github.com/21d4n/expense-tracker/blob/main/src/lib/auth.ts) (Session and auth), [`src/lib/prisma.ts`](https://github.com/21d4n/expense-tracker/blob/main/src/lib/prisma.ts) (Prisma client), [`src/actions/auth.ts`](https://github.com/21d4n/expense-tracker/blob/main/src/actions/auth.ts) (Auth actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_auth["Account access"]
  node_home["Landing page<br/>[page.tsx]"]
  node_login["Login page<br/>[page.tsx]"]
  node_loginform["Login form<br/>[login-form.tsx]"]
  node_register["Registration page<br/>[page.tsx]"]
  node_registerform["Registration form<br/>[register-form.tsx]"]
  node_authaction["Auth actions<br/>[auth.ts]"]
  node_logout["Logout route<br/>[route.ts]"]
end

subgraph group_dashboard["Financial overview"]
  node_dashboardpage["Dashboard page<br/>[page.tsx]"]
  node_summary["Summary cards<br/>[SummaryCards.tsx]"]
  node_filters["Dashboard filters<br/>[FilterTabs.tsx]"]
  node_history["Transaction history"]
end

subgraph group_transactions["Transaction management"]
  node_transactionroutes["Transaction pages"]
  node_transactionform["Transaction form"]
  node_transactionaction["Transaction actions<br/>[transactions.ts]"]
end

subgraph group_data["Security and storage"]
  node_middleware["Route middleware<br/>[middleware.ts]"]
  node_authlib["Session and auth<br/>[auth.ts]"]
  node_postgres[("PostgreSQL database<br/>[schema.prisma]")]
  node_prisma["Prisma client<br/>[prisma.ts]"]
end

node_user(("User"))
node_browser["Browser"]
node_cookie["HttpOnly session cookie"]

node_user -->|"uses"| node_browser
node_browser -->|"opens"| node_home
node_browser -->|"opens"| node_login
node_browser -->|"opens"| node_register
node_login -->|"renders"| node_loginform
node_register -->|"renders"| node_registerform
node_loginform -->|"submits to"| node_authaction
node_registerform -->|"submits to"| node_authaction
node_authaction -->|"reads/writes accounts"| node_prisma
node_authaction -->|"hashes; creates session"| node_authlib
node_authlib -->|"reads/writes sessions"| node_prisma
node_authlib -->|"sets/reads/deletes"| node_cookie
node_browser -->|"requests routes"| node_middleware
node_middleware -->|"reads"| node_cookie
node_browser -->|"requests logout"| node_logout
node_logout -->|"deletes session"| node_authlib
node_dashboardpage -->|"requires verified session"| node_authlib
node_browser -->|"opens dashboard"| node_dashboardpage
node_dashboardpage -->|"queries user transactions"| node_prisma
node_prisma -->|"queries"| node_postgres
node_dashboardpage -->|"passes totals"| node_summary
node_dashboardpage -->|"passes active filter"| node_filters
node_dashboardpage -->|"passes transaction rows"| node_history
node_browser -->|"opens transaction pages"| node_transactionroutes
node_transactionroutes -->|"renders form"| node_transactionform
node_transactionform -->|"submits create/edit"| node_transactionaction
node_transactionaction -->|"manages owned transactions"| node_prisma
node_history -->|"links edit"| node_transactionroutes

click node_home "https://github.com/21d4n/expense-tracker/blob/main/src/app/page.tsx"
click node_login "https://github.com/21d4n/expense-tracker/blob/main/src/app/(auth)/login/page.tsx"
click node_loginform "https://github.com/21d4n/expense-tracker/blob/main/src/app/(auth)/login/login-form.tsx"
click node_register "https://github.com/21d4n/expense-tracker/blob/main/src/app/(auth)/register/page.tsx"
click node_registerform "https://github.com/21d4n/expense-tracker/blob/main/src/app/(auth)/register/register-form.tsx"
click node_authaction "https://github.com/21d4n/expense-tracker/blob/main/src/actions/auth.ts"
click node_logout "https://github.com/21d4n/expense-tracker/blob/main/src/app/(auth)/logout/route.ts"
click node_middleware "https://github.com/21d4n/expense-tracker/blob/main/src/middleware.ts"
click node_authlib "https://github.com/21d4n/expense-tracker/blob/main/src/lib/auth.ts"
click node_dashboardpage "https://github.com/21d4n/expense-tracker/blob/main/src/app/dashboard/page.tsx"
click node_summary "https://github.com/21d4n/expense-tracker/blob/main/src/components/dashboard/SummaryCards.tsx"
click node_filters "https://github.com/21d4n/expense-tracker/blob/main/src/components/dashboard/FilterTabs.tsx"
click node_history "https://github.com/21d4n/expense-tracker/blob/main/src/components/dashboard/TransactionList.tsx"
click node_transactionroutes "https://github.com/21d4n/expense-tracker/tree/main/src/app/dashboard/transactions"
click node_transactionform "https://github.com/21d4n/expense-tracker/blob/main/src/components/transactions/transaction-form.tsx"
click node_transactionaction "https://github.com/21d4n/expense-tracker/blob/main/src/actions/transactions.ts"
click node_postgres "https://github.com/21d4n/expense-tracker/blob/main/prisma/schema.prisma"
click node_prisma "https://github.com/21d4n/expense-tracker/blob/main/src/lib/prisma.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_home,node_login,node_loginform,node_register,node_registerform,node_authaction,node_logout,node_user,node_browser toneBlue
class node_dashboardpage,node_summary,node_filters,node_history toneAmber
class node_transactionroutes,node_transactionform,node_transactionaction toneMint
class node_middleware,node_authlib,node_postgres,node_prisma toneRose
class node_cookie toneIndigo
```

## Components

### Account access

- [Landing page](https://github.com/21d4n/expense-tracker/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Login page](https://github.com/21d4n/expense-tracker/blob/main/src/app/(auth)/login/page.tsx): `src/app/(auth)/login/page.tsx`
- [Login form](https://github.com/21d4n/expense-tracker/blob/main/src/app/(auth)/login/login-form.tsx): `src/app/(auth)/login/login-form.tsx`
- [Registration page](https://github.com/21d4n/expense-tracker/blob/main/src/app/(auth)/register/page.tsx): `src/app/(auth)/register/page.tsx`
- [Registration form](https://github.com/21d4n/expense-tracker/blob/main/src/app/(auth)/register/register-form.tsx): `src/app/(auth)/register/register-form.tsx`
- [Auth actions](https://github.com/21d4n/expense-tracker/blob/main/src/actions/auth.ts): `src/actions/auth.ts`
- [Logout route](https://github.com/21d4n/expense-tracker/blob/main/src/app/(auth)/logout/route.ts): `src/app/(auth)/logout/route.ts`

### Financial overview

- [Dashboard page](https://github.com/21d4n/expense-tracker/blob/main/src/app/dashboard/page.tsx): `src/app/dashboard/page.tsx`
- [Summary cards](https://github.com/21d4n/expense-tracker/blob/main/src/components/dashboard/SummaryCards.tsx): `src/components/dashboard/SummaryCards.tsx`
- [Dashboard filters](https://github.com/21d4n/expense-tracker/blob/main/src/components/dashboard/FilterTabs.tsx): `src/components/dashboard/FilterTabs.tsx`
- [Transaction history](https://github.com/21d4n/expense-tracker/blob/main/src/components/dashboard/TransactionList.tsx): `src/components/dashboard/TransactionList.tsx`

### Transaction management

- [Transaction pages](https://github.com/21d4n/expense-tracker/tree/main/src/app/dashboard/transactions): `src/app/dashboard/transactions`
- [Transaction form](https://github.com/21d4n/expense-tracker/blob/main/src/components/transactions/transaction-form.tsx): `src/components/transactions/transaction-form.tsx`
- [Transaction actions](https://github.com/21d4n/expense-tracker/blob/main/src/actions/transactions.ts): `src/actions/transactions.ts`

### Security and storage

- [Route middleware](https://github.com/21d4n/expense-tracker/blob/main/src/middleware.ts): `src/middleware.ts`
- [Session and auth](https://github.com/21d4n/expense-tracker/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [PostgreSQL database](https://github.com/21d4n/expense-tracker/blob/main/prisma/schema.prisma): `prisma/schema.prisma`
- [Prisma client](https://github.com/21d4n/expense-tracker/blob/main/src/lib/prisma.ts): `src/lib/prisma.ts`

### Other components

- **User**
- **Browser**
- **HttpOnly session cookie**

## Connections

- User → Browser: uses
- Browser → Landing page: opens
- Browser → Login page: opens
- Browser → Registration page: opens
- Login page → Login form: renders
- Registration page → Registration form: renders
- Login form → Auth actions: submits to
- Registration form → Auth actions: submits to
- Auth actions → Prisma client: reads/writes accounts
- Auth actions → Session and auth: hashes; creates session
- Session and auth → Prisma client: reads/writes sessions
- Session and auth → HttpOnly session cookie: sets/reads/deletes
- Browser → Route middleware: requests routes
- Route middleware → HttpOnly session cookie: reads
- Browser → Logout route: requests logout
- Logout route → Session and auth: deletes session
- Dashboard page → Session and auth: requires verified session
- Browser → Dashboard page: opens dashboard
- Dashboard page → Prisma client: queries user transactions
- Prisma client → PostgreSQL database: queries
- Dashboard page → Summary cards: passes totals
- Dashboard page → Dashboard filters: passes active filter
- Dashboard page → Transaction history: passes transaction rows
- Browser → Transaction pages: opens transaction pages
- Transaction pages → Transaction form: renders form
- Transaction form → Transaction actions: submits create/edit
- Transaction actions → Prisma client: manages owned transactions
- Transaction history → Transaction pages: links edit
