# tejeshsana/bank_management architecture

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

- Interactive diagram: https://gitdiagram.com/tejeshsana/bank_management
- Repository: https://github.com/tejeshsana/bank_management

## Overview

##### Project Type and Purpose
- This is a full-stack web application (“Bank Management System”) built with Flask (Python) on the backend, MySQL as the database, and a simple responsive frontend using HTML/CSS and Jinja2 templates.
- Purpose: allow users to create bank accounts, check balances, and perform deposit/withdraw/transfer transactions via a web UI.

##### File Structure
- Top level:
- main.py – Flask app entrypoint, defines routes and business logic
- bank_management.sql – DDL/DML for MySQL schema (tables for customers, accounts, transactions)
- Directories:
- static/ – custom CSS files (style.css, style_bal.css) for responsive UI and animations
- templates/ – Jinja2 HTML templates (index, create_account, balance) for views

##### Key Insights from README
- Backend: Flask + python-dotenv for .env config, mysql-connector-python driver
- Frontend: Jinja2 templating with responsive design and flash messages for feedback
- Features outline the main use cases (account creation, balance check, transactions)

##### Main Components
a. User Interface (Client Browser)
- Static assets (CSS) + HTML rendered by Jinja2
- Responsive layout, animated inputs, flash notifications
b. Web Server / Application Layer
- Flask application (main.py) containing route handlers for each feature
- python-dotenv loading environment variables (DB credentials)
- Business logic and input validation
c. Database Layer
- MySQL instance (schema in bank_management.sql)
- Tables: Customer, Account, Transaction
d. External/Infrastructure
- WSGI server (e.g., Gunicorn) or development server
- Deployment environment (could be Docker, VM, or PaaS)

##### Relationships and Interactions
- Browser → HTTP requests (GET/POST) → Flask routes
- Flask routes ↔ mysql-connector-python → MySQL database
- Flask uses Jinja2 to render responses back to browser
- Static/CSS served directly by Flask under /static
- Flash messages passed via session in Flask

##### Architectural Patterns and Principles
- MVC-like separation:
- Model: MySQL tables and data-access layer inside route functions
- View: Jinja2 templates under /templates
- Controller: Flask route handlers in main.py
- Single process app: monolithic architecture
- Separation of concerns: static assets vs templates vs business logic vs data layer

- Flask (main.py)
- Environment loader (python-dotenv)
- Route handlers for create_account, balance, transactions
- From Browser → Flask: HTTP requests
- Flask → MySQL: SQL queries (via mysql-connector-python)
- MySQL → Flask: result sets
- Flask → Browser: HTTP responses (rendered HTML + flash)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Browser Layer
    subgraph "Client Browser"
        direction TB
        subgraph "Static Assets (CSS)"
            direction TB
            CSS1["style.css"]:::frontend
            CSS2["style_bal.css"]:::frontend
        end
        subgraph "HTML Templates (Jinja2)"
            direction TB
            T1["index.html"]:::frontend
            T2["create_account.html"]:::frontend
            T3["balance.html"]:::frontend
        end
    end

    %% Application Server Layer
    subgraph "Application Server"
        direction TB
        ENV["Env Loader (python-dotenv)"]:::backend
        FLASK["Flask App (main.py)"]:::backend
        ROUTES["Route Handlers"]:::backend
    end

    %% Database Layer
    subgraph "MySQL Database"
        direction TB
        DB["MySQL Instance"]:::database
        Customer["Customer Table"]:::database
        Account["Account Table"]:::database
        Transaction["Transaction Table"]:::database
    end

    %% Infrastructure Layer
    subgraph "Infrastructure"
        direction TB
        WSGI["WSGI Server (Gunicorn)"]:::infra
        ENVFILE[".env file"]:::infra
    end

    %% Documentation
    DOC["Project Documentation (README.md)"]:::docs

    %% Connections
    BROWSER["Client Browser"]:::frontend
    BROWSER -->|"HTTP GET/POST"| FLASK
    FLASK -->|"SQL Queries via mysql-connector-python"| DB
    DB -->|"Result Sets"| FLASK
    FLASK -->|"Rendered HTML + Flash"| BROWSER
    ENVFILE -->|"Environment Variables"| ENV
    ENV -->|"Loads into"| FLASK
    WSGI -->|"Serves App"| FLASK
    DOC -.->|"Reference"| FLASK

    %% Click Events
    click CSS1 "https://github.com/tejeshsana/bank_management/blob/main/static/style.css"
    click CSS2 "https://github.com/tejeshsana/bank_management/blob/main/static/style_bal.css"
    click T1 "https://github.com/tejeshsana/bank_management/blob/main/templates/index.html"
    click T2 "https://github.com/tejeshsana/bank_management/blob/main/templates/create_account.html"
    click T3 "https://github.com/tejeshsana/bank_management/blob/main/templates/balance.html"
    click FLASK "https://github.com/tejeshsana/bank_management/blob/main/main.py"
    click DB "https://github.com/tejeshsana/bank_management/blob/main/bank_management.sql"
    click DOC "https://github.com/tejeshsana/bank_management/blob/main/README.md"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,color:#000
    classDef backend fill:#90EE90,stroke:#000,color:#000
    classDef database fill:#FFA500,stroke:#000,color:#000
    classDef infra fill:#D3D3D3,stroke:#000,color:#000
    classDef docs fill:#FFFFE0,stroke:#000,color:#000
```
