# thehopetechteam/conf-webapi architecture

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

- Interactive diagram: https://gitdiagram.com/thehopetechteam/conf-webapi
- Repository: https://github.com/thehopetechteam/conf-webapi

## Overview

##### Main Components
- Django Web Server & Application Core: The main entry point is manage.py with the configuration files (e.g., portal/config.py, configurations for dev and production), WSGI/asgi files (portal/wsgi.py, portal/asgi.py) and the Gunicorn configuration (gunicorn_conf.py). This represents the core of the backend.
- Modular Django Apps: Under portal/apps, you have multiple apps such as:
- Account: Handles user accounts and authentication with its own models, views, admin, and management commands.
- Conference: Manages conference-related functionalities.
- Event_Info, FAQ, FCM_Device, Feedback, Home, Instructor, Language, Location, Notification, Search, Testimony, Ticket, Workshop: Each of these represent a specific domain with their models, migrations, views, and even custom integrations (like wagtail_hooks in some apps for Wagtail CMS integration).
- Request Routing and API Layers: The project contains clear routing through portal/urls.py and separated API endpoints under portal/routers/apis/v1. This layer maps incoming HTTP requests to the appropriate handlers.
- Middleware and Handlers: Custom middlewares (in portal/middlewares) intercept and process requests (e.g., custom HTTP handling) and domain-specific business logic is defined in portal/handlers (for account management, conference logic, feedback, etc.).
- Libraries and Shared Utilities: There are shared libraries (portal/libs) covering authentication, logging, context management, database connections (including an asynchronous redis client), and utility functions that support cross-cutting concerns.
- External Integrations: The providers directory, for example with Firebase integrations, signals external service communication. Additionally, the project uses Docker for containerization (Dockerfile) and has CI/CD workflows configured in .github/workflows.

##### Relationships and Data Flow
- Incoming HTTP requests (from client apps or a front-end) are received by the Django server running via Gunicorn or another WSGI/ASGI server.
- Requests pass through a series of middlewares (portal/middlewares) which may perform tasks such as authentication, logging, or custom request handling.
- The Django URL router (portal/urls.py along with portal/routers) then dispatches the requests to the appropriate Django app’s views.
- Inside each Django app, views interact with models and, where applicable, invoke custom handlers (in portal/handlers) to process business logic.
- After processing, responses are serialized (using serializers in portal/serializers) and sent back to the client.
- Database operations are coordinated through Django’s ORM with migrations maintained per app.
- External system integrations (such as Firebase authentication and notifications) are managed within the providers and libs directories.

##### Architectural Patterns and Design Principles
- Modular Architecture: Each domain area (account, conference, ticket, etc.) is separated into its own Django app. This separation encourages maintainability and clarity.
- Layered Design: The project clearly distinguishes between routing (urls/routers), business logic (views/handlers), data access (models/migrations), and auxiliary services (media, static files, utilities in libs).
- Extensibility: The existence of directories for plugins (wagtail_hooks in several apps) and extra modular libraries indicates that the system was designed with extensibility in mind.
- Configuration Management & CI/CD: Distinct configuration files for different environments (portal/configs) and automation scripts (GitHub workflows, Dockerfile) ensure smooth deployment pipelines.

