# 101t/jasmin-web-panel architecture

> Architecture diagram of the GitHub repository 101t/jasmin-web-panel, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/101t/jasmin-web-panel
- Repository: https://github.com/101t/jasmin-web-panel

## Overview

##### Project Type and Purpose
- This is a full-stack Django web application (“Jasmin Web Panel”) to manage a Jasmin SMS Gateway.
- It provides both a browser-based UI and a RESTful API, includes background tasks (via Celery), and is designed to run in Docker, behind Nginx/Gunicorn in production.

##### File Structure
- Top-level “config” directory holds Django settings, ASGI/WSGI entrypoints, Celery configuration, and Docker configs.
- “main/api” contains API endpoints (views, serializers).
- “main/web” contains server-rendered templates, static assets (JS/CSS) and web views.
- “main/core” holds core business logic: models, tasks, SMTP mailer, SMPP connectors to Jasmin.
- “main/users” manages authentication and user‐profile sub-system.
- Docker and docker-compose files orchestrate multi‐container deployments (app, DB, broker, Jasmin gateway, optional submit-log service).

##### README for Deployment Patterns
- Production stack: Nginx → Gunicorn → Django (config.wsgi)
- Async jobs: Celery workers (config.celery) → broker (Redis or RabbitMQ)
- External services:
– PostgreSQL (PRODB_URL)
– Jasmin SMS Gateway (Telnet/SMPP host & port)
– Submit-Log service (optional)
– External SMTP server (for notification emails)

##### Main Components
a. Client Layer
– Web Browser (UI)
– API Consumers (could be AJAX frontend or external apps)
b. Edge / Web Server
– Nginx (reverse proxy, static & media hosting)
– Upstream: Gunicorn WSGI/ASGI workers
c. Django Application
– URL Dispatcher (config/urls.py, main/api/urls.py, main/web/urls.py)
– Web MVC (main/web/views + templates + static)
– REST API (main/api/views)
– Users Module (authentication, profile management)
– Core Module (SMS commands, logging, SMPP connectors, mailer)
d. Data Stores
– PostgreSQL Database
– (Possibly) Redis/RabbitMQ as Celery broker
e. Background Workers
– Celery Workers executing tasks (mail_html, Submit-Log integration, SMPP jobs)
f. External Services
– Jasmin SMS Gateway (Telnet & SMPP interfaces)
– Submit-Log microservice (optional, via HTTP or AMQP)
– SMTP server (for sending emails)

##### Relationships and Data Flows
- Django ↔ Database: ORM calls to PostgreSQL
- Django → Celery broker: enqueue background tasks
- Celery worker → Django models/external systems: process queued tasks
- Django/Celery → Jasmin Gateway: Telnet API calls or SMPP sessions
- Django → SMTP server: send notification emails
- Docker-Compose: orchestrates all containers and inter-container networks

##### Architectural Patterns and Design Principles
- Django’s MTV (Model-Template-View) layered structure
- Clear separation: synchronous request/response vs asynchronous job processing
- Modular apps: api, web, core, users
- Infrastructure as code: Docker, Compose, Nginx, Systemd service

