How ishaannene/algorank works
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.