##### Suggested Components
- Client/External Requests: Frontend web/mobile which makes API calls.
- Web Server: Gunicorn (using the entrypoint script and managing via Docker).
- Django Framework Core: Represented by manage.py, configuration files, and WSGI/ASGI handlers.
- Middleware Layer: Custom middlewares handling HTTP requests.
- API & Routing Layer: Including URL routers (portal/urls.py, portal/routers/apis/v1) dispatching requests.
- Shared Libs and Utilities: Common libraries (authentication, logging, shared utilities) that support multiple apps.
- External Services: Firebase integration (under portal/providers/firebase), caching (aio_redis in portal/libs/database), and any additional third-party services.
- CI/CD and Deployment Infrastructure: Dockerfile, GitHub Actions workflows.
- Data Storage: Implicit database layer (managed by Django ORM and migrations).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend / Client
    subgraph "Frontend / Client"
        Client("Client Requests"):::external
    end

    %% Infrastructure
    subgraph "Infrastructure"
        Gunicorn("Gunicorn Server (Docker)"):::infra
    end

    %% Django Web Server & Application Core
    subgraph "Django Web Server & Application Core"
        ManagePY("manage.py"):::core
        Config("portal/config.py"):::core
        WSGI("portal/wsgi.py"):::core
        ASGI("portal/asgi.py"):::core
        GunicornConf("gunicorn_conf.py"):::core
    end

    %% Routing & Processing Layer
    subgraph "Routing & Processing"
        Middlewares("Portal Middlewares"):::processing
        URLRouter("URL Router (portal/urls.py)"):::processing
        APIEndpoints("API Endpoints (portal/routers/apis/v1)"):::processing
        Handlers("Custom Handlers (portal/handlers)"):::processing
    end

    %% Modular Django Apps
    subgraph "Modular Django Apps"
        Apps("Modular Apps (portal/apps)"):::apps
        Account("Account App"):::apps
        Conference("Conference App"):::apps
        OtherApps("Other Django Apps"):::apps
    end

    %% Shared Utilities & Libraries
    subgraph "Shared Utilities & Libraries"
        SharedLibs("Shared Libs (portal/libs)"):::utilities
    end

    %% External Services & CI/CD
    subgraph "External Services & CI/CD"
        Firebase("Firebase Provider"):::external
        Dockerfile("Dockerfile"):::infra
        CICD("CI/CD Pipelines (.github/workflows)"):::infra
    end

    %% Connections
    Client --> Gunicorn
    Gunicorn --> ManagePY
    ManagePY --> Middlewares
    Middlewares --> URLRouter
    URLRouter --> APIEndpoints
    APIEndpoints --> Account
    APIEndpoints --> Conference
    APIEndpoints --> OtherApps
    Account --> Handlers
    Conference --> Handlers
    OtherApps --> Handlers
    Handlers --> SharedLibs
    SharedLibs --> Account
    SharedLibs --> Conference
    SharedLibs --> OtherApps
    %% External integrations connection from core to external service
    ManagePY --> Firebase
    %% Deployment connections
    Gunicorn --> Dockerfile
    Dockerfile --> CICD

    %% Click Events for Core Components
    click ManagePY "https://github.com/thehopetechteam/conf-webapi/blob/main/manage.py"
    click Config "https://github.com/thehopetechteam/conf-webapi/blob/main/portal/config.py"
    click WSGI "https://github.com/thehopetechteam/conf-webapi/blob/main/portal/wsgi.py"
    click ASGI "https://github.com/thehopetechteam/conf-webapi/blob/main/portal/asgi.py"
    click GunicornConf "https://github.com/thehopetechteam/conf-webapi/blob/main/gunicorn_conf.py"

    %% Click Event for Modular Apps Directory
    click Apps "https://github.com/thehopetechteam/conf-webapi/tree/main/portal/apps/"

    %% Click Events for Routing and API Layers
    click URLRouter "https://github.com/thehopetechteam/conf-webapi/blob/main/portal/urls.py"
    click APIEndpoints "https://github.com/thehopetechteam/conf-webapi/tree/main/portal/routers/apis/v1/"

    %% Click Events for Middleware and Handlers
    click Middlewares "https://github.com/thehopetechteam/conf-webapi/tree/main/portal/middlewares/"
    click Handlers "https://github.com/thehopetechteam/conf-webapi/tree/main/portal/handlers/"

    %% Click Event for Shared Utilities
    click SharedLibs "https://github.com/thehopetechteam/conf-webapi/tree/main/portal/libs/"

    %% Click Event for External Integrations
    click Firebase "https://github.com/thehopetechteam/conf-webapi/tree/main/portal/providers/firebase/"

    %% Click Events for CI/CD and Deployment
    click Dockerfile "https://github.com/thehopetechteam/conf-webapi/tree/main/Dockerfile"
    click CICD "https://github.com/thehopetechteam/conf-webapi/tree/main/.github/workflows/"

    %% Class Definitions for Colors and Styling
    classDef external fill:#FFA07A,stroke:#FF4500,stroke-width:2px;
    classDef infra fill:#B0E0E6,stroke:#5F9EA0,stroke-width:2px;
    classDef core fill:#98FB98,stroke:#2E8B57,stroke-width:2px;
    classDef processing fill:#FFD700,stroke:#DAA520,stroke-width:2px;
    classDef apps fill:#E6E6FA,stroke:#9370DB,stroke-width:2px;
    classDef utilities fill:#F5DEB3,stroke:#D2B48C,stroke-width:2px;
```
