# petkov93/finance-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/petkov93/finance-tracker
- Repository: https://github.com/petkov93/finance-tracker

## Overview

1. **Overall shape**
   - This is a single Django monolith with one main app, `financetracker`, plus the project config package `config`.
   - The app is server-rendered: Django views return HTML templates, and static CSS is served through WhiteNoise.

2. **Request entry points**
   - `config/urls.py` routes the site-level paths into the `financetracker` app and likely exposes a lightweight `/health/` endpoint for deployment checks.
   - `financetracker/urls.py` is the app boundary for the user-facing features: dashboard, transactions, statistics, investments, auth pages, and CRUD actions.

3. **Domain model layer**
   - `models.py` defines the core persistence objects:
     - `Category` for income/expense grouping
     - `Transaction` for income and expense entries
     - `InvestmentEntry` for invested/profit tracking
   - Migrations show these are the primary business entities and that the schema evolved to support category typing and investments.

4. **Data ownership boundary**
   - All financial records are scoped per authenticated Django user; the app is explicitly multi-user, but each user only sees their own data.
   - Django’s built-in user model handles registration, login, logout, and session state; there is no separate auth service.

5. **Feature subsystems in the app**
   - **Dashboard** aggregates balance, income, expense totals, and recent transactions.
   - **Transactions** handles add/edit/delete flows for income and expense entries.
   - **Statistics** computes summary metrics and chart-ready datasets over a configurable date range.
   - **Investments** provides a separate list/edit/delete flow for invested vs profit amounts and portfolio value.
   - These are separate UI surfaces, but they all read from the same underlying user-owned financial records.

6. **Form and validation layer**
   - `forms.py` is the interaction boundary for user input.
   - It likely enforces category filtering by transaction type and validates amounts/descriptions before hitting the model layer.
   - This keeps business rules out of the templates and limits what data can reach persistence.

7. **Presentation layer**
   - Templates live under `financetracker/templates/financetracker/` and are organized by page: base layout, dashboard, transactions, statistics, investments, login, register.
   - `base.html` is the shared shell for the dark UI, while page templates render the computed data from views.
   - `style.css` is the only app-specific static asset shown, so the frontend is lightweight and server-driven rather than SPA-based.

8. **Business logic / view layer**
   - `views.py` is the main orchestration layer: it queries models, applies per-user filtering, prepares summaries/charts, and handles form submissions.
   - The views are the place where calculations such as totals, monthly summaries, and category breakdowns are assembled for the templates.

9. **Administration and bootstrap**
   - `admin.py` exposes models in Django admin at `/admin/` for direct management of categories, transactions, and investment entries.
   - `management/commands/seed_categories.py` is a bootstrap command that populates default income/expense categories only when the category table is empty, so startup does not overwrite existing admin data.

10. **Runtime and deployment boundary**
    - `settings.py`, `wsgi.py`, and `manage.py` are standard Django runtime entry points.
    - Production is configured for Gunicorn plus WhiteNoise, with PostgreSQL via a `SUPABASE_URL` environment variable; local development can fall back to SQLite when that variable is absent.
    - Render deployment is implied by the README and the app is designed to run migrations, optionally seed data, collect static files, and then serve the site.

11. **What an architecture diagram should emphasize**
    - A browser talks to Django views.
    - Views use forms and models.
    - Models persist to PostgreSQL/SQLite.
    - Templates render the HTML responses.
    - Static assets are served separately via WhiteNoise.
    - Django auth/session state gates access so each user’s financial data stays isolated.

