A full-stack quiz application deployed on AWS using Docker containers, ECR, and ECS with automated CI/CD through CircleCI.
- Frontend: React application containerized and hosted on ECS
- Backend: Node.js/Express API containerized and hosted on ECS
- Database: MongoDB Atlas
- CI/CD: CircleCI for automated testing and deployment
- Container Registry: Amazon ECR
- Container Orchestration: Amazon ECS
Register a new user
- Request Body:
{ "username": "string", "email": "string", "password": "string" } - Response: JWT token and user details
Login existing user
- Request Body:
{ "email": "string", "password": "string" } - Response: JWT token and user details
Get all quizzes
- Auth: Not required
- Response: Array of quiz objects
Create a new quiz
- Auth: Required
- Request Body:
{ "title": "string", "description": "string", "category": "string", "questions": [ { "text": "string", "choices": ["string"], "rightAnswer": "number", "points": "number" } ] } - Response: Created quiz object
Get a specific quiz
- Auth: Not required
- Response: Quiz object with questions
Submit an answer for a quiz question
- Auth: Required
- Request Body:
{ "questionIndex": "number", "selectedAnswer": "number" } - Response: Updated attempt object
Complete a quiz attempt
- Auth: Required
- Response: Final attempt object with score
Get user's quiz attempts
- Auth: Required
- Response: Array of attempt objects
Get current user profile
- Auth: Required
- Response: User object
Update user profile
- Auth: Required
- Request Body:
{ "username": "string", "email": "string", "bio": "string" } - Response: Updated user object
{
title: String,
description: String,
category: String,
creator: ObjectId,
questions: [{
text: String,
choices: [String],
rightAnswer: Number,
points: Number
}],
createdAt: Date
}{
user: ObjectId,
quiz: ObjectId,
answers: [{
questionIndex: Number,
selectedAnswer: Number,
isCorrect: Boolean,
points: Number
}],
score: Number,
completed: Boolean,
startedAt: Date,
completedAt: Date
}{
username: String,
email: String,
password: String (hashed),
bio: String,
quizzesTaken: Number,
quizzesCreated: Number,
createdAt: Date
}# AWS Configuration
AWS_ACCOUNT_ID=xxxx2510
AWS_DEFAULT_REGION=xxxxst-1
AWS_ECR_BACKEND_REPO=xxxxkend
AWS_ECR_FRONTEND_REPO=xxxxtend
AWS_ECS_CLUSTER=xxxxster
AWS_KEY=xxxxSH2E
AWS_RESOURCE_NAME_PREFIX=xxxx-app
AWS_SECRET_ACCESS_KEY=xxxxfn/l
DOCKER_IMAGE_TAG=xxxxest├── frontend/ # React frontend application
│ ├── src/ # Source code
│ ├── Dockerfile # Frontend container configuration
│ └── package.json # Frontend dependencies
├── controllers/ # Backend API controllers
├── models/ # MongoDB models
├── middleware/ # Express middleware
├── routes/ # API routes
├── __tests__/ # Test files
├── .circleci/ # CircleCI configuration
├── Dockerfile # Backend container configuration
└── server.js # Main backend entry point
- Node.js v14 or higher
- Docker Desktop
- AWS CLI configured
- CircleCI account
- MongoDB Atlas account
- Clone the repository
git clone <repository-url>
cd quiz-master- Install dependencies
# Install backend dependencies
npm install
# Install frontend dependencies
cd frontend && npm install
cd ..- Set up environment variables
- Create
.envfile in root directory - Create
.envfile in frontend directory
- Run the application
npm run dev- Build images
# Backend
docker build -t ${AWS_ECR_BACKEND_REPO}:latest .
# Frontend
cd frontend
docker build -t ${AWS_ECR_FRONTEND_REPO}:latest .- Push to ECR
# Login to ECR
aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com
# Push images
docker push ${AWS_ECR_BACKEND_REPO}:latest
docker push ${AWS_ECR_FRONTEND_REPO}:latestThe pipeline consists of three main stages:
- Test: Runs backend tests using Jest
- Build: Builds and pushes Docker images to ECR
- Deploy: Updates ECS services with new images
Required variables in CircleCI project settings:
- AWS_ACCOUNT_ID
- AWS_DEFAULT_REGION
- AWS_ECR_BACKEND_REPO
- AWS_ECR_FRONTEND_REPO
- AWS_ECS_CLUSTER
- AWS_KEY
- AWS_RESOURCE_NAME_PREFIX
- AWS_SECRET_ACCESS_KEY
- DOCKER_IMAGE_TAG
- Backend tests:
npm test - Frontend tests:
cd frontend && npm test
- ECR: Container registry for Docker images
- ECS: Container orchestration service
- EC2: Compute instances for ECS cluster
- VPC: Network configuration
- IAM: Access management
- Code is pushed to main branch
- CircleCI pipeline is triggered
- Tests are run
- Docker images are built and pushed to ECR
- ECS services are updated with new images
- ECS task logs in CloudWatch
- Application logs in CloudWatch
- Container metrics in CloudWatch
Common issues and solutions:
-
CircleCI Build Fails:
- Check environment variables
- Verify AWS credentials
- Check test results
-
Container Deployment Issues:
- Check ECS service events
- Verify task definition
- Check container logs
-
Application Errors:
- Check CloudWatch logs
- Verify environment variables
- Check MongoDB connection
- AWS credentials managed through CircleCI
- Sensitive data in environment variables
- MongoDB Atlas security configuration
- Container security best practices
-
Add frontend tests
-
Implement staging environment
-
Add performance monitoring
-
Implement auto-scaling
-
Add backup strategy
Here are some of the screenshots, remaining screenshots are neatly outlined in the pdf