# fabagaipo/webmart architecture

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

- Interactive diagram: https://gitdiagram.com/fabagaipo/webmart
- Repository: https://github.com/fabagaipo/webmart

## Overview

##### Project type and purpose
- WebMart is a full-stack e-commerce web application.
- The `frontend/` directory holds a React/Vite single-page app (SPA) with Context-based state management and a thin API wrapper.
- The `webmart_api/` directory is a Django back end exposing HTTP/GraphQL endpoints, organized into per-domain “apps” (category, product, store, order, user_profile).

##### File structure
- Top-level directories:
- `frontend/` (React code, assets, components, contexts, API wrapper)
- `webmart_api/` (Django project, apps, settings, ASGI/WSGI entrypoints)
- React uses `App.jsx`, various UI components under `src/components`, Context providers under `src/context`, and a client library under `src/webmart-api/webmartAPI.js`.
- Django side uses the traditional project structure (`manage.py`, settings, URLs) plus subfolders for each domain. Each domain has `models/`, `migrations/`, `api/` (endpoint handlers), and `schema/` (GraphQL or validation schemas).
- No separate microservices—Django is a monolith, but logically broken into modular apps.

##### README for additional insights
- Confirms local setup: Python 3.12, Django dev server, React dev server via `npm run dev`.
- No external dependencies (e.g. message brokers or cache layers) are explicitly listed; assume a single relational DB (e.g. PostgreSQL).

