How makhlouf1102/lets-go works
Project Type & Purpose
• The project is a full-stack web application built in Go that appears to be aimed at providing an online problem-solving or coding challenge service (inspired by LeetCode).
• Its purpose is indicated by the README (“I am trash at leetcode so I made leetcode ...”), combined with the presence of code samples in multiple languages, problem and authentication handlers, and the integration with Docker for language-specific containers.
Analyzing the File Structure
• Top-level files like main.go show the Go application’s entry point.
• Directories such as “handlers” (with subdirectories for auth and problem) indicate the routing/controllers (or MVC controllers) that process HTTP requests.
• The “models” directory contains definitions for entities such as user, problem, role, and language; this forms the data layer.
• “libs” contains various supporting libraries including bcrypt for authentication, token handling, error handling, Docker client utilities, etc.
• “middlewares” (auth, logger, roleGuard) point to the cross-cutting concerns which intercept and manage requests.
• The “views” directory (with HTML templates) and “static” directory (with JavaScript files) establish a presentation layer.
• The “database” folder contains SQL scripts and a database file indicating the data persistence setup.
• “docker” directories include Dockerfiles for various language environments and shared resources, which suggest support for containerized execution or testing.
• Additional scripts (run.sh, test.sh, test-with-docker.sh) and CI/CD configurations (.github/workflows) provide operational context on running tests, building, and deploying.
Elements
a. Main Components:
– Client / Presentation Layer:
• Views (HTML templates in “views/templates”)
• Static assets (JavaScript files in “static”)
– Application Server:
• Entry point (main.go)
• HTTP routing and controllers (handlers for auth and problem)
• Middlewares (auth, logger, role guard)
– Business Logic & Services:
• Models (user, problem, role, language, user_role)
• Supporting libraries for common functions, error handling, token processing, and environment configuration
– Container Management:
• Docker-related libraries (libs/dockerClient, libs/dockerController) for container orchestration—likely to run code in isolated environments.
• Data Persistence:
– Database layer (SQLite file “database-test.db”, build and production SQL scripts)
• Code Samples / Language Support:
– Code sample directories to hold example problem implementations for languages like Go, JavaScript, and Python.
– DevOps & CI/CD:
– Docker files (in “docker”) and GitHub workflows (CI configuration) for automated builds and testing.
b. Relationships & Interactions:
• The client layer sends HTTP requests to endpoints managed by the handlers.
• Handlers invoke business logic by interacting with models and libraries.
• Middleware intercepts requests to perform authentication, logging, and role-based access.
• The application interacts with the database via models (possibly using SQL scripts for initialization and testing).
• For code execution/sandboxing, parts of the system use Docker libraries to manage containerized language runtimes.
• Code samples show integration/testing examples across different languages.
c. Architectural Patterns & Design Principles:
• Layered Architecture: Separation of presentation, application, and data layers is evident.
• MVC / Handler-based Pattern: Clear division between routes/controllers (handlers) and models.
• Modular Design: Libraries (libs) and middlewares are split into functional areas (authentication, token processing, logging, Docker operations, etc.).
d. Relevant Technologies and Frameworks:
• Go (Golang) as the primary language.
• Docker for containerized execution (managed through custom DockerClient and DockerController libraries).
• Likely an SQLite database (given the test.db file) or similar SQL-based persistence.
• Authentication and password encryption via bcrypt.
• HTML templates and JavaScript for view rendering.