# divi-1910/codellosium architecture

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

- Interactive diagram: https://gitdiagram.com/divi-1910/codellosium
- Repository: https://github.com/divi-1910/codellosium

## Overview

##### Project Type and Purpose
- This project is a full-stack, microservices-based application organized as a monorepo (using Turbo via turbo.json) that includes multiple backend services, a frontend client, shared packages, and database models.
- The application is composed of an API Gateway, several domain-specific services (auth, notification, problem, submission, worker), and a client interface, each built likely in Node.js, with containerization using Docker and configuration files for orchestration.

##### Analyzing the File Structure
- Top-Level Directories:
- apps: Holds all microservices and the frontend client.
▪ api-gateway: Likely serves as a reverse proxy routing client requests to appropriate backend services.
▪ auth-service: Manages authentication/authorization.
▪ notification-service: Handles sending notifications (also includes websockets for real-time communication).
▪ problem-service: Manages problem related functions (possibly coding problems/challenges).
▪ submission-service: Processes submissions with additional queues and middleware.
▪ worker-service: Executes tasks asynchronously (including code execution, Docker management, and job processing).
▪ client: The frontend files using components, hooks, and a state store for user interactions.
- packages: Contains shared code such as database models (Problem, Submission, User), linting and TypeScript configuration, and a UI package.
- There are additional configuration files (docker-compose.yml, container.json, spec.yaml) for deployment orchestration.

- Architectural Patterns Indicated:
- Microservices Architecture: Each service is isolated within its own directory with independent controllers, routes, middleware, and configuration.
- API Gateway Pattern: Separating client-facing APIs (api-gateway) from backend service logic.
- Containerization: Dockerfiles for multiple services and a docker-compose file indicate container orchestration.
- Shared Libraries/Packages: The “packages” directory shows usage of common modules across services (e.g., database models, eslint, TypeScript, UI components).

- Align the backend microservices (Auth, Notification, Problem, Submission, Worker) in a row or grid, indicating their individual roles.
- Microservice to the central Database component.
- Annotations or notes about middleware components (such as rate-limiters, authentication middleware) at the API gateway and within services as necessary.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        A["Client (Frontend)"]:::client
    end

    %% API Gateway Layer
    subgraph "API Layer"
        B["API Gateway"]:::apigateway
    end

    %% Backend Microservices
    subgraph "Backend Services"
        C["Auth Service"]:::service
        D["Notification Service (Websockets)"]:::service
        E["Problem Service"]:::service
        F["Submission Service (Queue)"]:::service
        G["Worker Service"]:::service
    end

    %% Shared Infrastructure
    subgraph "Shared Infrastructure"
        H["Database (Shared Models)"]:::db
        I["Shared ESLint Configuration"]:::config
        J["Shared TypeScript Configuration"]:::config
        K["Shared UI Components"]:::config
    end

    %% Deployment Orchestration
    subgraph "Deployment"
        L["Docker Compose Container"]:::docker
    end

    %% Interactions
    A -->|"calls"| B

    B -->|"routes"| C
    B -->|"routes"| D
    B -->|"routes"| E
    B -->|"routes"| F
    B -->|"routes"| G

    %% Service to Database interactions
    C -->|"reads/writes"| H
    D -->|"reads/writes"| H
    E -->|"reads/writes"| H
    F -->|"reads/writes"| H
    G -->|"reads/writes"| H

    %% Internal Service Interactions
    F -->|"queuesJob"| G
    D -->|"sendsAlert"| A

    %% Container Deployment connections
    B --- L
    C --- L
    D --- L
    E --- L
    F --- L
    G --- L

    %% Click Events
    click A "https://github.com/divi-1910/codellosium/tree/main/apps/client"
    click B "https://github.com/divi-1910/codellosium/tree/main/apps/api-gateway"
    click C "https://github.com/divi-1910/codellosium/tree/main/apps/auth-service"
    click D "https://github.com/divi-1910/codellosium/tree/main/apps/notification-service"
    click E "https://github.com/divi-1910/codellosium/tree/main/apps/problem-service"
    click F "https://github.com/divi-1910/codellosium/tree/main/apps/submission-service"
    click G "https://github.com/divi-1910/codellosium/tree/main/apps/worker-service"
    click H "https://github.com/divi-1910/codellosium/tree/main/packages/db"
    click I "https://github.com/divi-1910/codellosium/tree/main/packages/eslint-config"
    click J "https://github.com/divi-1910/codellosium/tree/main/packages/typescript-config"
    click K "https://github.com/divi-1910/codellosium/tree/main/packages/ui"

    %% Styles
    classDef client fill:#AED6F1,stroke:#154360,stroke-width:2px;
    classDef apigateway fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef service fill:#A9DFBF,stroke:#1E8449,stroke-width:2px;
    classDef db fill:#F5B7B1,stroke:#922B21,stroke-width:2px,stroke-dasharray: 5,5;
    classDef config fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef docker fill:#FAD7A0,stroke:#D35400,stroke-width:2px,stroke-dasharray: 3,3;
```
