# raflibangsawan/sipeta-api-dev architecture

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

- Interactive diagram: https://gitdiagram.com/raflibangsawan/sipeta-api-dev
- Repository: https://github.com/raflibangsawan/sipeta-api-dev

## Overview

##### Main Components
- Client Layer: Show external clients (web browsers, API clients, mobile apps) that connect over HTTP/HTTPS.
- Web Server / Reverse Proxy: In production one would typically have a reverse proxy (like Nginx) to handle incoming requests and static assets though this might not be explicitly in the file tree. It may be noted as a “deployment artifact.”
- Application Server: Represent the Django application. Highlight the “config” folder (which holds URL routing, settings across various environments, and the WSGI entry point) as the core entry point for request handling.
- Django Apps: Break down the monolithic backend into its modular apps (users, proposal, semester, topik, pengumuman, etc.). Each of these can be visualized as individual components handling specific domain logic.
- Database Layer: Indicate a PostgreSQL database (as referenced by the instructions for starting a PostgreSQL server) that stores all the persistent data.
- Caching Layer: Include a cache system if applicable (as indicated by the “create cache table” command). Use a component for the caching mechanism.
- Utility & Configuration Services: Represent the utility scripts (for installing OS and Python dependencies) and settings management (with separate configurations for local, production, and test).

##### Specify Relationships and Interactions
- From the entry point, show the URL router (from “config/urls.py” and “config/api_router.py”) directing requests to various Django apps.
- For each Django app (e.g., “users”, “proposal”, etc.), indicate the internal MVC flow – the view layer processing the HTTP requests, models interacting with the database, and serializers/forms used for data validation and representation.
- Optionally, illustrate that static assets (from “sipeta_backend/static” and “templates”) are served either through Django in development or via a dedicated static server/load balancer in production.

##### Important Architectural Patterns
- Django’s MVC/MVT pattern where routing (URLs), business logic (views), and data access (models) are distinct.
- Point out the modular decomposition of the application into multiple self-contained apps. This separation of concerns aids maintainability and scalability.
- Mention the use of environment-specific settings stored in “config/settings” (Base, Local, Production, Test), which shows adherence to the principle of configuration decoupling.
- That pre-commit hooks, linting (using pylint and black), type checks (with mypy), and tests (pytest and coverage) are part of the development process but are not actively part of the runtime architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client and Deployment Layers
    Client["External Clients"]:::client
    ReverseProxy["Reverse Proxy (Nginx)"]:::reverse

    Client -->|"HTTP/HTTPS"| ReverseProxy

    %% Application Layer - Django Core
    DjangoEntry["Django Entry Point"]:::entry
    ReverseProxy -->|"forwards requests"| DjangoEntry

    %% Django Core Configuration
    Routing["URL Routing (config/urls.py, api_router.py)"]:::config
    Settings["Settings (config/settings/)"]:::config

    DjangoEntry -->|"initializes"| Routing
    DjangoEntry -->|"loads"| Settings

    %% Django Apps Cluster
    subgraph "Django Apps"
        UsersApp["Users App"]:::app
        ProposalApp["Proposal App"]:::app
        SemesterApp["Semester App"]:::app
        TopikApp["Topik App"]:::app
        PengumumanApp["Pengumuman App"]:::app
    end

    Routing -->|"routes to"| UsersApp
    Routing -->|"routes to"| ProposalApp
    Routing -->|"routes to"| SemesterApp
    Routing -->|"routes to"| TopikApp
    Routing -->|"routes to"| PengumumanApp

    %% External Dependencies: Database and Cache
    Database["PostgreSQL Database"]:::db
    Cache["Cache System"]:::cache

    UsersApp -->|"ORM operations"| Database
    ProposalApp -->|"ORM operations"| Database
    SemesterApp -->|"ORM operations"| Database
    TopikApp -->|"ORM operations"| Database
    PengumumanApp -->|"ORM operations"| Database

    UsersApp -->|"caches data"| Cache
    ProposalApp -->|"caches data"| Cache
    SemesterApp -->|"caches data"| Cache
    TopikApp -->|"caches data"| Cache
    PengumumanApp -->|"caches data"| Cache

    %% Utility Scripts for dependencies
    Utility["Utility Scripts"]:::utility
    DjangoEntry ---|"dependency setup"| Utility

    %% Static Assets for serving static files and templates
    StaticAssets["Static & Template Assets"]:::static
    ReverseProxy ---|"serves static"| StaticAssets

    %% Legend (optional, can be hidden if not needed)
    %% classDef client fill:#f9e79f,stroke:#7d6608,stroke-width:2px;
    %% classDef reverse fill:#aed6f1,stroke:#1b4f72,stroke-width:2px;
    %% classDef entry fill:#a9dfbf,stroke:#196f3d,stroke-width:2px;
    %% classDef config fill:#f5cba7,stroke:#7e5109,stroke-width:2px;
    %% classDef app fill:#d7bde2,stroke:#6c3483,stroke-width:2px;
    %% classDef db fill:#d1f2eb,stroke:#117864,stroke-width:2px,stroke-dasharray: 5 5;
    %% classDef cache fill:#fcf3cf,stroke:#7d6608,stroke-width:2px,stroke-dasharray: 5 5;
    %% classDef utility fill:#fadbd8,stroke:#922b21,stroke-width:2px;
    %% classDef static fill:#d6eaf8,stroke:#2874a6,stroke-width:2px;

    %% Click Events for Component Mapping
    click DjangoEntry "https://github.com/raflibangsawan/sipeta-api-dev/blob/master/config/wsgi.py"
    click Routing "https://github.com/raflibangsawan/sipeta-api-dev/blob/master/config/urls.py"
    click Settings "https://github.com/raflibangsawan/sipeta-api-dev/tree/master/config/settings/"
    click PengumumanApp "https://github.com/raflibangsawan/sipeta-api-dev/tree/master/sipeta_backend/pengumuman/"
    click ProposalApp "https://github.com/raflibangsawan/sipeta-api-dev/tree/master/sipeta_backend/proposal/"
    click SemesterApp "https://github.com/raflibangsawan/sipeta-api-dev/tree/master/sipeta_backend/semester/"
    click TopikApp "https://github.com/raflibangsawan/sipeta-api-dev/tree/master/sipeta_backend/topik/"
    click UsersApp "https://github.com/raflibangsawan/sipeta-api-dev/tree/master/sipeta_backend/users/"
    click Utility "https://github.com/raflibangsawan/sipeta-api-dev/tree/master/utility/"
    click StaticAssets "https://github.com/raflibangsawan/sipeta-api-dev/tree/master/sipeta_backend/static/"

    %% Style Definitions
    classDef client fill:#f9e79f,stroke:#7d6608,stroke-width:2px;
    classDef reverse fill:#aed6f1,stroke:#1b4f72,stroke-width:2px;
    classDef entry fill:#a9dfbf,stroke:#196f3d,stroke-width:2px;
    classDef config fill:#f5cba7,stroke:#7e5109,stroke-width:2px;
    classDef app fill:#d7bde2,stroke:#6c3483,stroke-width:2px;
    classDef db fill:#d1f2eb,stroke:#117864,stroke-width:2px,stroke-dasharray: 5,5;
    classDef cache fill:#fcf3cf,stroke:#7d6608,stroke-width:2px,stroke-dasharray: 5,5;
    classDef utility fill:#fadbd8,stroke:#922b21,stroke-width:2px;
    classDef static fill:#d6eaf8,stroke:#2874a6,stroke-width:2px;
```
