This project is a proof-of-concept (POC) microservices architecture built with Go (Golang), using multiple services to manage courses, students, and enrollments. It includes a GraphQL gateway for API aggregation and service communication via REST APIs.
├── course/ # Course service (manages courses)
├── student/ # Student service (manages students)
├── enrollment/ # Enrollment service (handles student enrollments in courses)
├── gateway/ # GraphQL API Gateway (aggregates data from other services)
├── docker-compose.yaml # Docker Compose file for running services
├── .gitignore # Git ignore file
- Provides CRUD operations for managing courses.
- Exposes REST API endpoints.
- Runs on port 8082.
- Manages student registrations.
- Exposes REST API endpoints.
- Runs on port 8081.
- Manages student enrollments in courses.
- Verifies student and course existence before enrollment.
- Runs on port 8083.
- Provides a GraphQL API to unify data access.
- Fetches data from
course,student, andenrollmentservices. - Runs on port 8080.
git clone https://github.com/Latte-Corporation/POC-GraphQL.git
cd POC-GraphQL docker-compose up --buildThis will start all services and expose the GraphQL API at http://localhost:8080.
- GraphQL Playground: http://localhost:8080/
- Course API:
GET http://localhost:8082/api/courses - Student API:
GET http://localhost:8081/api/students - Enrollment API:
GET http://localhost:8083/api/enrollments
- Go (Golang) - Language for all microservices
- Echo - Web framework for REST APIs
- GraphQL (GQLGen) - API Gateway for data aggregation
- Docker & Docker Compose - Containerization and orchestration
- Distroless Base Image - Minimal container image for security
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/courses |
Get all courses |
| GET | /api/courses/:id |
Get course by ID |
| POST | /api/courses |
Create a new course |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/students |
Get all students |
| GET | /api/students/:id |
Get student by ID |
| POST | /api/students |
Create a new student |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/enrollments |
Get all enrollments |
| GET | /api/enrollments/:id |
Get enrollment by ID |
| POST | /api/enrollments |
Enroll a student in a course |
query {
students {
id
name
courses {
title
}
}
courses {
id
title
}
}mutation {
enrollStudentInCourse(studentId: "1", courseId: "2") {
title
students {
name
}
}
}- Clone the repo and create a feature branch.
- Modify the required service (
course,student,enrollment,gateway). - Run
go mod tidyto ensure dependencies are correct. - Test locally with
docker-compose up --build. - Create a Pull Request for review.
This POC showcases a scalable microservices architecture using Go, GraphQL, and Docker. It can be extended with a database layer, authentication, and caching for production usage.