# smalldjangoking/fishmarket architecture

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

- Interactive diagram: https://gitdiagram.com/smalldjangoking/fishmarket
- Repository: https://github.com/smalldjangoking/fishmarket

## Overview

##### Project Type and Purpose
- This is a full-stack, monolithic Django web application (“FishMarket”) serving as an online seafood store.
- It exposes a browser-based UI (mainapp, cart, checkout, users apps), integrates with external services (Nova Poshta API for delivery, SMTP for email), runs asynchronous tasks (Celery), and offers a Telegram Bot for store managers.

##### File-Structure Analysis
- **Root & Config**
- manage.py, Dockerfile, docker-compose.yml, .env – orchestration & environment
- FishMarket/FishMarket – Django project settings (asgi.py, wsgi.py, celery.py, settings.py, urls.py)
- **Django Apps**
- mainapp – public listing, search, product pages
- cart – shopping-cart logic, bucket view templates, context processors
- checkout – order placement, Nova Poshta integration, checkout UI, delivery forms
- users – login/signup/email confirmation, profile, address & history
- novapost – scheduled tasks & helpers to sync delivery data via Nova Poshta API
- telegram – Aiogram-based Bot for managers: order status, notifications, commands
- **Asynchronous**
- celery.py in project root sets up Celery; tasks.py in novapost and telegram apps
- **Static & Templates**
- static/css/js per app + global static/ templates/base & includes
- **Dependencies & Build**
- Pipfile / requirements.txt, Docker, docker-compose to wire web server, DB, broker.

##### Key Insights from README
- Core features: browse & sort products, guest checkout vs. authenticated, discount & order history, Nova Poshta delivery options, manager tools via Django Admin & Telegram Bot.
- Tech stack: Python, Django, HTML/CSS/JS, jQuery, Aiogram, Celery.

