How freecodecamp/exam-services works
Project type and purpose
• From the README and file tree, this is a small, single-service moderation microservice written in Rust. It’s part of a larger “Exam Services” suite, responsible for moderating exam attempts. It uses Prisma (Rust client) to talk to a relational database, and is deployed via Docker Compose on a DigitalOcean droplet. A cron job periodically triggers moderation tasks.
File structure
• Top-level
• .github/workflows/deploy.yaml → CI/CD pipeline
• docker-compose.yml → local and production service orchestration
• cron.staging & cron.production → host crontab entries
• moderation-service/ → main Rust microservice
• prisma/ → shared Rust library for Prisma client (DB access)
• moderation-service/
• src/main.rs → entry point
• src/lib.rs → core moderation logic
• src/db.rs → low-level database operations
• src/config.rs → env-based configuration
• src/attempt.rs → domain model for exam attempts
• Dockerfile & sample.env → containerization and env template
• tests/ → integration tests driving the nightly-Rust requirements
• prisma/
• src/lib.rs → auto-generated Prisma client for DB schema
• Cargo.toml → defines versioned Prisma dependency
README for additional insights
• Execution steps:
• docker compose up -d spins up moderation-service + database (Postgres)
• Cron files are loaded into the droplet’s crontab to schedule periodic moderation runs
• Deployment is fully automated via GitHub Actions (deploy.yaml) pushing to a DigitalOcean VM
• Testing requires seeding with freeCodeCamp exam data and running on Rust nightly
Main components & how they interact
a. Components
1. Developer/CI (GitHub Actions)
2. DigitalOcean Droplet (host)
3. Cron scheduler (on VM)
4. Docker Compose
– moderation-service container
– Postgres database container
5. Prisma client (Rust library inside moderation-service)
6. External caller (could be another service for seeding or API consumer)
b. Interactions
– Git pushes → GitHub Actions builds Docker images → SSH → Droplet → docker-compose deploy
– Cron (host) runs scheduled moderation commands (either HTTP calls or direct service CLI)
– moderation-service uses Prisma client to read/write exam/attempt records in Postgres
– Tests and local development mimic this stack via docker compose up moderation
c. Architectural patterns
– Microservice: single bounded context handling “moderation”
– Twelve-factor app: config via env, one service per container, logs to stdout
– CI/CD pipeline triggers deployments automatically
d. Key technologies
– Rust + Tokio (async) for the service
– Prisma Rust client for DB ORM
– Postgres as relational store
– Docker Compose for local/dev/production orchestration
– Cron for scheduled tasks
– GitHub Actions for CI/CD