# anasattoum/safe-spend architecture

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

- Interactive diagram: https://gitdiagram.com/anasattoum/safe-spend
- Repository: https://github.com/anasattoum/safe-spend

## Overview

Safe Spend is a personal-finance web application: users manage transactions and categories, review balances and spending analytics, and consult currency-exchange and gold-price information. The graph shows those product areas and the sampled server-side data path through API handlers, domain actions, and Prisma. The README documents major capabilities that the excerpts do not trace to their data providers; those areas are included without guessed integration edges.

Main entry points: [`src/sections/dashboard/index.tsx`](https://github.com/anasattoum/safe-spend/blob/main/src/sections/dashboard/index.tsx) (Dashboard), [`src/actions/user.ts`](https://github.com/anasattoum/safe-spend/blob/main/src/actions/user.ts) (User and session), [`src/lib/prisma.ts`](https://github.com/anasattoum/safe-spend/blob/main/src/lib/prisma.ts) (Application database), [`src/lib/get-history.ts`](https://github.com/anasattoum/safe-spend/blob/main/src/lib/get-history.ts) (History calculations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_auth["Account access<br/>[page.tsx]"]
  node_dashboard["Dashboard<br/>[index.tsx]"]
end

subgraph group_finance["Finance workflows"]
  node_transactions["Transactions<br/>[index.tsx]"]
  node_transaction_actions["Transaction actions<br/>[transaction.ts]"]
  node_categories["Categories<br/>[index.tsx]"]
  node_category_actions["Category actions<br/>[category.ts]"]
  node_exchanges["Currency exchanges<br/>[index.tsx]"]
  node_exchange_actions["Exchange actions<br/>[exchange.ts]"]
  node_currency["Currency tools<br/>[index.tsx]"]
end

subgraph group_insights["Financial insights"]
  node_history_logic["History calculations<br/>[get-history.ts]"]
  node_balance_logic["Balance calculations"]
  node_market["Market information<br/>[index.tsx]"]
  node_syp["SYP rates<br/>[index.tsx]"]
end

subgraph group_server["Server and persistence"]
  node_history_api["History API<br/>[route.ts]"]
  node_transaction_api["Transaction API<br/>[route.ts]"]
  node_exchange_api["Exchange API<br/>[route.ts]"]
  node_statistics["Statistics APIs<br/>[route.ts]"]
  node_user_actions["User and session<br/>[user.ts]"]
  node_database[("Application database<br/>[prisma.ts]")]
end

node_user(("Finance user"))

node_user -->|"signs in"| node_auth
node_user -->|"manages finances"| node_dashboard
node_dashboard -->|"opens"| node_transactions
node_dashboard -->|"opens"| node_categories
node_dashboard -.->|"opens"| node_exchanges
node_dashboard -->|"uses"| node_transaction_actions
node_dashboard -->|"renders"| node_categories
node_transactions -.->|"manages"| node_transaction_actions
node_categories -.->|"manages"| node_category_actions
node_exchanges -.->|"manages"| node_exchange_actions
node_exchange_actions -->|"writes exchanges"| node_database
node_transaction_api -->|"authenticates"| node_user_actions
node_transaction_api -->|"reads transactions"| node_database
node_exchange_api -->|"authenticates"| node_user_actions
node_exchange_api -->|"reads exchanges"| node_database
node_history_api -->|"authenticates"| node_user_actions
node_history_api -->|"requests history"| node_history_logic
node_statistics -->|"authenticates"| node_user_actions
node_statistics -->|"requests balances"| node_history_logic
node_history_logic -->|"queries data"| node_database
node_history_logic -->|"uses calculations"| node_balance_logic
node_user_actions -->|"reads and writes"| node_database
node_user -->|"converts currencies"| node_currency
node_user -->|"checks gold prices"| node_market
node_user -->|"checks exchange rates"| node_syp

click node_auth "https://github.com/anasattoum/safe-spend/blob/main/src/app/%5Blocale%5D/(auth)/sign-in/page.tsx"
click node_dashboard "https://github.com/anasattoum/safe-spend/blob/main/src/sections/dashboard/index.tsx"
click node_transactions "https://github.com/anasattoum/safe-spend/blob/main/src/sections/transactions/index.tsx"
click node_transaction_actions "https://github.com/anasattoum/safe-spend/blob/main/src/actions/transaction.ts"
click node_categories "https://github.com/anasattoum/safe-spend/blob/main/src/sections/categories/index.tsx"
click node_category_actions "https://github.com/anasattoum/safe-spend/blob/main/src/actions/category.ts"
click node_exchanges "https://github.com/anasattoum/safe-spend/blob/main/src/sections/exchanges/index.tsx"
click node_exchange_actions "https://github.com/anasattoum/safe-spend/blob/main/src/actions/exchange.ts"
click node_currency "https://github.com/anasattoum/safe-spend/blob/main/src/sections/currency/index.tsx"
click node_history_api "https://github.com/anasattoum/safe-spend/blob/main/src/app/api/history/data/route.ts"
click node_history_logic "https://github.com/anasattoum/safe-spend/blob/main/src/lib/get-history.ts"
click node_transaction_api "https://github.com/anasattoum/safe-spend/blob/main/src/app/api/transactions/route.ts"
click node_exchange_api "https://github.com/anasattoum/safe-spend/blob/main/src/app/api/exchanges/route.ts"
click node_statistics "https://github.com/anasattoum/safe-spend/blob/main/src/app/api/statistics/total/route.ts"
click node_balance_logic "https://github.com/anasattoum/safe-spend/blob/main/src/lib/get-balance-stats.tsx"
click node_market "https://github.com/anasattoum/safe-spend/blob/main/src/sections/gold-today/index.tsx"
click node_syp "https://github.com/anasattoum/safe-spend/blob/main/src/sections/syrian-pound-today/index.tsx"
click node_user_actions "https://github.com/anasattoum/safe-spend/blob/main/src/actions/user.ts"
click node_database "https://github.com/anasattoum/safe-spend/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_auth,node_dashboard,node_user toneBlue
class node_transactions,node_transaction_actions,node_categories,node_category_actions,node_exchanges,node_exchange_actions,node_currency toneAmber
class node_history_logic,node_balance_logic,node_market,node_syp toneMint
class node_history_api,node_transaction_api,node_exchange_api,node_statistics,node_user_actions,node_database toneRose
```

## Components

### User experience

- [Account access](https://github.com/anasattoum/safe-spend/blob/main/src/app/%5Blocale%5D/(auth)/sign-in/page.tsx): `src/app/[locale]/(auth)/sign-in/page.tsx`
- [Dashboard](https://github.com/anasattoum/safe-spend/blob/main/src/sections/dashboard/index.tsx): `src/sections/dashboard/index.tsx`

### Finance workflows

- [Transactions](https://github.com/anasattoum/safe-spend/blob/main/src/sections/transactions/index.tsx): `src/sections/transactions/index.tsx`
- [Transaction actions](https://github.com/anasattoum/safe-spend/blob/main/src/actions/transaction.ts): `src/actions/transaction.ts`
- [Categories](https://github.com/anasattoum/safe-spend/blob/main/src/sections/categories/index.tsx): `src/sections/categories/index.tsx`
- [Category actions](https://github.com/anasattoum/safe-spend/blob/main/src/actions/category.ts): `src/actions/category.ts`
- [Currency exchanges](https://github.com/anasattoum/safe-spend/blob/main/src/sections/exchanges/index.tsx): `src/sections/exchanges/index.tsx`
- [Exchange actions](https://github.com/anasattoum/safe-spend/blob/main/src/actions/exchange.ts): `src/actions/exchange.ts`
- [Currency tools](https://github.com/anasattoum/safe-spend/blob/main/src/sections/currency/index.tsx): `src/sections/currency/index.tsx`

### Financial insights

- [History calculations](https://github.com/anasattoum/safe-spend/blob/main/src/lib/get-history.ts): `src/lib/get-history.ts`
- [Balance calculations](https://github.com/anasattoum/safe-spend/blob/main/src/lib/get-balance-stats.tsx): `src/lib/get-balance-stats.tsx`
- [Market information](https://github.com/anasattoum/safe-spend/blob/main/src/sections/gold-today/index.tsx): `src/sections/gold-today/index.tsx`
- [SYP rates](https://github.com/anasattoum/safe-spend/blob/main/src/sections/syrian-pound-today/index.tsx): `src/sections/syrian-pound-today/index.tsx`

### Server and persistence

- [History API](https://github.com/anasattoum/safe-spend/blob/main/src/app/api/history/data/route.ts): `src/app/api/history/data/route.ts`
- [Transaction API](https://github.com/anasattoum/safe-spend/blob/main/src/app/api/transactions/route.ts): `src/app/api/transactions/route.ts`
- [Exchange API](https://github.com/anasattoum/safe-spend/blob/main/src/app/api/exchanges/route.ts): `src/app/api/exchanges/route.ts`
- [Statistics APIs](https://github.com/anasattoum/safe-spend/blob/main/src/app/api/statistics/total/route.ts): `src/app/api/statistics/total/route.ts`
- [User and session](https://github.com/anasattoum/safe-spend/blob/main/src/actions/user.ts): `src/actions/user.ts`
- [Application database](https://github.com/anasattoum/safe-spend/blob/main/src/lib/prisma.ts): `src/lib/prisma.ts`

### Other components

- **Finance user**

## Connections

- Finance user → Account access: signs in (evidence: `README.md`)
- Finance user → Dashboard: manages finances (evidence: `README.md`)
- Dashboard → Transactions: opens (evidence: `src/sections/dashboard/index.tsx`)
- Dashboard → Categories: opens (evidence: `src/sections/dashboard/index.tsx`)
- Dashboard → Currency exchanges: opens
- Dashboard → Transaction actions: uses (evidence: `src/sections/dashboard/index.tsx`)
- Dashboard → Categories: renders (evidence: `src/sections/dashboard/index.tsx`)
- Transactions → Transaction actions: manages
- Categories → Category actions: manages
- Currency exchanges → Exchange actions: manages
- Exchange actions → Application database: writes exchanges (evidence: `src/actions/exchange.ts`)
- Transaction API → User and session: authenticates (evidence: `src/app/api/transactions/route.ts`)
- Transaction API → Application database: reads transactions (evidence: `src/app/api/transactions/route.ts`)
- Exchange API → User and session: authenticates (evidence: `src/app/api/exchanges/route.ts`)
- Exchange API → Application database: reads exchanges (evidence: `src/app/api/exchanges/route.ts`)
- History API → User and session: authenticates (evidence: `src/app/api/history/data/route.ts`)
- History API → History calculations: requests history (evidence: `src/app/api/history/data/route.ts`)
- Statistics APIs → User and session: authenticates (evidence: `src/app/api/statistics/total/route.ts`)
- Statistics APIs → History calculations: requests balances (evidence: `src/app/api/statistics/total/route.ts`)
- History calculations → Application database: queries data (evidence: `src/lib/get-history.ts`)
- History calculations → Balance calculations: uses calculations (evidence: `src/lib/get-history.ts`)
- User and session → Application database: reads and writes (evidence: `src/actions/user.ts`)
- Finance user → Currency tools: converts currencies (evidence: `README.md`)
- Finance user → Market information: checks gold prices (evidence: `README.md`)
- Finance user → SYP rates: checks exchange rates (evidence: `README.md`)