a. Main Components
- Clients (Browsers: mobile & desktop)
- Django Web Server (Gunicorn/Uvicorn via ASGI/WSGI)
- Relational Database (PostgreSQL/MySQL)
- Message Broker (Redis or RabbitMQ)
- Celery Workers
- External Services:
– Nova Poshta REST API
– SMTP Email Service
– Telegram API (via Aiogram Bot)
- Static-File Store / CDN (optional)
b. Relationships & Data Flows
- HTTP(S) requests: Clients → Django Web Server → (views → models) → Database
- Django → External APIs:
– checkout app calls Nova Poshta for shipping info
– users app sends verification emails via SMTP
- Asynchronous
– Django enqueues tasks → Message Broker → Celery Workers
– novapost sync task fetches & updates delivery locations daily
– telegram tasks send real-time notifications & handle manager commands
- Django Admin & Telegram Bot both read/write orders in the Database
c. Architectural Patterns & Principles
- MVC (Django’s MTV): Templates (views) ↔ Models ↔ URL routes/controllers
- Modular apps: each domain feature in its own Django app
- CQRS-style separation of synchronous web traffic vs. asynchronous tasks
- External-Service Integration via well-defined adapters/helpers
d. Key Technologies
- Django (apps, ORM, templates, URL routing)
- Celery & Broker (task queue)
- Aiogram (Telegram Bot)
- Nova Poshta API helper module (novapost/novapost.py)
- Docker & docker-compose (containerization)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    Browser["Web Browser (Desktop/Mobile)"]:::client
    StaticCDN["Static File Store/CDN"]:::cdn

    %% Backend Server
    subgraph "Django Web Server" 
        direction TB
        Server["Gunicorn/Uvicorn (ASGI/WSGI)"]:::backend
        subgraph "Project Settings"
            direction TB
            MP["manage.py"]:::backend
            SET["settings.py"]:::backend
            URLS["urls.py"]:::backend
            ASGI["asgi.py"]:::backend
            WSGI["wsgi.py"]:::backend
            CEL["celery.py"]:::backend
            HELP["helpers.py"]:::backend
        end
        subgraph "Django Apps"
            direction TB
            MA["MainApp"]:::app
            CART["Cart App"]:::app
            CO["Checkout App"]:::app
            USERS["Users App"]:::app
            NOVA["NovaPost App"]:::app
            TGBOT["Telegram Bot App"]:::app
        end
    end

    %% Database
    DB["Relational Database"]:::db

    %% Asynchronous
    subgraph "Async Infrastructure"
        direction TB
        Broker["Message Broker (Redis/RabbitMQ)"]:::broker
        Worker["Celery Workers"]:::worker
    end

    %% External Services
    NP["Nova Poshta API"]:::external
    SMTP["SMTP Email Service"]:::external
    TGAPI["Telegram API"]:::external

    %% Global Static & Templates
    GlobalStatic["Global Static Files"]:::static
    GlobalTemplates["Base Templates & Includes"]:::template

    %% Containerization
    Docker["Docker & Docker-Compose"]:::infra
    Env[".env / Pipfile / requirements.txt"]:::infra

    %% Connections
    Browser -->|"HTTP(S)"| Server
    Server -->|Serves static| StaticCDN
    Server -->|"Reads/Writes"| DB
    Server -->|Enqueue Tasks| Broker
    Broker -->|Dispatch| Worker
    Worker -->|Reads/Writes| DB

    Server -->|REST API| NP
    Server -->|SMTP| SMTP
    TGBOT -->|Telegram Bot API| TGAPI
    TGBOT -->|Reads/Writes| DB

    Browser -->|Static| GlobalStatic
    Server -->|Load Templates| GlobalTemplates

    Docker --> Server
    Docker --> Broker
    Docker --> DB
    Env --> Docker

    %% Click Events
    click MP "https://github.com/smalldjangoking/fishmarket/blob/main/FishMarket/manage.py"
    click SET "https://github.com/smalldjangoking/fishmarket/blob/main/FishMarket/FishMarket/settings.py"
    click URLS "https://github.com/smalldjangoking/fishmarket/blob/main/FishMarket/FishMarket/urls.py"
    click ASGI "https://github.com/smalldjangoking/fishmarket/blob/main/FishMarket/FishMarket/asgi.py"
    click WSGI "https://github.com/smalldjangoking/fishmarket/blob/main/FishMarket/FishMarket/wsgi.py"
    click CEL "https://github.com/smalldjangoking/fishmarket/blob/main/FishMarket/FishMarket/celery.py"
    click HELP "https://github.com/smalldjangoking/fishmarket/blob/main/FishMarket/FishMarket/helpers.py"

    click MA "https://github.com/smalldjangoking/fishmarket/tree/main/FishMarket/mainapp"
    click CART "https://github.com/smalldjangoking/fishmarket/tree/main/FishMarket/cart"
    click CO "https://github.com/smalldjangoking/fishmarket/tree/main/FishMarket/checkout"
    click USERS "https://github.com/smalldjangoking/fishmarket/tree/main/FishMarket/users"
    click NOVA "https://github.com/smalldjangoking/fishmarket/tree/main/FishMarket/novapost"
    click TGBOT "https://github.com/smalldjangoking/fishmarket/tree/main/FishMarket/telegram"

    click GlobalStatic "https://github.com/smalldjangoking/fishmarket/tree/main/FishMarket/static/"
    click GlobalTemplates "https://github.com/smalldjangoking/fishmarket/tree/main/FishMarket/templates/"

    click Docker "https://github.com/smalldjangoking/fishmarket/blob/main/docker-compose.yml"
    click Env "https://github.com/smalldjangoking/fishmarket/blob/main/.env"

    %% Styles
    classDef client fill:#ACE7EF,stroke:#0384A0,color:#000
    classDef cdn fill:#E0F7D4,stroke:#67A30A,color:#000
    classDef backend fill:#CDE7F0,stroke:#3B82F6,color:#000
    classDef app fill:#D1C4E9,stroke:#7E57C2,color:#000
    classDef db fill:#C8E6C9,stroke:#388E3C,color:#000
    classDef broker fill:#FFE0B2,stroke:#FB8C00,color:#000
    classDef worker fill:#FFCCBC,stroke:#D84315,color:#000
    classDef external fill:#ECEFF1,stroke:#607D8B,color:#000
    classDef static fill:#FFF9C4,stroke:#FBC02D,color:#000
    classDef template fill:#F3E5F5,stroke:#9C27B0,color:#000
    classDef infra fill:#CFD8DC,stroke:#455A64,color:#000
```
