How ibrahim-2005/money-tracker-api works
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 Flask app · categories.html Categories · base.html Base layout · index.html Home page
Components 15
Backend
Flask app and persistence logic
- Flask app · Central Flask composition point for routes, auth, validation, and rendering
app.py - Session auth · Login, registration, logout, and protected-route session checks
- User scope · Per-user filtering and ownership checks via user_id
- Dashboard · Computes balances and summaries from stored transactions
- Categories · User-defined category management and lookup
templates/categories.html - Transactions · Income and expense records with amount, type, category, and date
- SQLite · Persistent storage for users, categories, and transactions
Templates
Server-rendered pages
- Jinja2 render · Server-side template rendering and data binding
- Base layout · Shared HTML shell extended by other pages
templates/base.html - Home page · Main overview screen
templates/index.html - Login page · Authentication form screen
templates/login.html - Register page · Account creation screen
templates/register.html - Result page · Post-action feedback or transaction result screen
templates/result.html
Runtime
Deployment and serving
- WSGI deploy · Gunicorn-served Flask app in production
Connections 18
- 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