# varunpandey2106/baazaarapi2 architecture

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

- Interactive diagram: https://gitdiagram.com/varunpandey2106/baazaarapi2
- Repository: https://github.com/varunpandey2106/baazaarapi2

## Overview

##### Main Components

a. Core Services (Main Django Apps):
- User Service
- Product Service
- Cart Service
- Order Service
- Payment Service
- Notification Service

b. External Integrations:
- Twilio (Notifications)
- Paystack (Payment Processing)
- OAuth (Social Login)
- PostgreSQL Database

**┌─ Client Layer ─────────────────────────────────┐**
- External API Consumers (Mobile/Web Clients)     │
- ┬───────────────────────┘
- ↓
**┌─ API Gateway Layer ───────────────────────────┐**
- Django REST Framework + Swagger Documentation  │
- ┬───────────────────────┘
- ↓
**┌─ Service Layer ──────────────────────────────────────────────┐**
- ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌────────┐ │
- User   │ │ Product │ │  Cart   │ │  Order  │ │Payment │ │
- ┘ └─────────┘ └─────────┘ └─────────┘ └────────┘ │
- ┬───────────────────────────────────┘
- ↓
**┌─ External Services Layer ─────────────────────────────────┐**
- Twilio    PayStack    OAuth                              │
- ┬───────────────────────────────────┘
- ↓
**┌─ Data Layer ────────────────────────────────────────────┐**
- PostgreSQL Database                         │
- ┘

##### Specific Component Details

For each core service, show:
- Models (from models.py)
- Views (from views.py)
- Serializers (from serializer.py)
- URLs (from urls.py)
- Permissions (from permission.py)

##### Key Relationships to Highlight

- Cart → Product (Product selection)
- Order → Cart (Cart conversion to Order)
- Payment → Order (Order payment processing)
- Notification → User (User notifications)
- User → OAuth (Social authentication)

##### Additional Elements

Include:
- Authentication flow
- Payment processing flow
- Notification dispatch system
- Data flow between services
- API endpoints grouping

##### Technical Details

- Django REST Framework middleware
- Permission classes
- Authentication classes
- Database relationships
- Async operations (async_send_mail.py)
- Pagination implementation

##### Infrastructure Components

Show:
- Docker container boundaries
- Static file handling
- API documentation endpoints (Swagger)

