# rakaiskandar/sobat-hukum-be architecture

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

- Interactive diagram: https://gitdiagram.com/rakaiskandar/sobat-hukum-be
- Repository: https://github.com/rakaiskandar/sobat-hukum-be

## Overview

##### Main Components
- Django Configuration/Router: Represent the “config” module that includes the primary routing setup (in “urls.py”) and the server interface via WSGI/ASGI.
- API Modules: Break out the distinct Django apps:
– Cases: Responsible for case management, with dedicated models, serializers, views, and migrations.
– Chat: Designed for conversation functionalities, using both HTTP views and asynchronous consumers (as indicated by “consumers.py”).
– Documents: Handling document-related data.
– Users: Managing user-related information and authentication.
- Shared/Common Utilities: The “api/common” directory covers shared fields, permissions, and utility functions that are used across the apps.
- Database Layer: Represent the database that Django interacts with via its ORM. This includes tables/migrations for each app.

##### Relationships and Interactions
- How incoming HTTP requests are routed by the URLs configured in the “config/urls.py” into the appropriate Django app (cases, chat, documents, users).
- Within each app, display the flow: URL -> View -> Serializer (for parsing/validating data) -> Model -> Database.
- In the “chat” module, specifically indicate a branch for asynchronous communication (websocket consumer) and its interaction with the same data storage.
- Utility or common modules that are referenced by multiple apps. These should be drawn as supporting components that inject shared logic across other components.

##### Key Architectural Patterns and Technologies
- MVC/MVT pattern: Even though Django uses the Model-View-Template paradigm, note that the “views” and “serializers” serve as intermediate layers between models and client responses.
- Asynchronous Communication: Specifically note the “chat” module’s use of consumers for handling real-time messaging.
- Configuration and Dependency Management: Highlight the existence of configuration controls (i.e., “config/settings.py”, environment variables managed via the provided “.env.example”, and dependency management via “requirements.txt”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client("External Client (HTTP/WS)"):::client

    subgraph "Configuration & Routing"
        URLs("URLs (config/urls.py)"):::config
        ASGI("ASGI (config/asgi.py)"):::config
        WSGI("WSGI (config/wsgi.py)"):::config
    end

    Client --> URLs
    Client --> ASGI
    Client --> WSGI

    Cases("Cases Module"):::module
    Chat("Chat Module"):::module
    Documents("Documents Module"):::module
    Users("Users Module"):::module

    URLs --> Cases
    URLs --> Chat
    URLs --> Documents
    URLs --> Users
    ASGI --> Chat
    WSGI --> Cases
    WSGI --> Documents
    WSGI --> Users

    ChatAsync("Async Consumer (consumers.py)"):::async
    Chat --> ChatAsync

    Common("Common Utilities"):::common
    Common --- Cases
    Common --- Chat
    Common --- Documents
    Common --- Users

    Database("Database"):::db
    Cases -->|"Model_Save/Query"| Database
    Chat -->|"Model_Save/Query"| Database
    Documents -->|"Model_Save/Query"| Database
    Users -->|"Model_Save/Query"| Database
    ChatAsync -->|"Async_Update"| Database

    click URLs "https://github.com/rakaiskandar/sobat-hukum-be/blob/master/config/urls.py"
    click ASGI "https://github.com/rakaiskandar/sobat-hukum-be/blob/master/config/asgi.py"
    click WSGI "https://github.com/rakaiskandar/sobat-hukum-be/blob/master/config/wsgi.py"
    click Cases "https://github.com/rakaiskandar/sobat-hukum-be/tree/master/api/cases/"
    click Chat "https://github.com/rakaiskandar/sobat-hukum-be/tree/master/api/chat/"
    click Documents "https://github.com/rakaiskandar/sobat-hukum-be/tree/master/api/documents/"
    click Users "https://github.com/rakaiskandar/sobat-hukum-be/tree/master/api/users/"
    click Common "https://github.com/rakaiskandar/sobat-hukum-be/tree/master/api/common/"

    classDef client fill:#d1e8ff,stroke:#333,stroke-width:2px;
    classDef config fill:#fef3bd,stroke:#333,stroke-width:2px;
    classDef module fill:#c8e6c9,stroke:#333,stroke-width:2px;
    classDef async fill:#dcedc8,stroke:#333,stroke-width:2px;
    classDef common fill:#fce4ec,stroke:#333,stroke-width:2px;
    classDef db fill:#ffe0b2,stroke:#333,stroke-width:2px;
```
