# medurubharath/advanceswep architecture

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

- Interactive diagram: https://gitdiagram.com/medurubharath/advanceswep
- Repository: https://github.com/medurubharath/advanceswep

## Overview

##### Project Type and Purpose
- This is a monolithic, full-stack e-commerce web application built with Django (Python).
- It follows Django’s MTV (Model-Template-View) pattern, serving HTML pages to customers and providing an admin interface.
- Key features: product catalog, shopping cart, checkout, user authentication, order management, media uploads.

##### File Structure
- Top-level Django project:
- Eshop/ (settings.py, urls.py, wsgi.py, asgi.py)
- manage.py, db.sqlite3, requirements.txt
- Single Django app “store/” with sub-directories:
- models/ (category.py, product.py, customer.py, orders.py)
- views/ (home, cart, checkout, login, signup, orders)
- templates/ (HTML pages)
- templatetags/ (custom template filters, tags)
- migrations/ (DB schema evolution)
- middlewares/ (authentication middleware)
- uploads/ (product images)

##### Core Architectural Components
a. Client Tier
- Web browser or mobile client making HTTP(S) requests.
b. Web Server / Framework
- Django invoked via ASGI/WSGI (Eshop/asgi.py, Eshop/wsgi.py).
- Gunicorn/Uvicorn (if deployed), or built-in dev server (manage.py runserver).
c. URL Dispatcher
- Eshop/urls.py → include store/urls.py.
d. Middleware Layer
- store/middlewares/auth.py for request pre-processing (e.g., session check).
e. Controllers (Views)
- store/views/*.py handle business logic: cart.py, checkout.py, etc.
f. Template Layer
- store/templates/*.html rendered by Django Template Engine.
g. Model Layer (ORM)
- store/models/*.py define Product, Category, Customer, Order, OrderStatus.
- Migrations track schema.
h. Database
- SQLite (db.sqlite3). Could be Postgres/MySQL in production.
i. Media Storage
- store/uploads/products (local filesystem). Could be S3 in prod.
j. Django Admin
- store/admin.py exposes management UI.

##### Relationships & Data Flows
- Client → HTTP Request → ASGI/WSGI server
- Server → Middleware → URL Routing
- Routing → View function/class →
- Query Model (ORM) → Database
- Read/Write Media Files
- Invoke business logic (e.g., adding to cart)
- View → Template Engine → Render HTML → HTTP Response → Client
- Admin UI similarly goes through URL→View→Model.

##### Architectural Patterns & Principles
- MTV pattern (Model-Template-View).
- Single monolithic Django app; not microservices.
- Layered architecture: Presentation (templates), Controller (views), Persistence (models, DB).
- Separation of concerns: custom middleware for auth, templatetags for view-agnostic logic.

## Diagram (Mermaid)

```mermaid
flowchart TB
    title("Eshop System Architecture (MTV Model)")

    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        Client["Web Browser / Mobile Client"]:::client
        AdminUI["Django Admin UI"]:::presentation
        subgraph "Templates" 
            direction TB
            BaseT["base.html"]:::template
            IndexT["index.html"]:::template
            CartT["cart.html"]:::template
            CheckoutT["checkout.html"]:::template
            LoginT["login.html"]:::template
            SignupT["signup.html"]:::template
            OrdersT["orders.html"]:::template
        end
    end

    %% Application Logic Layer
    subgraph "Application Logic Layer"
        direction TB
        ASGI["ASGI Server\n(Django, Python)"]:::application
        WSGI["WSGI Server\n(Django, Python)"]:::application
        Middleware["Auth Middleware"]:::application
        ProjectURLs["Project URL Dispatcher\nEshop/urls.py"]:::application
        AppURLs["App URL Dispatcher\nstore/urls.py"]:::application
        subgraph "Views" 
            direction TB
            HomeV["HomeView"]:::view
            CartV["CartView"]:::view
            CheckoutV["CheckoutView"]:::view
            LoginV["LoginView"]:::view
            SignupV["SignupView"]:::view
            OrdersV["OrdersView"]:::view
        end
        AdminUI --> ASGI
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        subgraph "Models (ORM)"
            direction TB
            CategoryM["Category"]:::model
            ProductM["Product"]:::model
            CustomerM["Customer"]:::model
            OrderM["Order & Status"]:::model
        end
        DB["SQLite Database\n(db.sqlite3)"]:::database
        Migrations["Migrations\n(store/migrations/)"]:::database
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        direction TB
        Media["Media Storage\nstore/uploads/products"]:::infra
        ClassDiagram["UML Class Diagram\nstore/UmlClassdiagram.plantuml"]:::artifact
        Manage["manage.py"]:::artifact
    end

    %% Flows
    Client -->|"HTTP Request"| ASGI
    Client -->|"HTTP Request"| WSGI
    ASGI --> Middleware
    WSGI --> Middleware
    Middleware --> ProjectURLs
    ProjectURLs --> AppURLs
    AppURLs --> HomeV
    AppURLs --> CartV
    AppURLs --> CheckoutV
    AppURLs --> LoginV
    AppURLs --> SignupV
    AppURLs --> OrdersV

    HomeV -->|"render"| BaseT
    HomeV -->|"render"| IndexT
    CartV -->|"render"| CartT
    CheckoutV -->|"render"| CheckoutT
    LoginV -->|"render"| LoginT
    SignupV -->|"render"| SignupT
    OrdersV -->|"render"| OrdersT

    HomeV -->|"ORM Query"| ProductM
    CartV -->|"ORM Query"| CustomerM
    CartV -->|"ORM Update"| OrderM
    CheckoutV -->|"ORM Query/Update"| OrderM
    OrdersV -->|"ORM Query"| OrderM

    HomeV -->|"Read/Write"| Media
    CartV -->|"Read/Write"| Media
    CheckoutV -->|"Read/Write"| Media

    CategoryM --> DB
    ProductM --> DB
    CustomerM --> DB
    OrderM --> DB
    Migrations --> DB

    AdminUI --> ProjectURLs
    AdminUI --> CategoryM
    AdminUI --> ProductM
    AdminUI --> CustomerM
    AdminUI --> OrderM

    ClassDiagram --> CategoryM
    ClassDiagram --> ProductM
    ClassDiagram --> CustomerM
    ClassDiagram --> OrderM

    %% Click Events
    click ASGI "https://github.com/medurubharath/advanceswep/blob/main/Eshop/asgi.py"
    click WSGI "https://github.com/medurubharath/advanceswep/blob/main/Eshop/wsgi.py"
    click ProjectURLs "https://github.com/medurubharath/advanceswep/blob/main/Eshop/urls.py"
    click AppURLs "https://github.com/medurubharath/advanceswep/blob/main/store/urls.py"
    click Middleware "https://github.com/medurubharath/advanceswep/blob/main/store/middlewares/auth.py"
    click HomeV "https://github.com/medurubharath/advanceswep/blob/main/store/views/home.py"
    click CartV "https://github.com/medurubharath/advanceswep/blob/main/store/views/cart.py"
    click CheckoutV "https://github.com/medurubharath/advanceswep/blob/main/store/views/checkout.py"
    click LoginV "https://github.com/medurubharath/advanceswep/blob/main/store/views/login.py"
    click SignupV "https://github.com/medurubharath/advanceswep/blob/main/store/views/signup.py"
    click OrdersV "https://github.com/medurubharath/advanceswep/blob/main/store/views/orders.py"
    click BaseT "https://github.com/medurubharath/advanceswep/blob/main/store/templates/base.html"
    click IndexT "https://github.com/medurubharath/advanceswep/blob/main/store/templates/index.html"
    click CartT "https://github.com/medurubharath/advanceswep/blob/main/store/templates/cart.html"
    click CheckoutT "https://github.com/medurubharath/advanceswep/blob/main/store/templates/checkout.html"
    click LoginT "https://github.com/medurubharath/advanceswep/blob/main/store/templates/login.html"
    click SignupT "https://github.com/medurubharath/advanceswep/blob/main/store/templates/signup.html"
    click OrdersT "https://github.com/medurubharath/advanceswep/blob/main/store/templates/orders.html"
    click CategoryM "https://github.com/medurubharath/advanceswep/blob/main/store/models/category.py"
    click ProductM "https://github.com/medurubharath/advanceswep/blob/main/store/models/product.py"
    click CustomerM "https://github.com/medurubharath/advanceswep/blob/main/store/models/customer.py"
    click OrderM "https://github.com/medurubharath/advanceswep/blob/main/store/models/orders.py"
    click DB "https://github.com/medurubharath/advanceswep/blob/main/db.sqlite3"
    click Migrations "https://github.com/medurubharath/advanceswep/tree/main/store/migrations/"
    click AdminUI "https://github.com/medurubharath/advanceswep/blob/main/store/admin.py"
    click Media "https://github.com/medurubharath/advanceswep/tree/main/store/uploads/products/"
    click ClassDiagram "https://github.com/medurubharath/advanceswep/blob/main/store/UmlClassdiagram.plantuml"
    click Manage "https://github.com/medurubharath/advanceswep/blob/main/manage.py"

    %% Styles
    classDef client fill:#D0E6A5,stroke:#333,stroke-width:1px
    classDef presentation fill:#A0C4FF,stroke:#333,stroke-width:1px
    classDef template fill:#BDE0FE,stroke:#333,stroke-width:1px
    classDef application fill:#BFE6BA,stroke:#333,stroke-width:1px
    classDef view fill:#88BBFF,stroke:#333,stroke-width:1px
    classDef model fill:#FFD6A5,stroke:#333,stroke-width:1px
    classDef database fill:#FFADAD,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef infra fill:#E2E2E2,stroke:#333,stroke-width:1px
    classDef artifact fill:#CCCCCC,stroke:#333,stroke-width:1px
```
