# hackstarsj/django-ecommerce-project-amazon-clone architecture

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

- Interactive diagram: https://gitdiagram.com/hackstarsj/django-ecommerce-project-amazon-clone
- Repository: https://github.com/hackstarsj/django-ecommerce-project-amazon-clone

## Overview

##### Project type and purpose
- This is a monolithic full-stack web application built with Django (Python) that functions as an Amazon-style e-commerce admin panel.
- It provides CRUD interfaces for categories, sub-categories, merchants, products, customers, staff, inventory management, media uploads, and uses the Stisla admin theme.

##### File structure
- Top-level “DjangoEcommerce” directory contains Django project settings (settings.py, urls.py), ASGI/WSGI entrypoints, and the SQLite database file.
- “DjangoEcommerceApp” is the single Django app holding models.py, views.py, AdminViews.py, URL conf (adminurls.py), migrations, templates, static assets, and tests.
- “static” & “DjangoEcommerceApp/static” host CSS/JS/theme modules (Stisla, Bootstrap, DataTables, Summernote, etc.).
- “templates/admin_templates” contains Jinja2/Django templates for the admin UI.
- “media” stores uploaded product media files.

##### README
- It confirms use of the Stisla theme for UI.

##### Main components
a. Client Layer
- Web Browser (Admin user)
b. Edge / Reverse Proxy
- Nginx or a load balancer terminating HTTPS and serving static files
c. Application Layer
- WSGI Server (Gunicorn or uWSGI)
- Django Project (“DjangoEcommerce”)
‑ URL Router (django.urls)
‑ View Layer (views.py, AdminViews.py)
‑ Template Engine (Django templates under templates/)
‑ ORM / Model Layer (models.py → SQLite via django.db)
‑ Business logic (inventory management, pagination, search)
d. Data Layer
- SQLite database (db.sqlite3)
- Media file storage (local filesystem under /media)
e. Static Asset Layer
- WhiteNoise or Nginx serving /static and /DjangoEcommerceApp/static
f. External/Optional Services
- Email SMTP for notifications (if configured)
- CDN for offloading static modules (optional)
- Third-party APIs (none in current code)

##### Relationships and interactions
- Browser → (HTTPS) → Nginx
- Nginx:
- If request path starts with /static or /media, serve files directly
- Else proxy to Gunicorn
- Gunicorn (WSGI) → Django URL Router → matched View
- View → ORM queries/updates → SQLite
- View → render() → template → HTML response
- HTML → Browser
- Browser fetches additional assets (/static/js, /static/css) directly from Nginx
- File uploads (media) handled by Django → saved to /media

##### Architectural patterns and design principles
- MVC/MVT pattern: Models (models.py), Views (views.py), Templates
- Layered architecture: presentation (templates), business (views), data (ORM, DB)
- Separation of concerns: static assets vs. dynamic requests
- Single-app monolith: easy to deploy but can be broken into micro-services if scaled

##### Essential elements to capture
- Admin user’s browser as an external actor
- Reverse proxy/static server separate from the application server
- Django’s MVT internals (URL router, views, templates, models)
- Data storage: relational DB and file storage
- Static asset pipeline and theme modules

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Actor
    Browser["Admin Browser"]:::external

    %% Infrastructure Layer
    Nginx["Nginx / Reverse Proxy"]:::infra
    Gunicorn["Gunicorn WSGI Server"]:::infra

    %% Static Asset Layer
    StaticProj["Global Static (static/)"]:::static
    StaticApp["App Static (DjangoEcommerceApp/static/)"]:::static

    %% Data Layer
    DB["SQLite Database (db.sqlite3)"]:::data
    Media["Media Storage (media/)"]:::data

    %% External/Optional Services
    SMTP["Email SMTP (optional)"]:::external
    CDN["CDN (optional)"]:::external

    %% Application Layer
    subgraph "Application Layer (DjangoEcommerce)" 
        direction TB
        Settings["settings.py"]:::app
        URLRouter["urls.py"]:::app
        WSGI["wsgi.py"]:::app
        ASGI["asgi.py"]:::app
        manage["manage.py"]:::app
        README["README.md"]:::app

        subgraph "App Registration & Routing"
            direction TB
            AppConfig["apps.py"]:::app
            AdminURL["adminurls.py"]:::app
        end

        subgraph "Business Logic"
            direction TB
            Views["views.py"]:::app
            AdminViews["AdminViews.py"]:::app
            AdminReg["admin.py"]:::app
        end

        subgraph "Presentation"
            direction TB
            Templates["templates/admin_templates/"]:::app
        end

        subgraph "Data Models"
            direction TB
            Models["models.py"]:::app
            Migrations["migrations/"]:::app
        end

        Tests["tests.py"]:::app
    end

    %% Connections
    Browser -->|"HTTPS Request"| Nginx
    Nginx -->|"/static/*"| StaticProj
    Nginx -->|"/static-app/*"| StaticApp
    Nginx -->|"/media/*"| Media
    Nginx -->|Proxy Dynamic Request| Gunicorn
    Gunicorn -->|"WSGI Call"| WSGI
    Gunicorn -->|"ASGI Call"| ASGI
    WSGI -->|URL Routing| URLRouter
    ASGI -->|URL Routing| URLRouter
    URLRouter -->|Call Views| Views
    URLRouter -->|Call AdminViews| AdminViews
    Views -->|ORM Query/Update| Models
    AdminViews -->|ORM Query/Update| Models
    Models -->|Schema Migrations| Migrations
    Views -->|Render Template| Templates
    AdminViews -->|Render Template| Templates
    Views -->|Send Email| SMTP
    StaticApp -->|Optional CDN| CDN
    DjangoEnd["Response"]:::infra
    Views -->|Response| Gunicorn
    Gunicorn -->|Pass to Proxy| Nginx
    Nginx -->|HTTPS Response| Browser
    Models -->|Persist Data| DB
    Media -->|File Uploads| Media

    %% Click Events
    click Settings "https://github.com/hackstarsj/django-ecommerce-project-amazon-clone/blob/master/DjangoEcommerce/settings.py"
    click URLRouter "https://github.com/hackstarsj/django-ecommerce-project-amazon-clone/blob/master/DjangoEcommerce/urls.py"
    click WSGI "https://github.com/hackstarsj/django-ecommerce-project-amazon-clone/blob/master/DjangoEcommerce/wsgi.py"
    click ASGI "https://github.com/hackstarsj/django-ecommerce-project-amazon-clone/blob/master/DjangoEcommerce/asgi.py"
    click AppConfig "https://github.com/hackstarsj/django-ecommerce-project-amazon-clone/blob/master/DjangoEcommerceApp/apps.py"
    click Models "https://github.com/hackstarsj/django-ecommerce-project-amazon-clone/blob/master/DjangoEcommerceApp/models.py"
    click Migrations "https://github.com/hackstarsj/django-ecommerce-project-amazon-clone/tree/master/DjangoEcommerceApp/migrations/"
    click Views "https://github.com/hackstarsj/django-ecommerce-project-amazon-clone/blob/master/DjangoEcommerceApp/views.py"
    click AdminViews "https://github.com/hackstarsj/django-ecommerce-project-amazon-clone/blob/master/DjangoEcommerceApp/AdminViews.py"
    click AdminURL "https://github.com/hackstarsj/django-ecommerce-project-amazon-clone/blob/master/DjangoEcommerceApp/adminurls.py"
    click Templates "https://github.com/hackstarsj/django-ecommerce-project-amazon-clone/tree/master/DjangoEcommerceApp/templates/admin_templates/"
    click StaticApp "https://github.com/hackstarsj/django-ecommerce-project-amazon-clone/tree/master/DjangoEcommerceApp/static/"
    click StaticProj "https://github.com/hackstarsj/django-ecommerce-project-amazon-clone/tree/master/static/"
    click Media "https://github.com/hackstarsj/django-ecommerce-project-amazon-clone/tree/master/media/"
    click DB "https://github.com/hackstarsj/django-ecommerce-project-amazon-clone/blob/master/db.sqlite3"
    click Tests "https://github.com/hackstarsj/django-ecommerce-project-amazon-clone/blob/master/DjangoEcommerceApp/tests.py"
    click AdminReg "https://github.com/hackstarsj/django-ecommerce-project-amazon-clone/blob/master/DjangoEcommerceApp/admin.py"
    click manage "https://github.com/hackstarsj/django-ecommerce-project-amazon-clone/blob/master/manage.py"
    click README "https://github.com/hackstarsj/django-ecommerce-project-amazon-clone/blob/master/README.md"

    %% Styles
    classDef external fill:#bbbbbb,stroke:#888888,color:#000000
    classDef infra fill:#bbdefb,stroke:#1e88e5,color:#000000
    classDef app fill:#c8e6c9,stroke:#43a047,color:#000000
    classDef data fill:#ffe0b2,stroke:#fb8c00,color:#000000
    classDef static fill:#e0e0e0,stroke:#757575,color:#000000
```
