A modular REST API built with Python and FastAPI for managing students, course assignments, and validated student information.
The Student Management System API is a backend application designed to manage student records and course assignments through RESTful endpoints.
The project uses a layered structure with separate routes, services, models, and database components. This organization helps keep the application readable, maintainable, and easier to extend.
- Create a student
- Get all students
- Get a single student
- Update student information
- Delete a student
- Assign a course to a student
- Get assigned courses
- Update course assignments
- Delete course assignments
The API uses Pydantic for request and response validation, including:
- Minimum and maximum name length
- Age validation
- Class validation
- Email validation using
EmailStr - Nested address validation
FastAPI's HTTPException is used to handle common API errors, including:
- Student not found
- Course not found
- Duplicate course assignment
The application follows a layered architecture:
- Routes Layer — Handles API endpoints and HTTP requests/responses.
- Services Layer — Contains business logic, data processing, and CRUD operations.
- Models Layer — Defines data schemas, validation rules, and request/response structures.
- Database Layer — Uses Python dictionaries as an in-memory database for learning and prototyping.
| Field | Type |
|---|---|
student_name |
string |
father_name |
string |
student_age |
integer |
student_current_class |
integer |
admission_date |
date |
parent_email |
|
address |
object |
| Field | Type |
|---|---|
city |
string |
area |
string |
house_no |
string |
| Course No. | Course Name | Duration |
|---|---|---|
| 1 | Python Basics | 2 months |
| 2 | Python Advanced | 3 months |
| 3 | Front-end Development | 4 months |
| 4 | Back-end Development | 4 months |
| Technology | Purpose |
|---|---|
| Python | Core programming language |
| FastAPI | Backend framework |
| Pydantic | Data validation |
| REST API | API architecture |
| Uvicorn | ASGI server |
TASK-1/
│
├── models/
│ └── student.py
│
├── routes/
│ ├── student.py
│ └── course.py
│
├── services/
│ ├── student_service.py
│ └── course_service.py
│
├── database.py
├── main.py
├── requirements.txt
├── README.md
└── .gitignore
| Method | Endpoint | Description |
|---|---|---|
| POST | /students/ |
Create student |
| GET | /students/ |
Get all students |
| GET | /students/{student_id} |
Get a single student |
| PUT | /students/{student_id} |
Update student |
| DELETE | /students/{student_id} |
Delete student |
| Method | Endpoint | Description |
|---|---|---|
| POST | /courses/{student_id}/{course_no} |
Assign course |
| GET | /courses/ |
Get all assigned courses |
| GET | /courses/{student_id} |
Get assigned course |
| PUT | /courses/{student_id}/{course_no} |
Update course |
| DELETE | /courses/{student_id} |
Delete course |
After starting the server, FastAPI provides:
- Swagger UI:
http://127.0.0.1:8000/docs - ReDoc:
http://127.0.0.1:8000/redoc
python -m venv .venvWindows:
.venv\Scripts\activatepip install -r requirements.txtuvicorn main:app --reloadThe API will be available at:
http://127.0.0.1:8000
This project helped strengthen practical understanding of:
- FastAPI fundamentals
- REST API development
- CRUD operations
- Pydantic validation
- Dependency Injection
- Layered backend architecture
- Service layer design
- API documentation with Swagger and ReDoc
Potential future enhancements include:
- JWT authentication
- SQLite or PostgreSQL integration
- Attendance management
- Marks management
- User roles and permissions
- Automated testing
- Deployment support
Muhammad Umar
Building practical applications at the intersection of software engineering and AI.
- GitHub: https://github.com/devsparkcodes
- LinkedIn: https://linkedin.com/in/devsparkcodes