How u0nkis/assignhub works
Project Type and Purpose
• This is a full-stack web application built as a student assignment and code-judge platform (“Курсовая работа”).
• The frontend is a React/Vite single-page app; the backend is a Go monolith exposing REST APIs, handling user auth, assignments, submissions, and code judging; data is persisted in a relational database; metrics are collected via Prometheus.
File Structure Analysis
• Top-level:
• backend/: Go source organized by config, db access, handlers (assignment, auth, code, judge, submission, user), middleware (CORS, auth, rate–limit, security, metrics), models, utils, logger, main.go, Dockerfile.
• frontend/: React app with Vite build (src/, public/, dist/, Dockerfile).
• docker-compose.yaml: orchestrates backend, frontend, DB, Prometheus.
• init.sql: initial schema.
• prometheus/: config for scraping metrics.
• Architectural patterns:
• Layered backend (router → middleware → handlers → models → DB).
• RESTful API.
• Decoupled judge component invoked via handlers.
• Externalized metrics (Prometheus).
README Insights
• Minimal (“Курсовая работа”), so we infer architecture solely from code organization and build/deploy configs.
a. Main Components
1. Client (Web Browser)
2. Frontend SPA (React/Vite, TailwindCSS)
3. API Gateway / Backend (Go monolith)
4. Database (PostgreSQL)
5. Code Judge Engine (sandboxed process invoked by backend)
6. File Storage (local or mounted volume for submission files)
7. Monitoring (Prometheus)
8. Docker / Docker-Compose Orchestration
b. Relationships & Data Flows
• Browser ↔ Frontend (HTTP/HTTPS)
• Frontend → Backend REST API (JSON over HTTP)
• Backend ↔ DB (SQL)
• Backend → Code Judge Engine (spawned subprocess, pipes I/O, reads/writes to file storage)
• Backend → File Storage (upload/download submission files)
• Backend → Prometheus (expose /metrics endpoint)
• Prometheus → Backend (scrape metrics)
c. Architectural Patterns & Principles
• Layered separation: presentation (frontend), API layer, business logic (handlers), data access (models).
• Middleware pipeline for cross-cutting concerns (auth, CORS, rate limiting, logging, security, metrics).
• Single responsibility: each handler (assignment, submission, judge) encapsulates its domain.
• Containerization: each major component in its own Docker service.
d. Key Technologies
• Frontend: React, Vite, TailwindCSS, Axios
• Backend: Go, Gin or net/http, Docker
• Database: PostgreSQL (init.sql)
• Observability: Prometheus
• CI/CD: Docker-Compose