##### Don’t overthink—capture every logical component
- Break the Django monolith into its five domain apps rather than lumping them all together.
- React Context providers and the custom API client as separate pieces of the frontend.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend" 
        direction TB
        SPA["React SPA"]:::frontend
        subgraph "Context Providers"
            direction TB
            CartCtx["CartContext"]:::frontend
            NotifCtx["NotificationContext"]:::frontend
            UserCtx["UserContext"]:::frontend
        end
        ComponentsDir["UI Components"]:::frontend
        APIClient["WebMartAPI Client"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend" 
        direction TB
        DjangoCore["Django Core"]:::backend
        subgraph "Category App"
            direction TB
            CatModels["Category Models"]:::backend
            CatAPI["Category API Endpoints"]:::backend
            CatSchema["Category Schema"]:::backend
        end
        subgraph "Product App"
            direction TB
            ProdModels["Product Models"]:::backend
            ProdAPI["Product API Endpoints"]:::backend
            ProdSchema["Product Schema"]:::backend
        end
        subgraph "Store App"
            direction TB
            StoreModels["Store Models"]:::backend
            StoreAPI["Store API Endpoints"]:::backend
            StoreSchema["Store Schema"]:::backend
        end
        subgraph "Order App"
            direction TB
            OrderModels["Order Models"]:::backend
            OrderAPI["Order API Endpoints"]:::backend
            OrderSchema["Order Schema"]:::backend
        end
        subgraph "UserProfile App"
            direction TB
            UserModels["UserProfile Models"]:::backend
            UserAPI["UserProfile API Endpoints"]:::backend
            UserSchema["UserProfile Schema"]:::backend
        end
    end

    %% Data Stores and External
    DB["PostgreSQL Database"]:::database
    External["Payment/Email Gateway"]:::external

    %% Connections
    SPA -->|"state via Context"| CartCtx
    SPA -->|"state via Context"| NotifCtx
    SPA -->|"state via Context"| UserCtx
    SPA -->|"renders UI from Components"| ComponentsDir
    ComponentsDir -->|"calls"| APIClient
    CartCtx -->|"uses API Client"| APIClient
    NotifCtx -->|"uses API Client"| APIClient
    UserCtx -->|"uses API Client"| APIClient
    APIClient -->|"HTTP/GraphQL Requests"| DjangoCore

    DjangoCore -->|"routes to app APIs"| CatAPI
    DjangoCore -->|"routes to app APIs"| ProdAPI
    DjangoCore -->|"routes to app APIs"| StoreAPI
    DjangoCore -->|"routes to app APIs"| OrderAPI
    DjangoCore -->|"routes to app APIs"| UserAPI

    CatAPI -->|"CRUD via ORM"| CatModels
    ProdAPI -->|"CRUD via ORM"| ProdModels
    StoreAPI -->|"CRUD via ORM"| StoreModels
    OrderAPI -->|"CRUD via ORM"| OrderModels
    UserAPI -->|"CRUD via ORM"| UserModels

    CatModels -->|"persist data"| DB
    ProdModels -->|"persist data"| DB
    StoreModels -->|"persist data"| DB
    OrderModels -->|"persist data"| DB
    UserModels -->|"persist data"| DB
    DjangoCore -->|"auth/session storage"| DB

    DjangoCore -->|"send notifications/payments"| External

    %% Click Events
    click SPA "https://github.com/fabagaipo/webmart/blob/master/frontend/src/App.jsx"
    click CartCtx "https://github.com/fabagaipo/webmart/blob/master/frontend/src/context/CartContext.jsx"
    click NotifCtx "https://github.com/fabagaipo/webmart/blob/master/frontend/src/context/NotificationContext.jsx"
    click UserCtx "https://github.com/fabagaipo/webmart/blob/master/frontend/src/context/UserContext.jsx"
    click ComponentsDir "https://github.com/fabagaipo/webmart/tree/master/frontend/src/components"
    click APIClient "https://github.com/fabagaipo/webmart/blob/master/frontend/src/webmart-api/webmartAPI.js"

    click DjangoCore "https://github.com/fabagaipo/webmart/blob/master/webmart_api/src/_webmart_api/asgi.py"
    click DjangoCore "https://github.com/fabagaipo/webmart/blob/master/webmart_api/src/_webmart_api/wsgi.py"
    click DjangoCore "https://github.com/fabagaipo/webmart/blob/master/webmart_api/src/_webmart_api/settings.py"
    click DjangoCore "https://github.com/fabagaipo/webmart/blob/master/webmart_api/src/_webmart_api/urls.py"
    click DjangoCore "https://github.com/fabagaipo/webmart/blob/master/webmart_api/src/_webmart_api/api.py"
    click DjangoCore "https://github.com/fabagaipo/webmart/blob/master/webmart_api/src/_webmart_api/auth.py"
    click DjangoCore "https://github.com/fabagaipo/webmart/blob/master/webmart_api/src/_webmart_api/baseschema.py"
    click DjangoCore "https://github.com/fabagaipo/webmart/blob/master/webmart_api/src/_webmart_api/utils.py"

    click Category App "webmart_api/src/category/models/category.py"
    click CatAPI "https://github.com/fabagaipo/webmart/tree/master/webmart_api/src/category/api/"
    click CatSchema "https://github.com/fabagaipo/webmart/tree/master/webmart_api/src/category/schema/"

    click Product App "webmart_api/src/product/models/product.py"
    click ProdAPI "https://github.com/fabagaipo/webmart/tree/master/webmart_api/src/product/api/"
    click ProdSchema "https://github.com/fabagaipo/webmart/blob/master/webmart_api/src/product/schema/product.py"

    click Store App "webmart_api/src/store/models/store.py"
    click StoreAPI "https://github.com/fabagaipo/webmart/tree/master/webmart_api/src/store/api/"
    click StoreSchema "https://github.com/fabagaipo/webmart/blob/master/webmart_api/src/store/schema/store.py"

    click Order App "webmart_api/src/order/models/order.py"
    click OrderAPI "https://github.com/fabagaipo/webmart/tree/master/webmart_api/src/order/api/"
    click OrderSchema "https://github.com/fabagaipo/webmart/tree/master/webmart_api/src/order/schema/"

    click UserProfile App "webmart_api/src/user_profile/models/user_profile.py"
    click UserAPI "https://github.com/fabagaipo/webmart/tree/master/webmart_api/src/user_profile/api/"
    click UserSchema "https://github.com/fabagaipo/webmart/tree/master/webmart_api/src/user_profile/schema/"

    %% Styles
    classDef frontend fill:#DAE8FC,stroke:#6C8EBF,color:#1A237E
    classDef backend fill:#D5E8D4,stroke:#82B366,color:#254117
    classDef database fill:#FFF2CC,stroke:#D6B656,color:#7F6000
    classDef external fill:#F5F5F5,stroke:#999999,color:#333333
```
