# mhdhamka/django-ecommerce-website architecture

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

- Interactive diagram: https://gitdiagram.com/mhdhamka/django-ecommerce-website
- Repository: https://github.com/mhdhamka/django-ecommerce-website

## Overview

##### Project Type and Purpose
- This is a full-stack eCommerce website built on Django (Python) providing user authentication, product catalog, cart/checkout flows, payment integration (Razorpay), order management, and an admin panel.
- The file tree shows a standard Django “project” (ecomm/) with multiple “apps” (accounts, home, products, base), plus templates, static/media assets, migration scripts, and configuration files (.env, settings.py).

##### File Structure Analysis
- Top-level “ecomm” directory: ASGI/WSGI entry points, settings, URL routing.
- Apps (“accounts”, “products”, “home”, “base”): each follows Django’s MVT pattern (models.py, views.py, urls.py, forms.py, migrations/).
- Templates: organized by app, plus shared “base” templates.
- Static/media under public/media: CSS, JS, fonts, images for the frontend.
- requirements.txt, .env.example, manage.py: environment management and project bootstrapping.

##### README Insights
- Clearly lists features (auth, cart, checkout, payments, responsive UI, admin).
- Technologies: Django backend, HTML/CSS/JS + Bootstrap frontend, Razorpay API for payments.
- Deployment hints: uses environment variables for SECRET_KEY, DEBUG, and social-auth settings.

