# ishaannene/algorank architecture

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

- Interactive diagram: https://gitdiagram.com/ishaannene/algorank
- Repository: https://github.com/ishaannene/algorank

## Overview

##### Project Overview & Components
- The project is a platform for practicing algorithmic problems with support for multiple programming languages. It is built as a containerized, microservices-style application.
- The four primary components are:
- Frontend: The user interface that provides an interactive code editor (built with web technologies – the README states Angular, but the file tree indicates a React/Vite setup; it is advisable to verify which framework is currently in use).
- Backend: A Go-based API server that manages problem data, user interactions, authentication, and business logic.
- Executor: A Python FastAPI service that securely executes user-submitted code in a sandboxed environment.
- Database: A PostgreSQL database (as specified in the README) used for data persistence (with initialization scripts like BackEnd/init.sql).

##### Detailed File Structure & Architectural Insights
- FrontEnd Directory:
- Contains source files under src (pages, components, hooks, context, types, etc.) for the web client.
- Configuration files like vite.config.ts, tsconfig.json imply a modern TypeScript setup.
- Dockerfile, .env, and other configuration files indicate containerized deployment.
- BackEnd Directory:
- Organized into directories like api, config, db, handlers, models, and utils.
- Files (such as main.go, Dockerfile, go.mod, and init.sql) represent the building blocks of a Go API that handles incoming requests, authentication, problem management, and database interactions.
- Executor Directory:
- Contains Python scripts (main.py, code_runner.py) and its own Dockerfile, which together implement the secure code execution service.
- Docker & Deployment:
- At the root level, there are Docker Compose files (docker-compose.yml) and Makefile commands that indicate a containerized deployment with orchestration of all services.
- Solutions Directory:
- Stores user solutions across multiple languages, serving as sample submissions that could be used for testing or demo purposes.

##### Relationships & Data Flow
- Frontend <-> Backend:
- The web client sends HTTP requests (REST API calls) to the Go backend for actions like logging in, problem retrieval, and submission handling.
- Backend <-> Executor:
- The backend communicates with the Executor service to send user code for execution and to receive performance metrics (execution time, memory, CPU usage).
- Backend <-> Database:
- The API server performs database CRUD operations, using SQL scripts (e.g., init.sql) to manage underlying PostgreSQL data.
- Containerization & Service Communication:
- All components are containerized (as seen by individual Dockerfiles for each service) and orchestrated using Docker Compose to ensure they run in harmony.

##### Architectural Patterns & Design Principles
- Microservices Architecture:
- Separation of concerns is achieved by isolating the frontend, backend, executor, and database services.
- Containerization:
- Dockerfiles and Docker Compose ensure that services are portable and isolated.
- API-Driven Communication:
- Clear RESTful or HTTP-based interactions between the frontend, backend, and executor.
- Scalability and Security Consideration:
- The dedicated Executor service handles code execution in a secure, sandboxed environment that can be scaled independently if needed.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Deployment["Containerized Deployment<br/>(Docker Compose & Makefile)"]:::orchestration
    FE["Frontend (React/Vite or Angular)"]:::frontend
    BE["Backend (Go)"]:::backend
    EX["Executor (Python FastAPI)"]:::executor
    DB["Database (PostgreSQL)"]:::database
    SOL["Solutions (Sample Submissions)"]:::solutions

    Deployment --> FE
    Deployment --> BE
    Deployment --> EX
    Deployment --> DB
    Deployment --> SOL

    FE -->|"HTTP_API_Calls"| BE
    BE -->|"Execute_Code_Request"| EX
    BE -->|"CRUD_Operations"| DB

    click FE "https://github.com/ishaannene/algorank/tree/main/FrontEnd/"
    click BE "https://github.com/ishaannene/algorank/tree/main/BackEnd/"
    click EX "https://github.com/ishaannene/algorank/tree/main/Executor/"
    click DB "https://github.com/ishaannene/algorank/blob/main/BackEnd/init.sql"
    click SOL "https://github.com/ishaannene/algorank/tree/main/Solutions/"

    classDef orchestration fill:#ffe6cc,stroke:#b38600,stroke-width:2px;
    classDef frontend fill:#cce5ff,stroke:#5bc0de,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#28a745,stroke-width:2px;
    classDef executor fill:#f8d7da,stroke:#dc3545,stroke-width:2px;
    classDef database fill:#fef9c3,stroke:#ffc107,stroke-width:2px;
    classDef solutions fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
```
