This is a RESTful API built using Express.js, Sequelize ORM, and MySQL to manage Students, Courses, and Teachers. It includes full CRUD operations, Swagger API documentation, and a Faker-based database seeder.
- 🧑🎓 CRUD for Students
- 🧑🏫 CRUD for Teachers
- 📘 CRUD for Courses
- 🔁 Associations:
- One Teacher teaches many Courses
- Many Students enroll in many Courses (Many-to-Many)
- 📚 Swagger documentation (
/docs) - 🧪 Faker.js seeder for generating test data
git clone https://github.com/KimangKhenng/school-api.git
cd school-apinpm installCreate a .env file in the root:
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=yourpassword
DB_NAME=school_db
DB_PORT=3306
PORT=3000npm run devVisit: http://localhost:3000/docs
.
├── index.js
├── config
│ └── swagger.js
├── controllers
│ ├── student.controller.js
│ ├── teacher.controller.js
│ └── course.controller.js
├── models
│ └── index.js
├── routes
│ ├── student.routes.js
│ ├── teacher.routes.js
│ └── course.routes.js
├── seed.js
└── .env
To populate the database with fake students, courses, and teachers using Faker.js:
npm run seedThis will:
- Recreate all tables
- Insert 5 teachers, 10 courses, and 20 students
- Enroll students in random courses
Swagger UI is available at:
http://localhost:3000/docs
It includes all CRUD endpoints for:
/students/teachers/courses
| Script | Description |
|---|---|
npm start |
Start the server |
node seed.js |
Seed database with Faker.js |
- Express.js
- Sequelize ORM
- MySQL
- Swagger (swagger-jsdoc + swagger-ui-express)
- Faker.js
- dotenv
MIT