a. Main Components
- Clients (Web browser/mobile)
- Django Web Server (ASGI/WSGI + Gunicorn or similar)
- Django Apps (accounts, products, home, base) implementing business logic
- Django ORM and Database (PostgreSQL/SQLite)
- Static/Media File Storage (local filesystem or CDN)
- External Services: Razorpay Payment Gateway, SMTP/email provider, (optional) Google OAuth via django-allauth
b. Relationships & Data Flows
- HTTP/HTTPS requests from clients → Django URL dispatcher → appropriate app view → template rendering or JSON response
- Views invoke business logic → ORM queries → Database
- Checkout flow: server initiates Razorpay payment session via HTTPS → client completes payment → Razorpay webhooks → server updates Order records
- Email flows: server sends account activation and order notifications via SMTP
- Admin Panel: Django admin front-end → ORM → Database
c. Architectural Patterns & Principles
- Django’s MVT (Model-View-Template) modular pattern
- Separation of concerns: each app owns its domain (users, products, home pages, shared utilities)
- Environment-driven config (.env) for credentials and debug toggles
- Reusable templates and static assets managed via Django’s staticfiles system
d. Key Technologies
- Backend: Python, Django, Gunicorn/ASGI
- Frontend: HTML5, CSS3, JavaScript, Bootstrap
- Database: PostgreSQL or SQLite (via Django ORM)
- Payment: Razorpay REST APIs
- Email: SMTP or external email-service integration

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients
    Client["Web Browser / Mobile"]:::frontend

    %% Backend Server Entry & Config
    subgraph "Backend Server" 
        direction TB
        Config[".env Configuration"]:::config
        Settings["Django Settings"]:::config
        ASGI["ASGI Entry Point"]:::config
        WSGI["WSGI Entry Point"]:::config
        Manage["manage.py"]:::config

        Config --> Settings
        Settings --> ASGI
        Settings --> WSGI
        Settings --> Manage

        %% URL Dispatcher
        URL["URL Dispatcher"]:::backend
        ASGI --> URL
        WSGI --> URL

        %% Template Engine & ORM
        TEngine["Template Engine"]:::backend
        ORM["Django ORM"]:::backend

        %% Apps Cluster
        subgraph "Django Apps" 
            direction TB
            Accounts["accounts app"]:::backend
            Products["products app"]:::backend
            HomeApp["home app"]:::backend
            BaseApp["base app"]:::backend

            Accounts --> ORM
            Products --> ORM
            HomeApp --> ORM
            BaseApp --> ORM

            Accounts --> TEngine
            Products --> TEngine
            HomeApp --> TEngine
            BaseApp --> TEngine
        end

        URL --> Accounts
        URL --> Products
        URL --> HomeApp
        URL --> BaseApp

        %% Payment & Email Services
        Accounts --> RazorpayAPI
        BaseApp --> SMTP

    end

    %% Static / Media Storage
    subgraph "Static/Media Storage" 
        direction TB
        StaticFiles["CSS/JS/Fonts/Images"]:::storage
    end
    StaticFiles --> TEngine

    %% Database
    DB["Database (PostgreSQL/SQLite)"]:::database
    ORM --> DB

    %% External Services
    RazorpayAPI["Razorpay Payment Gateway"]:::external
    SMTP["SMTP / Email Provider"]:::external
    OAuth["Google OAuth (django-allauth)"]:::external

    Client -->|"HTTP/HTTPS"| URL
    TEngine -->|"HTML/CSS/JS"| Client
    Client -->|"AJAX/API Calls"| Accounts

    RazorpayAPI -->|"Webhooks"| Accounts
    SMTP -->|"Emails"| Client
    OAuth -->|"OAuth Callbacks"| Accounts

    %% Click Events - Config & Entry Points
    click Config "https://github.com/mhdhamka/django-ecommerce-website/blob/main/.env.example"
    click Settings "https://github.com/mhdhamka/django-ecommerce-website/blob/main/ecomm/settings.py"
    click ASGI "https://github.com/mhdhamka/django-ecommerce-website/blob/main/ecomm/asgi.py"
    click WSGI "https://github.com/mhdhamka/django-ecommerce-website/blob/main/ecomm/wsgi.py"
    click Manage "https://github.com/mhdhamka/django-ecommerce-website/blob/main/manage.py"

    %% Click Events - URL Routing
    click URL "https://github.com/mhdhamka/django-ecommerce-website/blob/main/ecomm/urls.py"
    click Accounts "https://github.com/mhdhamka/django-ecommerce-website/blob/main/accounts/urls.py"
    click Products "https://github.com/mhdhamka/django-ecommerce-website/blob/main/products/urls.py"
    click HomeApp "https://github.com/mhdhamka/django-ecommerce-website/blob/main/home/urls.py"

    %% Click Events - Accounts App
    click Accounts "https://github.com/mhdhamka/django-ecommerce-website/blob/main/accounts/models.py"
    click Accounts "https://github.com/mhdhamka/django-ecommerce-website/blob/main/accounts/views.py"
    click Accounts "https://github.com/mhdhamka/django-ecommerce-website/blob/main/accounts/forms.py"
    click Accounts "https://github.com/mhdhamka/django-ecommerce-website/blob/main/accounts/signals.py"
    click Accounts "https://github.com/mhdhamka/django-ecommerce-website/blob/main/accounts/admin.py"
    click Accounts "https://github.com/mhdhamka/django-ecommerce-website/tree/main/templates/accounts"

    %% Click Events - Products App
    click Products "https://github.com/mhdhamka/django-ecommerce-website/blob/main/products/models.py"
    click Products "https://github.com/mhdhamka/django-ecommerce-website/blob/main/products/views.py"
    click Products "https://github.com/mhdhamka/django-ecommerce-website/blob/main/products/forms.py"
    click Products "https://github.com/mhdhamka/django-ecommerce-website/blob/main/products/admin.py"
    click Products "https://github.com/mhdhamka/django-ecommerce-website/tree/main/templates/product"
    click Products "https://github.com/mhdhamka/django-ecommerce-website/blob/main/templates/product_parts/product_list.html"

    %% Click Events - Home App
    click HomeApp "https://github.com/mhdhamka/django-ecommerce-website/blob/main/home/models.py"
    click HomeApp "https://github.com/mhdhamka/django-ecommerce-website/blob/main/home/views.py"
    click HomeApp "https://github.com/mhdhamka/django-ecommerce-website/blob/main/home/admin.py"
    click HomeApp "https://github.com/mhdhamka/django-ecommerce-website/tree/main/templates/home"

    %% Click Events - Base App
    click BaseApp "https://github.com/mhdhamka/django-ecommerce-website/blob/main/base/models.py"
    click BaseApp "https://github.com/mhdhamka/django-ecommerce-website/blob/main/base/emails.py"
    click BaseApp "https://github.com/mhdhamka/django-ecommerce-website/tree/main/templates/base"
    click BaseApp "https://github.com/mhdhamka/django-ecommerce-website/tree/main/templates/emails"

    %% Click Events - Static Files
    click StaticFiles "https://github.com/mhdhamka/django-ecommerce-website/tree/main/public/media/css"
    click StaticFiles "https://github.com/mhdhamka/django-ecommerce-website/blob/main/public/media/js/script.js"
    click StaticFiles "https://github.com/mhdhamka/django-ecommerce-website/tree/main/public/media/fonts"
    click StaticFiles "https://github.com/mhdhamka/django-ecommerce-website/tree/main/public/media/images"

    %% Click Events - Auth Templates
    click Client "https://github.com/mhdhamka/django-ecommerce-website/tree/main/templates/registration"
    click Client "https://github.com/mhdhamka/django-ecommerce-website/blob/main/templates/accounts/change_password.html"
    click Client "https://github.com/mhdhamka/django-ecommerce-website/blob/main/templates/accounts/register.html"
    click Client "https://github.com/mhdhamka/django-ecommerce-website/blob/main/templates/accounts/login.html"

    %% Click Events - Environment & Dependencies
    click Config "https://github.com/mhdhamka/django-ecommerce-website/blob/main/requirements.txt"
    click Config "https://github.com/mhdhamka/django-ecommerce-website/blob/main/.gitignore"
    click Config "https://github.com/mhdhamka/django-ecommerce-website/tree/main/LICENSE"
    click Config "https://github.com/mhdhamka/django-ecommerce-website/blob/main/README.md"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef backend fill:#E0FFE0,stroke:#028A0F,color:#028A0F
    classDef config fill:#FFF4D6,stroke:#D18B00,color:#D18B00
    classDef database fill:#FFE0E0,stroke:#D00000,color:#D00000
    classDef storage fill:#FFF0F5,stroke:#C71585,color:#C71585
    classDef external fill:#FFEFD5,stroke:#FF8C00,color:#FF8C00
```
