# saadmk11/banking-system architecture

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

- Interactive diagram: https://gitdiagram.com/saadmk11/banking-system
- Repository: https://github.com/saadmk11/banking-system

## Overview

##### Project Type and Purpose
- Full-stack web application built with Django (MTV/MVC)
- Provides online banking features: account creation, deposit/withdraw, transaction reports, interest calculation via Celery
- Uses Tailwind CSS for modern UI

##### File Structure
- Top-level “banking_system” folder: Django project settings (asgi.py, wsgi.py, settings.py, celery.py)
- Three Django apps under project root:
– accounts (user auth, registration, admin models)
– transactions (deposit/withdraw logic, models, Celery tasks)
– core (home page, shared views, base templates)
- templates/: frontend HTML (organized by app)
- Celery configuration in banking_system/celery.py, django-celery-beat scheduled tasks
- requirements.txt indicates Django, Celery, Redis

##### Key README Insights
- Monthly interest calculation scheduled via Celery Beat + Worker
- Redis as message broker
- PostgreSQL/MySQL (generic RDBMS) for persistence
- Local dev uses manage.py runserver + celery commands

##### Main Components
a. Client / Browser
– Sends HTTP/HTTPS requests
– Renders HTML/CSS (Tailwind)
b. Django Web Application (Monolith)
– HTTP Server (Gunicorn/ASGI or built-in dev server)
– URL Router (banking_system/urls.py → app URLs)
– View Layer (accounts/views.py, transactions/views.py, core/views.py)
– Template Layer (templates/*.html)
– Models/ORM (accounts/models.py, transactions/models.py, core/models.py)
c. Relational Database
– Stores Users, Accounts, Transactions, Interest rules, etc.
d. Message Broker (Redis)
– Queues Celery tasks
e. Celery Worker(s)
– Executes asynchronous tasks (calculating interest, sending notifications)
f. Celery Beat Scheduler
– Triggers periodic interest-calculation tasks

##### Relationships and Interactions
1) Client → Web App
- HTTP GET/POST → Django views → ORM → DB → render HTML → response
2) Web App → DB
- Synchronous reads/writes for accounts & transactions
3) Web App → Redis
- When a transaction occurs or at month-end, view or signal enqueues Celery task
4) Celery Beat → Redis
- Periodic “calculate monthly interest” tasks enqueued
5) Celery Worker → Redis
- Worker polls Redis, fetches tasks
6) Celery Worker → DB
- Updates account balances, writes transaction records

##### Architectural Patterns & Principles
- Monolithic Django “apps” as modules (accounts, transactions, core)
- MTV (Model-Template-View) pattern
- Asynchronous task processing (Celery for scalability & non-blocking work)
- Separation of concerns:
– HTTP request-response cycle vs. background job processing
– UI layer vs. business logic layer vs. data layer

##### Putting It All Together
- Layer 2 (Web App): Django (views/templates/models) → DB
↘ enqueue → Redis
- Layer 3 (Async): Celery Beat → Redis → Celery Worker → DB

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer" 
        direction TB
        Browser["Client Browser"]:::client
        subgraph "Template Layer" 
            direction TB
            A1["user_login.html"]:::template
            A2["user_registration.html"]:::template
            B1["base.html"]:::template
            B2["footer.html"]:::template
            B3["index.html"]:::template
            B4["messages.html"]:::template
            B5["navbar.html"]:::template
            C1["transaction_form.html"]:::template
            C2["transaction_report.html"]:::template
        end
    end

    %% Web App Layer
    subgraph "Django Web App" 
        direction TB
        Server["Gunicorn/ASGI Server\n(manage.py)"]:::server
        Settings["settings.py\nasgi.py\nwsgi.py\ncelery.py"]:::config
        Router["URL Router"]:::router
        subgraph "Business Logic"
            direction TB
            Views["View Layer"]:::view
            Models["ORM Models"]:::model
        end
    end

    %% Persistence & Async Layer
    subgraph "Persistence & Async" 
        direction TB
        DB["Relational Database"]:::db
        Redis["Redis Broker"]:::async
        Beat["Celery Beat Scheduler"]:::async
        Worker["Celery Worker"]:::async
    end

    %% Connections
    Browser -->|"HTTP Request"| Server
    Server -->|"load settings"| Settings
    Server -->|"route request"| Router
    Router -->|"invoke"| Views
    Views -->|"render"| A1
    Views -->|"render"| A2
    Views -->|"render"| B1
    Views -->|"render"| B2
    Views -->|"render"| B3
    Views -->|"render"| B4
    Views -->|"render"| B5
    Views -->|"render"| C1
    Views -->|"render"| C2
    Views -->|"access"| Models
    Models -->|"read/write"| DB
    Views -->|"enqueue task"| Redis
    Beat -->|"schedule job"| Redis
    Worker -->|"fetch task"| Redis
    Worker -->|"update"| DB

    %% Click Events - Templates
    click A1 "https://github.com/saadmk11/banking-system/blob/master/templates/accounts/user_login.html"
    click A2 "https://github.com/saadmk11/banking-system/blob/master/templates/accounts/user_registration.html"
    click B1 "https://github.com/saadmk11/banking-system/blob/master/templates/core/base.html"
    click B2 "https://github.com/saadmk11/banking-system/blob/master/templates/core/footer.html"
    click B3 "https://github.com/saadmk11/banking-system/blob/master/templates/core/index.html"
    click B4 "https://github.com/saadmk11/banking-system/blob/master/templates/core/messages.html"
    click B5 "https://github.com/saadmk11/banking-system/blob/master/templates/core/navbar.html"
    click C1 "https://github.com/saadmk11/banking-system/blob/master/templates/transactions/transaction_form.html"
    click C2 "https://github.com/saadmk11/banking-system/blob/master/templates/transactions/transaction_report.html"

    %% Click Events - Config & Entry
    click Settings "https://github.com/saadmk11/banking-system/blob/master/banking_system/settings.py"
    click Settings "https://github.com/saadmk11/banking-system/blob/master/banking_system/asgi.py"
    click Settings "https://github.com/saadmk11/banking-system/blob/master/banking_system/wsgi.py"
    click Settings "https://github.com/saadmk11/banking-system/blob/master/banking_system/celery.py"
    click Server "https://github.com/saadmk11/banking-system/blob/master/manage.py"

    %% Click Events - Router
    click Router "https://github.com/saadmk11/banking-system/blob/master/banking_system/urls.py"
    click Router "https://github.com/saadmk11/banking-system/blob/master/accounts/urls.py"
    click Router "https://github.com/saadmk11/banking-system/blob/master/transactions/urls.py"

    %% Click Events - Views
    click Views "https://github.com/saadmk11/banking-system/blob/master/accounts/views.py"
    click Views "https://github.com/saadmk11/banking-system/blob/master/transactions/views.py"
    click Views "https://github.com/saadmk11/banking-system/blob/master/core/views.py"

    %% Click Events - Models
    click Models "https://github.com/saadmk11/banking-system/blob/master/accounts/models.py"
    click Models "https://github.com/saadmk11/banking-system/blob/master/transactions/models.py"
    click Models "https://github.com/saadmk11/banking-system/blob/master/core/models.py"

    %% Click Events - Async
    click Beat "https://github.com/saadmk11/banking-system/blob/master/banking_system/celery.py"
    click Worker "https://github.com/saadmk11/banking-system/blob/master/transactions/tasks.py"

    %% Styles
    classDef client fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef template fill:#e2e3e5,stroke:#555,stroke-dasharray: 2 2
    classDef server fill:#f8d7da,stroke:#900,stroke-width:1px
    classDef config fill:#fff3cd,stroke:#665,stroke-width:1px
    classDef router fill:#d1ecf1,stroke:#177,stroke-width:1px
    classDef view fill:#f5c6cb,stroke:#c00,stroke-width:1px
    classDef model fill:#d4edda,stroke:#155,stroke-width:1px
    classDef db fill:#c3e6cb,stroke:#090,stroke-width:2px
    classDef async fill:#ffe5b4,stroke:#f80,stroke-width:2px
```