Main entry points: [`financetracker/views.py`](https://github.com/petkov93/finance-tracker/blob/main/financetracker/views.py) (Views), [`financetracker/models.py`](https://github.com/petkov93/finance-tracker/blob/main/financetracker/models.py) (Models), [`config/urls.py`](https://github.com/petkov93/finance-tracker/blob/main/config/urls.py) (Site URLs), [`config/settings.py`](https://github.com/petkov93/finance-tracker/blob/main/config/settings.py) (Settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_runtime["Runtime"]
  node_manage["Manage<br/>entrypoint<br/>[manage.py]"]
  node_settings["Settings<br/>config<br/>[settings.py]"]
  node_urls_config["Site URLs<br/>router<br/>[urls.py]"]
  node_wsgi["WSGI<br/>runtime<br/>[wsgi.py]"]
end

subgraph group_group_app["App Core"]
  node_views["Views<br/>orchestration<br/>[views.py]"]
  node_urls_app["App URLs<br/>router<br/>[urls.py]"]
  node_forms["Forms<br/>validation<br/>[forms.py]"]
  node_models[("Models<br/>domain<br/>[models.py]")]
  node_migrations["Migrations<br/>schema<br/>[0001_initial.py]"]
  node_admin["Admin<br/>management<br/>[admin.py]"]
  node_seed["Seed Cmd<br/>bootstrap<br/>[seed_categories.py]"]
end

subgraph group_group_ui["UI"]
  node_dashboard_tpl["Dashboard UI<br/>template<br/>[dashboard.html]"]
  node_trans_tpl["Transaction UI<br/>template"]
  node_stats_tpl["Statistics UI<br/>template<br/>[statistics.html]"]
  node_invest_tpl["Investments UI<br/>template<br/>[investments.html]"]
  node_base_tpl["Base Layout<br/>template shell<br/>[base.html]"]
  node_style["Styles<br/>static css<br/>[style.css]"]
end

node_browser(("Browser<br/>client"))
node_auth(("Auth<br/>session"))

node_browser -->|"HTTP"| node_urls_config
node_urls_config -->|"route"| node_urls_app
node_urls_config -.->|"auth paths"| node_auth
node_urls_config -->|"health/site"| node_views
node_urls_app -->|"dispatch"| node_views
node_views -->|"validate"| node_forms
node_forms -->|"clean data"| node_models
node_views -->|"query/write"| node_models
node_models -.->|"evolve schema"| node_migrations
node_views -->|"render"| node_dashboard_tpl
node_views -->|"render"| node_trans_tpl
node_views -->|"render"| node_stats_tpl
node_views -->|"render"| node_invest_tpl
node_dashboard_tpl -.->|"extend"| node_base_tpl
node_trans_tpl -.->|"extend"| node_base_tpl
node_stats_tpl -.->|"extend"| node_base_tpl
node_invest_tpl -.->|"extend"| node_base_tpl
node_settings -.->|"DB config"| node_models
node_settings -.->|"static files"| node_style
node_manage -->|"boot"| node_settings
node_wsgi -->|"serve"| node_settings
node_admin -->|"manage"| node_models
node_seed -->|"seed"| node_models
node_auth -.->|"gate access"| node_views

click node_manage "https://github.com/petkov93/finance-tracker/blob/main/manage.py"
click node_settings "https://github.com/petkov93/finance-tracker/blob/main/config/settings.py"
click node_urls_config "https://github.com/petkov93/finance-tracker/blob/main/config/urls.py"
click node_wsgi "https://github.com/petkov93/finance-tracker/blob/main/config/wsgi.py"
click node_views "https://github.com/petkov93/finance-tracker/blob/main/financetracker/views.py"
click node_urls_app "https://github.com/petkov93/finance-tracker/blob/main/financetracker/urls.py"
click node_forms "https://github.com/petkov93/finance-tracker/blob/main/financetracker/forms.py"
click node_models "https://github.com/petkov93/finance-tracker/blob/main/financetracker/models.py"
click node_migrations "https://github.com/petkov93/finance-tracker/blob/main/financetracker/migrations/0001_initial.py"
click node_admin "https://github.com/petkov93/finance-tracker/blob/main/financetracker/admin.py"
click node_seed "https://github.com/petkov93/finance-tracker/blob/main/financetracker/management/commands/seed_categories.py"
click node_dashboard_tpl "https://github.com/petkov93/finance-tracker/blob/main/financetracker/templates/financetracker/dashboard.html"
click node_trans_tpl "https://github.com/petkov93/finance-tracker/blob/main/financetracker/templates/financetracker/add_transaction.html"
click node_stats_tpl "https://github.com/petkov93/finance-tracker/blob/main/financetracker/templates/financetracker/statistics.html"
click node_invest_tpl "https://github.com/petkov93/finance-tracker/blob/main/financetracker/templates/financetracker/investments.html"
click node_base_tpl "https://github.com/petkov93/finance-tracker/blob/main/financetracker/templates/financetracker/base.html"
click node_style "https://github.com/petkov93/finance-tracker/blob/main/financetracker/static/financetracker/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_manage,node_settings,node_urls_config,node_wsgi toneBlue
class node_views,node_urls_app,node_forms,node_models,node_migrations,node_admin,node_seed toneAmber
class node_dashboard_tpl,node_trans_tpl,node_stats_tpl,node_invest_tpl,node_base_tpl,node_style toneMint
class node_browser,node_auth toneNeutral
```

## Components

### Runtime

Django project bootstrap and deployment entry points

- [Manage](https://github.com/petkov93/finance-tracker/blob/main/manage.py): entrypoint · Django CLI entrypoint · `manage.py`
- [Settings](https://github.com/petkov93/finance-tracker/blob/main/config/settings.py): config · Project configuration, database, auth, static files · `config/settings.py`
- [Site URLs](https://github.com/petkov93/finance-tracker/blob/main/config/urls.py): router · Project-level URL routing and health check · `config/urls.py`
- [WSGI](https://github.com/petkov93/finance-tracker/blob/main/config/wsgi.py): runtime · Production application entrypoint · `config/wsgi.py`

### App Core

Domain, forms, views, admin, and background commands

- [Views](https://github.com/petkov93/finance-tracker/blob/main/financetracker/views.py): orchestration · Request handling, per-user filtering, summaries, and form submission · `financetracker/views.py`
- [App URLs](https://github.com/petkov93/finance-tracker/blob/main/financetracker/urls.py): router · Feature routes for dashboard, transactions, statistics, and investments · `financetracker/urls.py`
- [Forms](https://github.com/petkov93/finance-tracker/blob/main/financetracker/forms.py): validation · User input validation and category filtering · `financetracker/forms.py`
- [Models](https://github.com/petkov93/finance-tracker/blob/main/financetracker/models.py): domain · Category, Transaction, and InvestmentEntry persistence models · `financetracker/models.py`
- [Migrations](https://github.com/petkov93/finance-tracker/blob/main/financetracker/migrations/0001_initial.py): schema · Database schema evolution for categories and investments · `financetracker/migrations/0001_initial.py`
- [Admin](https://github.com/petkov93/finance-tracker/blob/main/financetracker/admin.py): management · Django admin registrations for direct data management · `financetracker/admin.py`
- [Seed Cmd](https://github.com/petkov93/finance-tracker/blob/main/financetracker/management/commands/seed_categories.py): bootstrap · Populates default categories when none exist · `financetracker/management/commands/seed_categories.py`

### UI

Templates and static assets for server-rendered pages

- [Dashboard UI](https://github.com/petkov93/finance-tracker/blob/main/financetracker/templates/financetracker/dashboard.html): template · Dashboard page and shared shell · `financetracker/templates/financetracker/dashboard.html`
- [Transaction UI](https://github.com/petkov93/finance-tracker/blob/main/financetracker/templates/financetracker/add_transaction.html): template · Transaction create/edit/delete pages · `financetracker/templates/financetracker/add_transaction.html`
- [Statistics UI](https://github.com/petkov93/finance-tracker/blob/main/financetracker/templates/financetracker/statistics.html): template · Summary and chart pages · `financetracker/templates/financetracker/statistics.html`
- [Investments UI](https://github.com/petkov93/finance-tracker/blob/main/financetracker/templates/financetracker/investments.html): template · Investment list and edit pages · `financetracker/templates/financetracker/investments.html`
- [Base Layout](https://github.com/petkov93/finance-tracker/blob/main/financetracker/templates/financetracker/base.html): template shell · Shared HTML layout for the app · `financetracker/templates/financetracker/base.html`
- [Styles](https://github.com/petkov93/finance-tracker/blob/main/financetracker/static/financetracker/css/style.css): static css · App-specific server-served styling · `financetracker/static/financetracker/css/style.css`

### Other components

- **Browser**: client · User requests and form submissions
- **Auth**: session · Django users, login, logout, and session state

## Connections

- Browser → Site URLs: HTTP · Browser requests enter the project router
- Site URLs → App URLs: route · Site paths are delegated to the app router
- Site URLs → Auth: auth paths · Login and logout rely on Django auth/session state
- Site URLs → Views: health/site · Project routes reach view handlers
- App URLs → Views: dispatch · Feature routes map to view functions
- Views → Forms: validate · Views bind and validate user submissions
- Forms → Models: clean data · Validated inputs are shaped for persistence
- Views → Models: query/write · Views read and write user-owned financial records
- Models → Migrations: evolve schema · Migrations define the database structure
- Views → Dashboard UI: render · Dashboard data is rendered into HTML
- Views → Transaction UI: render · Transaction flows render page templates
- Views → Statistics UI: render · Statistics summaries render page templates
- Views → Investments UI: render · Investment flows render page templates
- Dashboard UI → Base Layout: extend · Page templates share the base layout
- Transaction UI → Base Layout: extend · Page templates share the base layout
- Statistics UI → Base Layout: extend · Page templates share the base layout
- Investments UI → Base Layout: extend · Page templates share the base layout
- Settings → Models: DB config · Settings choose SQLite or PostgreSQL-backed persistence
- Settings → Styles: static files · WhiteNoise serves static assets
- Manage → Settings: boot · CLI startup loads project settings
- WSGI → Settings: serve · Production server boots through WSGI config
- Admin → Models: manage · Admin exposes core domain objects
- Seed Cmd → Models: seed · Bootstrap command creates default categories
- Auth → Views: gate access · Authenticated users are required for personal data access