##### Technologies & Frameworks to Annotate
- Python ≥3.11, Django framework
- Celery for background processing
- PostgreSQL (primary DB)
- Redis or RabbitMQ (Celery broker)
- Jasmin SMS Gateway (external Telnet/SMPP)
- Docker / docker-compose orchestrator
- Nginx reverse proxy + Gunicorn application server
- SMTP server (mail notifications)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        Browser["Web Browser"]:::ui
        APIClient["API Consumer"]:::ui
    end

    %% Docker Compose Stack
    subgraph "Docker Compose Stack"
        direction TB
        Nginx["Nginx Reverse Proxy"]:::compute
        Gunicorn["Gunicorn WSGI/ASGI Workers"]:::compute
        CeleryWorker["Celery Worker"]:::compute
        Postgres["PostgreSQL Database"]:::datastore
        Broker["Redis/RabbitMQ Broker"]:::datastore
        JasminContainer["Jasmin SMS Gateway"]:::external
        SubmitLogService["Submit-Log Service (Optional)"]:::external
        SMTPServer["SMTP Server"]:::external
    end

    %% Django Application Layer
    subgraph "Django Application"
        direction TB
        %% Entrypoints
        WSGI["config/wsgi.py"]:::compute
        ASGI["config/asgi.py"]:::compute
        CeleryConfig["config/celery.py"]:::compute

        %% URL Dispatcher
        Dispatcher["URL Dispatcher"]:::compute
        ProjectURLs["config/urls.py"]:::compute
        APIURLs["main/api/urls.py"]:::compute
        WebURLs["main/web/urls.py"]:::compute
        UsersURLs["main/users/urls.py"]:::compute

        %% Modules
        subgraph "Web MVC"
            WebViews["main/web/views/"]:::compute
            WebTemplates["main/web/templates/"]:::compute
            WebStatic["main/web/static/"]:::compute
        end
        subgraph "REST API"
            APIViews["main/api/views/"]:::compute
            APIFilters["main/api/views/filters.py"]:::compute
        end
        subgraph "Users Module"
            UsersModels["main/users/models/"]:::compute
            UsersViews["main/users/views/"]:::compute
            UsersForms["main/users/forms/"]:::compute
            UsersAdmin["main/users/admin/"]:::compute
            UsersBackends["main/users/backends/"]:::compute
            UsersMiddleware["main/users/middleware.py"]:::compute
        end
        subgraph "Core Module"
            CoreModels["main/core/models/"]:::compute
            SMPP["main/core/smpp/"]:::compute
            Mailer["main/core/mailer/"]:::compute
            MailSender["main/core/notify/mail_sender.py"]:::compute
            CoreTasks["main/core/tasks/"]:::compute
            MailHTMLTask["main/core/tasks/mail_html.py"]:::compute
            CoreAdmin["main/core/admin/"]:::compute
            ManagementCmds["main/core/management/commands/"]:::compute
            CoreUtils["main/core/utils/"]:::compute
            CoreTools["main/core/tools.py"]:::compute
            CoreCtx["main/core/context_processors.py"]:::compute
            CoreMiddleware["main/core/middleware.py"]:::compute
        end
        %% Config & Settings
        subgraph "Config"
            SettingsCom["config/settings/com.py"]:::compute
            SettingsDev["config/settings/dev.py"]:::compute
            SettingsPro["config/settings/pro.py"]:::compute
            Routing["config/routing.py"]:::compute
            Version["config/version.py"]:::compute
        end
    end

    %% Infrastructure as Code
    subgraph "Infra as Code"
        Compose["docker-compose.yml"]:::compute
        AlpineDockerfile["config/docker/alpine/Dockerfile"]:::compute
        ComposeAlpine["docker-compose-alpine.yml"]:::compute
        JasminCompose["config/docker/jasmin/docker-compose.yml"]:::compute
        JasminConfig["config/docker/jasmin/jasmin/config/"]:::compute
        SmsLoggerDockerfile["config/docker/sms_logger/Dockerfile"]:::compute
        SmsLoggerScript["sms_logger.py"]:::compute
        EntrypointSlim["config/docker/slim/docker-entrypoint.sh"]:::compute
        EntrypointCelery["docker-entrypoint-celery.sh"]:::compute
    end

    %% Connections
    Browser -->|HTTP Request| Nginx
    APIClient -->|API Call| Nginx
    Nginx -->|Forward| Gunicorn
    Gunicorn -->|WSGI/ASGI| WSGI
    Gunicorn -->|ASGI| ASGI
    WSGI -->|Invoke| Dispatcher
    ASGI -->|Invoke| Dispatcher
    CeleryWorker -->|Uses| CeleryConfig
    Dispatcher -->|Routes to| ProjectURLs
    ProjectURLs -->|Includes| APIURLs
    ProjectURLs -->|Includes| WebURLs
    ProjectURLs -->|Includes| UsersURLs

    WebURLs -->|Calls| WebViews
    WebViews -->|Render| WebTemplates
    WebViews -->|Serve| WebStatic

    APIURLs -->|Calls| APIViews
    APIViews -->|Use| APIFilters

    UsersURLs -->|Calls| UsersViews
    UsersViews -->|Use| UsersModels
    UsersViews -->|Use| UsersForms
    UsersAdmin -->|Manage| UsersModels
    UsersBackends -->|Auth| UsersModels
    UsersMiddleware -->|Process| UsersRequests

    CoreTasks -->|Define| MailHTMLTask
    CoreTasks -->|Use| CoreModels
    MailHTMLTask -->|Send| Mailer
    MailHTMLTask -->|Queue| CeleryConfig
    CoreModels -->|Store| Postgres
    SMPP -->|Connect| JasminContainer
    Mailer -->|SMTP| SMTPServer
    SubmitLogService -->|Ingest| CoreTasks

    %% Django to Broker and DB
    Dispatcher -->|ORM| Postgres
    Dispatcher -->|Enqueue Task| Broker
    CeleryWorker -->|Fetch Task| Broker
    CeleryWorker -->|ORM| Postgres

    %% Docker Compose Orchestration
    Compose -->|Defines| Nginx
    Compose -->|Defines| Gunicorn
    Compose -->|Defines| CeleryWorker
    Compose -->|Defines| Postgres
    Compose -->|Defines| Broker
    Compose -->|Defines| JasminContainer
    Compose -->|Defines| SubmitLogService
    Compose -->|Defines| SMTPServer

    %% Click Events
    click WSGI "https://github.com/101t/jasmin-web-panel/blob/master/config/wsgi.py"
    click ASGI "https://github.com/101t/jasmin-web-panel/blob/master/config/asgi.py"
    click CeleryConfig "https://github.com/101t/jasmin-web-panel/blob/master/config/celery.py"
    click ProjectURLs "https://github.com/101t/jasmin-web-panel/blob/master/config/urls.py"
    click APIURLs "https://github.com/101t/jasmin-web-panel/blob/master/main/api/urls.py"
    click WebURLs "https://github.com/101t/jasmin-web-panel/blob/master/main/web/urls.py"
    click UsersURLs "https://github.com/101t/jasmin-web-panel/blob/master/main/users/urls.py"
    click WebViews "https://github.com/101t/jasmin-web-panel/tree/master/main/web/views/"
    click WebTemplates "https://github.com/101t/jasmin-web-panel/tree/master/main/web/templates/"
    click WebStatic "https://github.com/101t/jasmin-web-panel/tree/master/main/web/static/"
    click APIViews "https://github.com/101t/jasmin-web-panel/tree/master/main/api/views/"
    click APIFilters "https://github.com/101t/jasmin-web-panel/blob/master/main/api/views/filters.py"
    click UsersModels "https://github.com/101t/jasmin-web-panel/tree/master/main/users/models/"
    click UsersViews "https://github.com/101t/jasmin-web-panel/tree/master/main/users/views/"
    click UsersForms "https://github.com/101t/jasmin-web-panel/tree/master/main/users/forms/"
    click UsersAdmin "https://github.com/101t/jasmin-web-panel/tree/master/main/users/admin/"
    click UsersBackends "https://github.com/101t/jasmin-web-panel/tree/master/main/users/backends/"
    click UsersMiddleware "https://github.com/101t/jasmin-web-panel/blob/master/main/users/middleware.py"
    click CoreModels "https://github.com/101t/jasmin-web-panel/tree/master/main/core/models/"
    click SMPP "https://github.com/101t/jasmin-web-panel/tree/master/main/core/smpp/"
    click Mailer "https://github.com/101t/jasmin-web-panel/tree/master/main/core/mailer/"
    click MailSender "https://github.com/101t/jasmin-web-panel/blob/master/main/core/notify/mail_sender.py"
    click CoreTasks "https://github.com/101t/jasmin-web-panel/tree/master/main/core/tasks/"
    click MailHTMLTask "https://github.com/101t/jasmin-web-panel/blob/master/main/core/tasks/mail_html.py"
    click CoreAdmin "https://github.com/101t/jasmin-web-panel/tree/master/main/core/admin/"
    click ManagementCmds "https://github.com/101t/jasmin-web-panel/tree/master/main/core/management/commands/"
    click CoreUtils "https://github.com/101t/jasmin-web-panel/tree/master/main/core/utils/"
    click CoreTools "https://github.com/101t/jasmin-web-panel/blob/master/main/core/tools.py"
    click CoreCtx "https://github.com/101t/jasmin-web-panel/blob/master/main/core/context_processors.py"
    click CoreMiddleware "https://github.com/101t/jasmin-web-panel/blob/master/main/core/middleware.py"
    click SettingsCom "https://github.com/101t/jasmin-web-panel/blob/master/config/settings/com.py"
    click SettingsDev "https://github.com/101t/jasmin-web-panel/blob/master/config/settings/dev.py"
    click SettingsPro "https://github.com/101t/jasmin-web-panel/blob/master/config/settings/pro.py"
    click Routing "https://github.com/101t/jasmin-web-panel/blob/master/config/routing.py"
    click Version "https://github.com/101t/jasmin-web-panel/blob/master/config/version.py"
    click Compose "https://github.com/101t/jasmin-web-panel/blob/master/docker-compose.yml"
    click AlpineDockerfile "https://github.com/101t/jasmin-web-panel/tree/master/config/docker/alpine/Dockerfile"
    click ComposeAlpine "https://github.com/101t/jasmin-web-panel/blob/master/docker-compose-alpine.yml"
    click JasminCompose "https://github.com/101t/jasmin-web-panel/blob/master/config/docker/jasmin/docker-compose.yml"
    click JasminConfig "https://github.com/101t/jasmin-web-panel/tree/master/config/docker/jasmin/jasmin/config/"
    click SmsLoggerDockerfile "https://github.com/101t/jasmin-web-panel/tree/master/config/docker/sms_logger/Dockerfile"
    click SmsLoggerScript "https://github.com/101t/jasmin-web-panel/blob/master/sms_logger.py"
    click EntrypointSlim "https://github.com/101t/jasmin-web-panel/blob/master/config/docker/slim/docker-entrypoint.sh"
    click EntrypointCelery "https://github.com/101t/jasmin-web-panel/blob/master/docker-entrypoint-celery.sh"

    %% Styles
    classDef ui fill:#AEDFF7,stroke:#0288D1,color:#000
    classDef compute fill:#D5E8D4,stroke:#2E7D32,color:#000
    classDef datastore fill:#FFF2CC,stroke:#F9A825,color:#000
    classDef external fill:#E0E0E0,stroke:#616161,color:#000
```
