A lightweight REST API for serving and grading NGSA (National Grade Six Assessment) exam questions. This API provides endpoints for retrieving exam papers, fetching exam questions, and grading submitted answers.
The project is built with:
- Node.js
- Express
- MongoDB
- Docker & Docker Compose
The database includes open-source NGSA-style exam questions and answers.
The API is publicly deployed and accessible at:
Base URL: [ https://ngsa-exam-api.onrender.com/ ]
API Documentation (Swagger): [ https://ngsa-exam-api.onrender.com/docs ]
This live deployment allows developers, applications, and dashboards to access NGSA exam questions and grading services programmatically without needing to install the API locally.
- Retrieve available exams
- Filter exams by subject
- Retrieve all questions for a specific exam
- Submit answers and receive grading results
- Fully containerized with Docker
- Seeded database with exam data
.
├── src
│ ├── config
│ │ ├── db.js
│ │ └── swagger.js
│ ├── controllers
│ │ ├── examController.js
│ │ └── questionController.js
│ ├── models
│ │ ├── examModel.js
│ │ └── questionModel.js
│ └── routes
│ └── ngsaRoutes.js
├── data
│ ├── ngsa-db.exams.json
│ └── ngsa-db.questions.json
├── mongo-init
│ └── init.sh
├── docker-compose.yml
├── Dockerfile
├── server.js
├── package.json
└── README.md
Start the API and MongoDB using Docker Compose.
docker compose up --buildThe API will be available at: http://localhost:8080
To reset the database and re-import the seed data:
docker compose down -v
docker compose up --buildBase route: /ngsa
| Method | Endpoint | Description |
|---|---|---|
| GET | /ngsa/exams |
Returns a list of available exams. |
| GET | /ngsa/exams/english |
Returns all English exam papers. |
| GET | /ngsa/exams/math |
Returns all Mathematics exam papers. |
| GET | /ngsa/exam/questions/:id |
Returns the list of questions for the selected exam. Correct answers are NOT included in this response. |
| POST | /ngsa/exam/:testId/grade |
Submit answers for grading. |
Example response:
[
{
"_id": "66d0d0000000000000000000",
"subject": "English",
"paper_type": "Paper 1",
"year": 2010
}
]Example: GET /ngsa/exam/questions/66d0d0000000000000000000
Example response:
{
"questions": [
{
"_id": "66d0d0240000000000000001",
"number": 1,
"question_text": "Calvin is an _____ young man whom I admire.",
"options": {
"A": "adventorus",
"B": "adventureus",
"C": "adventorous",
"D": "adventurous"
}
}
]
}Example: POST /ngsa/exam/66d0d0000000000000000000/grade
Request Body:
{
"answers": [
{
"questionId": "66d0d0240000000000000001",
"selectedOption": "D"
},
{
"questionId": "66d0d0240000000000000002",
"selectedOption": "C"
}
]
}Response Example:
{
"summary": {
"score": 2,
"totalQuestions": 2,
"percentage": 100
},
"results": [
{
"questionId": "66d0d0240000000000000001",
"selectedOption": "D",
"isCorrect": true
},
{
"questionId": "66d0d0240000000000000002",
"selectedOption": "C",
"isCorrect": true
}
]
}The MongoDB database used by the project is: ngsa-db
Collections:
- exams
- questions
The database is automatically seeded from:
data/ngsa-db.exams.jsondata/ngsa-db.questions.json
when the Mongo container initializes.
Example .env file for local development :
PORT=YOUR_PORT
MONGODB_URI=YOUR_MONGODB_CONNECTION_STRING
GET /healthcheck
Response:
{
"status": "ok",
"message": "API is up and running!"
}This project is licensed under the MIT License