# webclub-nitk/atlas architecture

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

- Interactive diagram: https://gitdiagram.com/webclub-nitk/atlas
- Repository: https://github.com/webclub-nitk/atlas

## Overview

##### Main Components
- Frontend Client:
- Represented by the “frontend” folder. It includes React components, layouts, pages (both public and admin/user), API service modules, and a Vite configuration.
- This part handles user interactions, rendering challenges, authentication pages, and admin interfaces.
- Backend Application:
- Inside the “backend” directory, notice two sub-folders. One contains the Django app (atlas_backend) that defines models, views, serializers, and migrations. The other contains project-level settings (Django’s settings, asgi, wsgi).
- This is responsible for business logic, REST APIs, authentication, and challenge management.
- Database:
- While not explicitly defined in the file tree, the README and environment variables (DB_USER, DB_PASSWORD, DB_NAME) indicate the use of a relational database (likely PostgreSQL) that stores persistent data (users, challenges, teams, etc.).
- Docker Orchestration / Challenge Containers:
- The project uses Docker for running both the backend and the frontend. Additionally, files like “challenge.Dockerfile”, “docker-compose.yml”, and “docker_plugin.py” indicate there’s dynamic management of separate challenge environments inside containers.
- This component manages spinning up and tearing down containers that host individual CTF challenges.

##### Relationships and Interactions
- The Frontend communicates with the Backend via HTTP API calls (see all the API modules inside “frontend/src/api”).
- The Backend interacts with the Database (via Django ORM) to retrieve and store data such as challenges, user profiles, scores, etc.
- When a challenge is triggered or needs to run, the Backend leverages Docker APIs (as suggested by docker_plugin.py and assorted Dockerfiles) to orchestrate challenge containers.
- An admin route in the Frontend is available to manage challenges, teams, and users, interfacing with the backend’s admin panel.

##### Architectural Patterns and Principles
- Separation of Concerns:
- Clear splitting between frontend and backend services.
- MVC (or similar) in the Backend:
- Django’s organization in “atlas_backend” (models, views, serializers) indicates a classic separation of controllers, views, and models.
- Containerization:
- Extensive use of Docker for deployment, local development (with docker-compose) and dynamic container management for challenge execution.
- API-Driven Communication:
- The frontend uses a well-organized API layer (e.g., admin.js, auth.js, challenges.js, etc.) to communicate with the backend services.

##### Incorporate Relevant Technologies and Tools
- Frontend: React, Vite, TailwindCSS, and possibly ESLint for code quality.
- Backend: Django (with RESTful APIs), Docker for container orchestration, and PostgreSQL (or another relational DB as suggested by the env variables).
- Docker & Deployment: Dockerfiles, docker-compose, and scripts like “entrypoint.sh” to manage service startup.
- Additional Libraries: Provided coding style guidelines denote Python docstrings and comments, meaning code documentation is an important part of the implementation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend (React/Vite)"
        F1["Frontend Client (React/Vite)"]:::frontend
        F2["API Service Modules"]:::frontend
        F3["React Components"]:::frontend
        F4["Frontend Pages"]:::frontend
    end

    subgraph "Backend (Django)"
        B1["Django App"]:::backend
        B2["Project Settings"]:::backend
    end

    DB["PostgreSQL Database"]:::database

    subgraph "Docker Orchestration"
        D0["Docker Orchestrator"]:::docker
        D1["Challenge Dockerfile"]:::docker
        D2["Backend Dockerfile"]:::docker
        D3["Frontend Dockerfile"]:::docker
        D4["docker-compose.yml"]:::docker
        D5["entrypoint.sh"]:::docker
        D6["docker_plugin.py"]:::docker
    end

    %% Internal Frontend composition
    F1 --> F2
    F1 --> F3
    F1 --> F4

    %% Main interactions
    F1 -->|"HTTP_API"| B1
    B1 -->|"DB_queries"| DB
    B1 -->|"Container_management"| D0

    %% Docker Orchestrator configuration
    D0 --> D1
    D0 --> D2
    D0 --> D3
    D0 --> D4
    D0 --> D5
    D0 --> D6

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef database fill:#d4edda,stroke:#155724,stroke-width:2px,stroke-dasharray:5,5;
    classDef docker fill:#fff3cd,stroke:#856404,stroke-width:2px;

    %% Click Events for Frontend Components
    click F1 "https://github.com/webclub-nitk/atlas/tree/main/frontend/"
    click F2 "https://github.com/webclub-nitk/atlas/tree/main/frontend/src/api/"
    click F3 "https://github.com/webclub-nitk/atlas/tree/main/frontend/src/components/"
    click F4 "https://github.com/webclub-nitk/atlas/tree/main/frontend/src/pages/"

    %% Click Events for Backend Components
    click B1 "https://github.com/webclub-nitk/atlas/tree/main/backend/atlas_backend/"
    click B2 "https://github.com/webclub-nitk/atlas/tree/main/backend/backend/"

    %% Click Events for Docker Orchestration Components
    click D1 "https://github.com/webclub-nitk/atlas/blob/main/challenge.Dockerfile"
    click D2 "https://github.com/webclub-nitk/atlas/tree/main/backend/Dockerfile"
    click D3 "https://github.com/webclub-nitk/atlas/tree/main/frontend/Dockerfile"
    click D4 "https://github.com/webclub-nitk/atlas/blob/main/docker-compose.yml"
    click D5 "https://github.com/webclub-nitk/atlas/blob/main/backend/code/entrypoint.sh"
    click D6 "https://github.com/webclub-nitk/atlas/blob/main/backend/docker_plugin.py"
```
