Skip to content

devsparkcodes/student-management-system-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Student Management System API

A professional backend API built using FastAPI for managing students and course enrollments.


๐Ÿ“Œ Project Overview

The Student Management System API is a backend application designed to manage:

  • ๐Ÿ‘จโ€๐ŸŽ“ Students
  • ๐Ÿ“š Course Assignments
  • ๐Ÿงพ Student Information
  • โœ… Data Validation

The project follows a clean and organized layered architecture using:

  • Routes Layer
  • Services Layer
  • Models Layer
  • Database Layer

This structure helps keep the project scalable, readable, and easy to maintain.


โš™๏ธ Tech Stack

Technology Purpose
Python Core programming language
FastAPI Backend framework
Pydantic Data validation
REST API API architecture
Uvicorn ASGI server

๐Ÿ“‚ Project Structure

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

โœจ Features

๐Ÿ‘จโ€๐ŸŽ“ Student Management

  • Create Student
  • Get All Students
  • Get Single Student
  • Update Student
  • Delete Student

๐Ÿ“š Course Management

  • Assign Course to Student
  • Get Assigned Course
  • Update Assigned Course
  • Delete Assigned Course

โœ… Validation Features

The API uses Pydantic for strong validation.

Validations Implemented:

  • Minimum & maximum name length
  • Age validation
  • Class validation
  • Email validation using EmailStr
  • Nested address validation

๐Ÿง  Architecture Explanation

๐Ÿ“ Routes Layer

Responsible for:

  • Handling API endpoints
  • Managing HTTP requests/responses
  • Raising exceptions
  • Connecting routes with services

๐Ÿ“ Services Layer

Responsible for:

  • Business logic
  • Data processing
  • CRUD operations
  • Database interactions

This separation keeps the code clean and maintainable.


๐Ÿ“ Models Layer

Responsible for:

  • Data schemas
  • Validation rules
  • Request & response structure

๐Ÿ“ Database Layer

A fake in-memory database is used using Python dictionaries.

This is suitable for:

  • Learning purposes
  • Fast prototyping
  • Understanding API flow

๐Ÿ“„ Student Model

Student Fields

Field Type
student_name string
father_name string
student_age integer
student_current_class integer
admission_date date
parent_email email
address object

Address Fields

Field Type
city string
area string
house_no string

๐Ÿ“š Available Courses

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

๐Ÿ”Œ API Endpoints

๐Ÿ‘จโ€๐ŸŽ“ Student Routes

Method Endpoint Description
POST /students/ Create student
GET /students/ Get all students
GET /students/{student_id} Get single student
PUT /students/{student_id} Update student
DELETE /students/{student_id} Delete student

๐Ÿ“š Course Routes

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

๐Ÿšจ Error Handling

The project uses FastAPI's HTTPException for handling errors.

Examples:

  • Student not found
  • Course not found
  • Duplicate course assignment

โ–ถ๏ธ How to Run the Project

1๏ธโƒฃ Create Virtual Environment

python -m venv .venv

2๏ธโƒฃ Activate Virtual Environment

Windows

.venv\Scripts\activate

3๏ธโƒฃ Install Dependencies

pip install -r requirements.txt

4๏ธโƒฃ Run Server

uvicorn main:app --reload

๐Ÿ“– API Documentation

FastAPI automatically provides interactive documentation.

Swagger UI

http://127.0.0.1:8000/docs

ReDoc

http://127.0.0.1:8000/redoc

๐Ÿ”ฎ Future Improvements

Planned future enhancements:

  • ๐Ÿ” JWT Authentication
  • ๐Ÿ—„๏ธ SQLite/PostgreSQL Integration
  • ๐Ÿ“Š Attendance Management
  • ๐Ÿ“ Marks Management
  • ๐Ÿ‘ฅ User Roles
  • ๐Ÿงช Automated Testing
  • โ˜๏ธ Deployment Support

๐ŸŽฏ Learning Outcomes

This project helped me understand:

  • FastAPI fundamentals
  • API architecture
  • Dependency Injection
  • Pydantic validation
  • CRUD operations
  • Service layer structure
  • REST API development

๐Ÿ‘จโ€๐Ÿ’ป Author

Muhammad Umar

Passionate learner exploring:

  • Artificial Intelligence
  • Generative AI
  • Backend Development
  • FastAPI
  • Python

โญ Final Note

This project was built for learning and practice purposes as part of my backend development and FastAPI learning journey.

Continuous improvement and learning are the main goals of this repository ๐Ÿš€

About

RESTful Student & Course Management API built with FastAPI and Python.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages