# hackstarsj/amazoncloneecommerceprojectusingdjangoreact architecture

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

- Interactive diagram: https://gitdiagram.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact
- Repository: https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact

## Overview

##### Project Type and Purpose
- This is a full‑stack e‑commerce web application (an “Amazon clone”) built on a Django backend (Python) and a React frontend (JavaScript).
- The backend is logically decomposed into Django apps (InventoryServices, OrderService, ProductServices, UserServices) that implement core domain services.
- The frontend is a React SPA that communicates via REST APIs, uses Redux for state management, and implements dynamic multi‑step forms, theming, and user workflows (authentication, product management, purchase/sales orders, warehouse management).

##### File‑Structure Analysis
- Backend/EcommerceInventory: a Django project root containing global settings, middleware (PermissionMiddleware), helper utilities, URL routing, ASGI/WSGI entrypoints, templates, and a local sqlite3 (or MySQL in production).
- Backend/EcommerceInventory/…/apps: four Django apps—InventoryServices, OrderService, ProductServices, UserServices—each with its own controllers, models, migrations, views, and URLs.
- Frontend/ecommerce_inventory: a Create‑React‑App boilerplate with public/ (static HTML), src/ (components, hooks/APIHandler.js, layout, pages, redux store & reducers, utils), and environment configs.
- Dev‑ops files: Dockerfile, CI/CD workflow (/.github/workflows/deploy.yml), AWS deployment steps (S3_SETUP.txt, CI_CD_Deployment_Step_Using_Docker_AWS.txt), ER_Diagram.pdf.

##### Key Components
a. Frontend Layer (React SPA)
- Browser/Client
- React components & pages
- Redux store
- APIHandler (HTTP client)
b. API Layer (Django REST)
- ASGI/WSGI server (e.g., Gunicorn or Uvicorn)
- URL dispatcher → routes to app‑specific controllers (AuthController, WarehouseController, etc.)
- Middleware (PermissionMiddleware)
c. Domain Services (Django Apps)
- UserServices: authentication, authorization, user & permission management
- ProductServices: categories, products, reviews, questions
- InventoryServices: warehouse, rack, shelf, stock management
- OrderService: purchase orders, sales orders
d. Database Layer
- MySQL (or sqlite for dev) with tables per app (see ER_Diagram.pdf)
e. External/Infrastructure Services
- Object storage (AWS S3 for static/media)
- CI/CD pipeline (GitHub Actions → Docker build → push to AWS ECR/ECS)
- Hosting (AWS EC2/ECS, Nginx load balancer, RDS)

##### Relationships & Data Flows
- The React app issues HTTP(S) requests → Django ASGI/WSGI endpoint.
- Django middleware enforces permissions → request routed to appropriate app controller → business logic → ORM → MySQL → response.
- Static/media assets uploaded via frontend → stored in S3 → served via CDN.
- CI/CD pushes Docker images to AWS → deploys backend & frontend containers behind load balancer.

##### Architectural Patterns & Principles
- Layered architecture: Presentation (React) → API layer (Django) → Domain logic (Django apps) → Persistence (ORM/MySQL).
- Modularity via Django apps for service decomposition.
- RESTful API contract between front and back.
- Single‑page‑application on client; cookie/JWT‑based auth.
- Infrastructure as Code via Docker & GitHub Actions.

##### Essential Elements
- From Browser → API Gateway (Django)
- Within Django: URL router → Controllers → Models → DB
- From React file uploads → S3
- CI/CD flow: GitHub Actions → Docker → AWS
- Optional: annotate ports (3000 frontend, 8000 backend), protocols (HTTPS), and data formats (JSON).

##### Step‑by‑Step for the Engineer
1. Start by drawing the React client on top, showing key modules: pages, components, Redux, API handler.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Tier
    subgraph "Client Tier"
        direction TB
        Browser["Browser / React SPA"]:::frontend
        Components["React Components & Pages"]:::frontend
        ReduxStore["Redux Store & Reducers"]:::frontend
        APIHandler["APIHandler (HTTP client)"]:::frontend
        Theming["GlobalStyle & Themes"]:::frontend
        ProtectedRoute["ProtectedRoute Utility"]:::frontend
    end

    %% Application Tier
    subgraph "Application Tier"
        direction TB
        ASGI["ASGI Entry Point"]:::backend
        WSGI["WSGI Entry Point"]:::backend
        Middleware["PermissionMiddleware"]:::backend
        URLRouter["URL Dispatcher / Router"]:::backend

        subgraph "Django Apps"
            direction TB
            subgraph "UserServices App"
                direction TB
                US_Controllers["UserServices Controllers"]:::backend
                US_Models["UserServices Models"]:::backend
                US_URLs["UserServices URLs"]:::backend
            end
            subgraph "ProductServices App"
                direction TB
                PS_Controllers["ProductServices Controllers"]:::backend
                PS_Models["ProductServices Models"]:::backend
                PS_URLs["ProductServices URLs"]:::backend
            end
            subgraph "InventoryServices App"
                direction TB
                IS_Controllers["InventoryServices Controllers"]:::backend
                IS_Models["InventoryServices Models"]:::backend
                IS_URLs["InventoryServices URLs"]:::backend
            end
            subgraph "OrderService App"
                direction TB
                OS_Controllers["OrderService Controllers"]:::backend
                OS_Models["OrderService Models"]:::backend
                OS_URLs["OrderService URLs"]:::backend
            end
        end
    end

    %% Data Tier
    subgraph "Data Tier"
        direction TB
        MySQL["MySQL (EcommerceInventory DB)"]:::database
        S3["AWS S3 (Static/Media)"]:::infra
    end

    %% Deployment Tier
    subgraph "Deployment Tier"
        direction TB
        GitHubActions["GitHub Actions (CI/CD)"]:::infra
        Docker["Docker Build"]:::infra
        AWS["AWS ECS/ECR & Load Balancer"]:::infra
    end

    %% Connections
    Browser -->|interacts| Components
    Components -->|dispatches| ReduxStore
    Components -->|uses| ProtectedRoute
    ReduxStore -->|calls| APIHandler
    APIHandler -->|HTTPS JSON| ASGI

    ASGI -->|forwards| Middleware
    Middleware -->|checks| URLRouter
    URLRouter --> US_Controllers
    URLRouter --> PS_Controllers
    URLRouter --> IS_Controllers
    URLRouter --> OS_Controllers

    US_Controllers --> US_Models --> MySQL
    PS_Controllers --> PS_Models --> MySQL
    IS_Controllers --> IS_Models --> MySQL
    OS_Controllers --> OS_Models --> MySQL

    Components -->|uploads| S3
    ASGI -->|serves static/media| S3

    GitHubActions --> Docker --> AWS
    AWS -->|deploys| ASGI
    AWS -->|deploys| Browser

    %% Click Events
    click Components "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/tree/master/Frontend/ecommerce_inventory/src/components"
    click ReduxStore "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/Frontend/ecommerce_inventory/src/redux/store/store.js"
    click ReduxStore "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/tree/master/Frontend/ecommerce_inventory/src/redux/reducer"
    click APIHandler "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/Frontend/ecommerce_inventory/src/hooks/APIHandler.js"
    click Theming "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/Frontend/ecommerce_inventory/src/layout/GlobalStyle.js"
    click Theming "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/Frontend/ecommerce_inventory/src/layout/themes.js"
    click ProtectedRoute "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/Frontend/ecommerce_inventory/src/utils/ProtectedRoute.js"
    click ASGI "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/Backend/EcommerceInventory/EcommerceInventory/asgi.py"
    click WSGI "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/Backend/EcommerceInventory/EcommerceInventory/wsgi.py"
    click URLRouter "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/Backend/EcommerceInventory/EcommerceInventory/urls.py"
    click Middleware "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/Backend/EcommerceInventory/EcommerceInventory/middleware/PermissionMiddleware.py"
    click US_Controllers "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/tree/master/Backend/EcommerceInventory/UserServices/Controller/"
    click US_Models "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/Backend/EcommerceInventory/UserServices/models.py"
    click US_URLs "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/Backend/EcommerceInventory/UserServices/urls.py"
    click PS_Controllers "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/tree/master/Backend/EcommerceInventory/ProductServices/controller/"
    click PS_Models "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/Backend/EcommerceInventory/ProductServices/models.py"
    click PS_URLs "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/Backend/EcommerceInventory/ProductServices/urls.py"
    click IS_Controllers "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/Backend/EcommerceInventory/InventoryServices/Controller/WarehouseController.py"
    click IS_Models "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/Backend/EcommerceInventory/InventoryServices/models.py"
    click IS_URLs "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/Backend/EcommerceInventory/InventoryServices/urls.py"
    click OS_Controllers "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/tree/master/Backend/EcommerceInventory/OrderService/controller/"
    click OS_Models "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/Backend/EcommerceInventory/OrderService/models.py"
    click OS_URLs "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/Backend/EcommerceInventory/OrderService/urls.py"
    click MySQL "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/Backend/EcommerceInventory/db.sqlite3"
    click GitHubActions "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/.github/workflows/deploy.yml"
    click Docker "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/tree/master/Dockerfile"
    click AWS "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/S3_SETUP.txt"
    click AWS "https://github.com/hackstarsj/amazoncloneecommerceprojectusingdjangoreact/blob/master/CI_CD_Deployment_Step_Using_Docker_AWS.txt"

    %% Styles
    classDef frontend fill:#D0E7FF,stroke:#0366D6,stroke-width:1px
    classDef backend fill:#D0FFD6,stroke:#028A0F,stroke-width:1px
    classDef database fill:#FFE7C0,stroke:#D26900,stroke-width:1px
    classDef infra fill:#F0F0F0,stroke:#666,stroke-width:1px
```