Remember to:
- Clear boundaries between services
- Data flow directions
- Version information
- Document security measures

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph CL["Client Layer"]
        Client["External API Consumers"]:::client
    end

    %% API Gateway Layer
    subgraph AG["API Gateway Layer"]
        DRF["Django REST Framework"]:::gateway
        Swagger["Swagger Documentation"]:::gateway
        click Swagger "https://github.com/varunpandey2106/BaazaarAPI2/tree/main/staticfiles/drf-yasg/"
    end

    %% Service Layer
    subgraph SL["Service Layer"]
        %% User Service
        subgraph US["User Service"]
            UserModels["Models"]:::service
            UserViews["Views"]:::service
            UserSerializers["Serializers"]:::service
            UserURLs["URLs"]:::service
            click US "https://github.com/varunpandey2106/BaazaarAPI2/tree/main/user/"
            click UserModels "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/user/models.py"
            click UserViews "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/user/views.py"
            click UserSerializers "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/user/serializer.py"
            click UserURLs "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/user/urls.py"
        end

        %% Product Service
        subgraph PS["Product Service"]
            ProductModels["Models"]:::service
            ProductViews["Views"]:::service
            ProductSerializers["Serializers"]:::service
            ProductURLs["URLs"]:::service
            ProductPerms["Permissions"]:::service
            click PS "https://github.com/varunpandey2106/BaazaarAPI2/tree/main/product/"
            click ProductModels "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/product/models.py"
            click ProductViews "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/product/views.py"
            click ProductSerializers "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/product/serializer.py"
            click ProductURLs "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/product/urls.py"
            click ProductPerms "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/product/permissions.py"
        end

        %% Cart Service
        subgraph CS["Cart Service"]
            CartModels["Models"]:::service
            CartViews["Views"]:::service
            CartSerializers["Serializers"]:::service
            CartURLs["URLs"]:::service
            CartPerms["Permissions"]:::service
            click CS "https://github.com/varunpandey2106/BaazaarAPI2/tree/main/cart/"
            click CartModels "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/cart/models.py"
            click CartViews "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/cart/views.py"
            click CartSerializers "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/cart/serializers.py"
            click CartURLs "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/cart/urls.py"
            click CartPerms "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/cart/permission.py"
        end

        %% Order Service
        subgraph OS["Order Service"]
            OrderModels["Models"]:::service
            OrderViews["Views"]:::service
            OrderSerializers["Serializers"]:::service
            OrderURLs["URLs"]:::service
            OrderPerms["Permissions"]:::service
            click OS "https://github.com/varunpandey2106/BaazaarAPI2/tree/main/order/"
            click OrderModels "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/order/models.py"
            click OrderViews "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/order/views.py"
            click OrderSerializers "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/order/serializer.py"
            click OrderURLs "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/order/urls.py"
            click OrderPerms "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/order/permission.py"
        end

        %% Payment Service
        subgraph PAS["Payment Service"]
            PaymentModels["Models"]:::service
            PaymentViews["Views"]:::service
            PaymentSerializers["Serializers"]:::service
            PaymentURLs["URLs"]:::service
            PaymentPerms["Permissions"]:::service
            click PAS "https://github.com/varunpandey2106/BaazaarAPI2/tree/main/payment/"
            click PaymentModels "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/payment/models.py"
            click PaymentViews "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/payment/views.py"
            click PaymentSerializers "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/payment/serializer.py"
            click PaymentURLs "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/payment/urls.py"
            click PaymentPerms "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/payment/permission.py"
        end

        %% Notification Service
        subgraph NS["Notification Service"]
            NotifModels["Models"]:::service
            NotifViews["Views"]:::service
            NotifUtils["Utils"]:::service
            NotifSignals["Signals"]:::service
            click NS "https://github.com/varunpandey2106/BaazaarAPI2/tree/main/notification/"
            click NotifModels "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/notification/models.py"
            click NotifViews "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/notification/views.py"
            click NotifUtils "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/notification/utils.py"
            click NotifSignals "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/notification/signals.py"
        end
    end

    %% Backend Core Services
    subgraph BCS["Backend Core Services"]
        AsyncMail["Async Mail System"]:::core
        Pagination["Pagination"]:::core
        GlobalPerms["Global Permissions"]:::core
        click AsyncMail "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/backends/async_send_mail.py"
        click Pagination "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/backends/pagination.py"
        click GlobalPerms "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/backends/permission.py"
    end

    %% External Services Layer
    subgraph ESL["External Services Layer"]
        Twilio["Twilio"]:::external
        Paystack["Paystack"]:::external
        OAuth["OAuth"]:::external
    end

    %% Data Layer
    subgraph DL["Data Layer"]
        DB[(PostgreSQL)]:::database
    end

    %% Main Configuration
    subgraph MC["Main Configuration"]
        Settings["Settings"]:::config
        MainURLs["Main URLs"]:::config
        click Settings "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/base/settings.py"
        click MainURLs "https://github.com/varunpandey2106/BaazaarAPI2/blob/main/base/urls.py"
    end

    %% Relationships
    Client --> DRF
    DRF --> Swagger
    DRF --> SL
    CS --> PS
    OS --> CS
    PAS --> OS
    NS --> US
    US --> OAuth
    SL --> ESL
    SL --> DB
    BCS --> SL

    %% Styles
    classDef client fill:#f9f,stroke:#333,stroke-width:2px
    classDef gateway fill:#ff9,stroke:#333,stroke-width:2px
    classDef service fill:#9cf,stroke:#333,stroke-width:2px
    classDef external fill:#9f9,stroke:#333,stroke-width:2px
    classDef database fill:#ddd,stroke:#333,stroke-width:2px
    classDef core fill:#f99,stroke:#333,stroke-width:2px
    classDef config fill:#ff9,stroke:#333,stroke-width:2px
```
