# ibrahim-2005/money-tracker-api architecture

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

- Interactive diagram: https://gitdiagram.com/ibrahim-2005/money-tracker-api
- Repository: https://github.com/ibrahim-2005/money-tracker-api

## Overview

1. **Overall shape**
   - This is a small, monolithic Flask application with server-rendered pages. `app.py` is the central composition point: it wires routes, authentication, database access, and page rendering together.
   - The repo is split into three main runtime areas: Flask backend logic, Jinja2 HTML templates, and static CSS.

2. **Request/response architecture**
   - Browser requests hit Flask routes in `app.py`.
   - Route handlers validate input, read/write SQLite data, update session state, and render a template response.
   - There is no separate API client or SPA layer; the browser consumes server-rendered pages directly.

3. **Authentication boundary**
   - Authentication is session-based, with login, registration, and logout flows.
   - Passwords are hashed with Werkzeug, so plaintext credentials are never stored.
   - Protected routes depend on session state, creating a clear trust boundary between anonymous and authenticated access.

4. **User isolation**
   - The system is multi-user, and all financial data is scoped by `user_id`.
   - Categories and transactions are filtered per logged-in user, so each user only sees their own records.
   - This isolation is a core architectural constraint and affects every data-access route.

5. **Financial domain subsystems**
   - The app tracks two main domain entities: **categories** and **transactions**.
   - Transactions represent income or expense entries with amount, type, category, and date.
   - Categories are user-defined and linked to transactions through foreign keys, which keeps the data normalized and queryable.

6. **Analytics/dashboard flow**
   - The dashboard is computed from stored transaction data, not from a separate analytics service.
   - Totals such as income, expenses, and net balance are derived through aggregate queries in the backend and then injected into the rendered page.
   - This keeps reporting close to the source of truth in SQLite.

7. **Template/view layer**
   - `templates/base.html` is the shared layout, and the other templates extend it for individual screens.
   - `index.html`, `login.html`, `register.html`, `categories.html`, and `result.html` indicate a traditional multi-page flow with distinct views for overview, auth, category management, and transaction results.
   - Jinja2 handles server-side rendering and data binding.

8. **Static presentation layer**
   - `static/css/style.css` provides the application styling.
   - There are no other front-end assets in the tree, which suggests the UI is intentionally lightweight and mostly server-driven.

9. **Persistence layer**
   - SQLite is the backing store, which matches the README’s normalized relational design.
   - The database schema centers on users, categories, and transactions, with foreign keys enforcing consistency.
   - The repo does not show a separate ORM package in the tree, so persistence is likely handled directly in `app.py` or with minimal abstraction.

10. **Validation and error handling**
   - Input validation and fallback handling are part of the backend contract, especially around amounts, dates, and session expiry.
   - Because the app is backend-first, invalid state is handled before rendering, reducing the chance of leaking bad data into the UI.

11. **Deployment/runtime**
   - The README indicates deployment with Gunicorn on Render.
   - In production, Flask runs as a WSGI app behind Gunicorn, while environment variables provide configuration.
   - This means the app is designed to separate local development execution from production serving, even though the repo is compact.

12. **Architecture takeaway**
   - The key diagram should show a single Flask application at the center, with three connected layers: browser-facing Jinja templates, static CSS, and SQLite persistence.
   - Around that core are two cross-cutting concerns: session authentication and per-user data isolation.
   - The result is a small but complete full-stack CRUD system with server-side rendering and relational data boundaries.

