A backend microservices-based management system to help user manage their learning center, sport club,... built with Node.js, featuring authentication, student management, class management, teacher management, and tuition tracking.
- Auth Service (Port 3001) - User authentication and authorization
- Student Service (Port 3002) - Student data management
- Class Service (Port 3003) - Class and enrollment management
- Teacher Service (Port 3005) - Teacher profile management
- Tuition Service (Port 3004) - Payment and invoice management
The microservices are deployed on AWS with the following architecture:
- ECR (Elastic Container Registry) - Stores Docker images for each service
- Lambda - Runs each microservice as a containerized function (arm64, deployed from ECR images)
- API Gateway (HTTP API) - Single entry point that routes requests to the corresponding Lambda function
- ElastiCache Serverless (Valkey) - Shared serverless caching layer for all services
- S3 - Image file storage, with versioning, lifecycle policies, and SSE encryption
- Secrets Manager - Stores sensitive credentials (MongoDB connection, JWT keys, refresh token secret)
- CloudWatch - Monitoring and alerting for Lambda functions, API Gateway, and ElastiCache
- VPC - Lambda functions run in private subnets with a NAT Gateway for outbound access
- Backend: Node.js, Javascript
- Databases: MongoDB (Auth), PostgreSQL (Students, Classes, Teachers, Tuition)
- Caching: Redis (Database caching)
- ORM: Prisma (PostgreSQL services), Mongoose (MongoDB)
- Authentication: JWT with RSA keys
- Containerization: Docker & Docker Compose
- CI/CD: GitHub Actions
- Terraform - Manages all AWS infrastructure as Infrastructure as Code
- Docker and Docker Compose
- Node.js 18+ (for local development)
# Start all services
docker-compose up -d- Auth Service: http://localhost:3001
- Student Service: http://localhost:3002
- Class Service: http://localhost:3003
- Tuition Service: http://localhost:3004
- Teacher Service: http://localhost:3005
The system uses multiple databases:
- MongoDB (Port 27017) - User authentication data
- Redis (Port 6379) - Database caching
- PostgreSQL instances for each service:
- Student DB (studentdb)
- Class DB (classdb)
- Teacher DB (teacherdb)
- Tuition DB (tuitiondb)
Each service requires its own .env file. Check individual service directories for required environment variables.
Auth Service:
REFRESH_TOKEN_SECRET=your-refresh-token-secret
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PREFIX=userSv:
ACCESS_TOKEN_EXPIRY='1h'
REFRESH_TOKEN_EXPIRY='7d'
Student Service:
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PREFIX=studentSv:
Class Service:
STUDENT_SERVICE_API="http://student:3002/students"
TEACHER_SERVICE_API="http://teacher:3005/teachers"
USER_SERVICE_API="http://auth:3001/users"
AWS_REGION="your-aws-region"
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PREFIX=classSv:
Teacher Service:
AWS_BUCKET_NAME=your-bucket-name
AWS_REGION="your-aws-region"
AWS_ACCESS_KEY_ID=your-access-key-id
AWS_SECRET_ACCESS_KEY=your-secret-access-key
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PREFIX=teacherSv:
Tuition Service:
CLASS_SERVICE_API="http://class:3003/classes"
STUDENT_SERVICE_API="http://student:3002/students"
AWS_REGION="your-aws-region"
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PREFIX=tuitionSv:
POST /auth/register- User registrationPOST /auth/login- User loginPOST /auth/refresh- Refresh tokenDELETE /auth/logout- User logoutPATCH /auth/password- Change passwordGET /auth/by-ids- Get usernames by IDs
GET /students- List studentsPOST /students- Create studentGET /students/:id- Get student by IDPATCH /students/:id- Update studentDELETE /students/:id- Delete studentGET /students/by-ids- Get students by IDs
GET /classes- List classesPOST /classes- Create classGET /classes/:id- Get class by IDPATCH /classes/:id- Update classDELETE /classes/:id- Delete classGET /classes/:id/students- Get students in classPOST /classes/:id/students- Add student to classPATCH /classes/:id/students/:studentId- Change student classDELETE /classes/:id/students/:studentId- Remove student from classGET /classes/:id/users- Get users in classPOST /classes/:id/users- Add user to classPATCH /classes/:id/users/:userId- Change user class roleDELETE /classes/:id/users/:userId- Remove user from classDELETE /classes/:id/users/me- Leave classPOST /classes/join- Join classGET /classes/:classId/permissions- Check user permissions
GET /teachers- List teachersPOST /teachers- Create teacher (with avatar upload)GET /teachers/:id- Get teacher by IDPATCH /teachers/:id- Update teacher (with avatar upload)DELETE /teachers/:id- Delete teacher
GET /invoices- List invoicesPOST /invoices- Create invoiceGET /invoices/:id- Get invoice by IDPATCH /invoices/:id- Update invoiceDELETE /invoices/:id- Delete invoicePATCH /invoices/:id/cancel- Cancel invoiceGET /invoices/:id/payments- Get payments for invoicePOST /invoices/:id/payments- Create payment for invoice
DELETE /payments/:paymentId- Delete payment
GET /reports/class/:classId- Get class monthly tuition reportGET /reports/student/:studentId- Get student tuition report
- JWT-based authentication with RSA key pairs
- Password hashing with bcrypt
- Role-based access control
- Request validation middleware
