# ayoubbencheikhi/income-expense-website architecture

> Architecture diagram of the GitHub repository ayoubbencheikhi/income-expense-website, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ayoubbencheikhi/income-expense-website
- Repository: https://github.com/ayoubbencheikhi/income-expense-website

## Overview

##### Project Type and Purpose
- This is a monolithic full-stack web application built on Django, named “income-expense-website.”
- Its primary purpose is to let users register/login, track incomes and expenses, and manage user preferences.
- It bundles three Django apps—authentication, expenses, and userpreferences—under a single project.

##### File Structure Analysis
- Top-level files: .env (environment variables), Pipfile/Pipfile.lock (dependencies via Pipenv), Procfile (Heroku deploy).
- Project root app folder: expenseswebsite/ contains Django settings, URL routing, ASGI/WSGI entry points, and static assets.
- Apps:
- authentication/: user account management, login, registration, password resets.
- expenses/: expense/income models, CRUD views and templates.
- userpreferences/: per-user settings (e.g. currency).
- templates/: global and per-app HTML templates, partials for messages and sidebar.
- static/: CSS and JavaScript for client-side interactivity (dashboard, search, register flows).
- db.sqlite3: development database. In production likely replaced by Postgres or MySQL.

##### README Insights
- Very minimal; reinforces the project’s identity as an income/expense tracking website.