Main entry points: [`app.py`](https://github.com/ibrahim-2005/money-tracker-api/blob/main/app.py) (Flask app), [`templates/categories.html`](https://github.com/ibrahim-2005/money-tracker-api/blob/main/templates/categories.html) (Categories), [`templates/base.html`](https://github.com/ibrahim-2005/money-tracker-api/blob/main/templates/base.html) (Base layout), [`templates/index.html`](https://github.com/ibrahim-2005/money-tracker-api/blob/main/templates/index.html) (Home page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Backend"]
  node_app["Flask app<br/>web app<br/>[app.py]"]
  node_auth(("Session auth<br/>auth flow"))
  node_userscope{{"User scope<br/>boundary"}}
  node_dashboard["Dashboard<br/>reporting"]
  node_categories["Categories<br/>domain CRUD<br/>[categories.html]"]
  node_transactions["Transactions<br/>domain CRUD"]
  node_db[("SQLite<br/>relational store")]
end

subgraph group_views["Templates"]
  node_render["Jinja2 render<br/>view layer"]
  node_base["Base layout<br/>template<br/>[base.html]"]
  node_home["Home page<br/>template<br/>[index.html]"]
  node_loginpage["Login page<br/>template<br/>[login.html]"]
  node_registerpage["Register page<br/>template<br/>[register.html]"]
  node_resultpage["Result page<br/>template<br/>[result.html]"]
end

subgraph group_assets["Static"]
  node_style["Stylesheet<br/>css<br/>[style.css]"]
end

subgraph group_runtime["Runtime"]
  node_deploy["WSGI deploy<br/>production runtime"]
end

node_deploy -->|"serves"| node_app
node_app -->|"uses"| node_auth
node_app -->|"filters by"| node_userscope
node_app -->|"computes"| node_dashboard
node_app -->|"manages"| node_categories
node_app -->|"manages"| node_transactions
node_app -->|"renders"| node_render
node_render -->|"extends"| node_base
node_render -->|"renders"| node_home
node_render -->|"renders"| node_loginpage
node_render -->|"renders"| node_registerpage
node_render -->|"renders"| node_categories
node_render -->|"renders"| node_resultpage
node_app -->|"reads/writes"| node_db
node_app -->|"serves"| node_style
node_dashboard -->|"aggregates from"| node_db
node_transactions -->|"persists to"| node_db
node_categories -->|"persists to"| node_db

click node_app "https://github.com/ibrahim-2005/money-tracker-api/blob/main/app.py"
click node_categories "https://github.com/ibrahim-2005/money-tracker-api/blob/main/templates/categories.html"
click node_base "https://github.com/ibrahim-2005/money-tracker-api/blob/main/templates/base.html"
click node_home "https://github.com/ibrahim-2005/money-tracker-api/blob/main/templates/index.html"
click node_loginpage "https://github.com/ibrahim-2005/money-tracker-api/blob/main/templates/login.html"
click node_registerpage "https://github.com/ibrahim-2005/money-tracker-api/blob/main/templates/register.html"
click node_resultpage "https://github.com/ibrahim-2005/money-tracker-api/blob/main/templates/result.html"
click node_style "https://github.com/ibrahim-2005/money-tracker-api/blob/main/static/css/style.css"

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_auth,node_userscope,node_dashboard,node_categories,node_transactions,node_db toneBlue
class node_render,node_base,node_home,node_loginpage,node_registerpage,node_resultpage toneAmber
class node_style toneMint
class node_deploy toneRose
```

## Components

### Backend

Flask app and persistence logic

- [Flask app](https://github.com/ibrahim-2005/money-tracker-api/blob/main/app.py): web app · Central Flask composition point for routes, auth, validation, and rendering · `app.py`
- **Session auth**: auth flow · Login, registration, logout, and protected-route session checks
- **User scope**: boundary · Per-user filtering and ownership checks via user_id
- **Dashboard**: reporting · Computes balances and summaries from stored transactions
- [Categories](https://github.com/ibrahim-2005/money-tracker-api/blob/main/templates/categories.html): domain CRUD · User-defined category management and lookup · `templates/categories.html`
- **Transactions**: domain CRUD · Income and expense records with amount, type, category, and date
- **SQLite**: relational store · Persistent storage for users, categories, and transactions

### Templates

Server-rendered pages

- **Jinja2 render**: view layer · Server-side template rendering and data binding
- [Base layout](https://github.com/ibrahim-2005/money-tracker-api/blob/main/templates/base.html): template · Shared HTML shell extended by other pages · `templates/base.html`
- [Home page](https://github.com/ibrahim-2005/money-tracker-api/blob/main/templates/index.html): template · Main overview screen · `templates/index.html`
- [Login page](https://github.com/ibrahim-2005/money-tracker-api/blob/main/templates/login.html): template · Authentication form screen · `templates/login.html`
- [Register page](https://github.com/ibrahim-2005/money-tracker-api/blob/main/templates/register.html): template · Account creation screen · `templates/register.html`
- [Result page](https://github.com/ibrahim-2005/money-tracker-api/blob/main/templates/result.html): template · Post-action feedback or transaction result screen · `templates/result.html`

### Static

Presentation assets

- [Stylesheet](https://github.com/ibrahim-2005/money-tracker-api/blob/main/static/css/style.css): css · Application-wide visual styling · `static/css/style.css`

### Runtime

Deployment and serving

- **WSGI deploy**: production runtime · Gunicorn-served Flask app in production

## Connections

- WSGI deploy → Flask app: serves · Production WSGI server runs the Flask application
- Flask app → Session auth: uses · Route handlers enforce session-based access
- Flask app → User scope: filters by · All data access is scoped to the logged-in user
- Flask app → Dashboard: computes · Dashboard metrics are aggregated in the backend
- Flask app → Categories: manages · Category routes create, read, update, and delete user categories
- Flask app → Transactions: manages · Transaction routes record financial entries
- Flask app → Jinja2 render: renders · Flask handlers return Jinja2 pages
- Jinja2 render → Base layout: extends · Shared layout underpins all pages
- Jinja2 render → Home page: renders · Overview page is rendered server-side
- Jinja2 render → Login page: renders · Login view is server-rendered
- Jinja2 render → Register page: renders · Registration view is server-rendered
- Jinja2 render → Categories: renders · Category management page is server-rendered
- Jinja2 render → Result page: renders · Result or confirmation page is server-rendered
- Flask app → SQLite: reads/writes · SQLite persistence is accessed directly or with minimal abstraction
- Flask app → Stylesheet: serves · Static CSS supports the rendered pages
- Dashboard → SQLite: aggregates from · Summary totals are derived from stored transactions
- Transactions → SQLite: persists to · Transaction records are stored in SQLite
- Categories → SQLite: persists to · Category records are stored in SQLite