a. Main Components
- Web Client (browser)
- Django Web Server
− URL dispatcher (project-level urls.py)
− Authentication app
− Expenses app
− UserPreferences app
- Static File Handler (serving CSS/JS)
- Database (SQLite in dev, replaceable with RDBMS)
- External Services (e.g., Email SMTP for password resets)
- Currencies JSON (as a data resource)
b. Relationships and Interactions
- Browser sends HTTP/HTTPS requests to Django via WSGI/ASGI.
- Django routes requests to the correct app based on URL config.
- Views in each app interact with models and the database.
- Templates are rendered with context data and returned to the client.
- Static files served either by Django’s static handler or CDN in production.
- Password-reset flows trigger email service calls.
c. Architectural Patterns and Principles
- Monolithic MVC (Models in models.py, Views in views.py, Templates as the V layer).
- Apps are cohesive modules: authentication, expense tracking, preferences.
- Separation of concerns: routing, business logic, persistence, and presentation are distinct.
d. Key Technologies and Frameworks
- Python 3 + Django framework
- SQLite (dev) / Postgres or MySQL (prod)
- Pipenv for dependency management
- HTML5, CSS3, vanilla JavaScript
- Heroku deployment via Procfile or similar PaaS

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        WebClient["Web Client (Browser)"]:::frontend
        StaticHandler["Static File Handler"]:::frontend
        WebClient -->|"HTTP/HTTPS"| DjangoServer
        WebClient -->|"HTTP/HTTPS"| StaticHandler
    end

    %% Application Layer
    subgraph "Application Layer (Django Monolith)" 
        direction TB
        DjangoServer["Django Web Server"]:::backend

        subgraph "Project Configuration"
            direction TB
            Settings["settings.py"]:::file
            URLsConfig["urls.py"]:::file
            ASGI["asgi.py"]:::file
            WSGI["wsgi.py"]:::file
        end

        subgraph "Authentication App"
            direction TB
            AuthDir["authentication/"]:::backend
            AuthURLs["authentication/urls.py"]:::file
            AuthViews["authentication/views.py"]:::file
            AuthModels["authentication/models.py"]:::file
            AuthUtils["authentication/utils.py"]:::file
            AuthTemplates["templates/authentication/*.html"]:::file
        end

        subgraph "Expenses App"
            direction TB
            ExpDir["expenses/"]:::backend
            ExpURLs["expenses/urls.py"]:::file
            ExpViews["expenses/views.py"]:::file
            ExpModels["expenses/models.py"]:::file
            ExpTemplates["templates/expenses/*.html"]:::file
        end

        subgraph "UserPreferences App"
            direction TB
            PrefDir["userpreferences/"]:::backend
            PrefURLs["userpreferences/urls.py"]:::file
            PrefViews["userpreferences/views.py"]:::file
            PrefModels["userpreferences/models.py"]:::file
            PrefTemplates["templates/preferences/index.html"]:::file
        end

        DjangoServer -->|routes via urls.py| Settings
        DjangoServer --> Settings
        Settings --> URLsConfig
        Settings --> ASGI
        Settings --> WSGI

        DjangoServer --> AuthDir
        AuthDir --> AuthURLs
        AuthDir --> AuthViews
        AuthDir --> AuthModels
        AuthDir --> AuthUtils
        AuthDir --> AuthTemplates

        DjangoServer --> ExpDir
        ExpDir --> ExpURLs
        ExpDir --> ExpViews
        ExpDir --> ExpModels
        ExpDir --> ExpTemplates

        DjangoServer --> PrefDir
        PrefDir --> PrefURLs
        PrefDir --> PrefViews
        PrefDir --> PrefModels
        PrefDir --> PrefTemplates
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Database[(db.sqlite3)]:::database
        Currencies["currencies.json"]:::file
    end

    DjangoServer -->|"SQL/ORM queries"| Database
    PrefDir -->|"reads"| Currencies

    %% External Services
    subgraph "External Services"
        direction TB
        EmailService((Email SMTP Service)):::external
    end
    DjangoServer -->|"SMTP"| EmailService

    %% Static Files
    subgraph "Static Assets"
        direction TB
        StaticCSS["expenseswebsite/static/css/"]:::file
        StaticJS["expenseswebsite/static/js/"]:::file
    end
    StaticHandler --> StaticCSS
    StaticHandler --> StaticJS

    %% Global Templates
    subgraph "Global Templates"
        direction TB
        BaseHTML["templates/base.html"]:::file
        BaseAuth["templates/base_auth.html"]:::file
        IndexHTML["templates/index.html"]:::file
        PartialsMsgs["templates/partials/_messages.html"]:::file
        PartialsSidebar["templates/partials/_sidebar.html"]:::file
    end
    DjangoServer --> BaseHTML
    DjangoServer --> BaseAuth
    DjangoServer --> IndexHTML
    DjangoServer --> PartialsMsgs
    DjangoServer --> PartialsSidebar

    %% Env & Deployment
    subgraph "Environment & Deployment"
        direction TB
        EnvFile[".env"]:::config
        Pipfile["Pipfile"]:::config
        PipfileLock["Pipfile.lock"]:::config
        Procfile["Procfile"]:::config
    end

    %% Click Events
    click Settings "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/expenseswebsite/settings.py"
    click URLsConfig "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/expenseswebsite/urls.py"
    click ASGI "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/expenseswebsite/asgi.py"
    click WSGI "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/expenseswebsite/wsgi.py"
    click AuthDir "https://github.com/ayoubbencheikhi/income-expense-website/tree/main/authentication/"
    click AuthURLs "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/authentication/urls.py"
    click AuthViews "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/authentication/views.py"
    click AuthModels "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/authentication/models.py"
    click AuthUtils "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/authentication/utils.py"
    click AuthTemplates "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/templates/authentication/*.html"
    click ExpDir "https://github.com/ayoubbencheikhi/income-expense-website/tree/main/expenses/"
    click ExpURLs "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/expenses/urls.py"
    click ExpViews "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/expenses/views.py"
    click ExpModels "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/expenses/models.py"
    click ExpTemplates "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/templates/expenses/*.html"
    click PrefDir "https://github.com/ayoubbencheikhi/income-expense-website/tree/main/userpreferences/"
    click PrefURLs "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/userpreferences/urls.py"
    click PrefViews "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/userpreferences/views.py"
    click PrefModels "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/userpreferences/models.py"
    click PrefTemplates "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/templates/preferences/index.html"
    click StaticCSS "https://github.com/ayoubbencheikhi/income-expense-website/tree/main/expenseswebsite/static/css/"
    click StaticJS "https://github.com/ayoubbencheikhi/income-expense-website/tree/main/expenseswebsite/static/js/"
    click BaseHTML "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/templates/base.html"
    click BaseAuth "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/templates/base_auth.html"
    click IndexHTML "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/templates/index.html"
    click PartialsMsgs "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/templates/partials/_messages.html"
    click PartialsSidebar "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/templates/partials/_sidebar.html"
    click EnvFile "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/.env"
    click Pipfile "https://github.com/ayoubbencheikhi/income-expense-website/tree/main/Pipfile"
    click PipfileLock "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/Pipfile.lock"
    click Procfile "https://github.com/ayoubbencheikhi/income-expense-website/tree/main/Procfile"
    click Currencies "https://github.com/ayoubbencheikhi/income-expense-website/blob/main/currencies.json"

    %% Styles
    classDef frontend fill:#E8F1FC,stroke:#0366d6,color:#0366d6
    classDef backend fill:#FEF3C7,stroke:#d97706,color:#92400e
    classDef database fill:#C7F9CC,stroke:#15803d,color:#065f46
    classDef external fill:#F0C7F9,stroke:#9333ea,color:#6b21a8
    classDef config fill:#D9D9D9,stroke:#6b7280,color:#374151
    classDef file fill:#FFFFFF,stroke:#374151,color:#374151
```
