Table of Contents
Academia API is a Student management system's API. It is a RESTful API that allows students to register for courses and admins to manage courses and students.
- Admins can create, read, update and delete students and courses
- Students get their unique student ID by using their email to fetch it through the right endpoint
- Students can login with their student ID and default password.
- Students can register for courses
- Students can view their profiles and courses registered
- Students can change their passwords once, subsequent changes will require the student to contact the admin
- Admins can view all students and courses
- Admins can view all students registered for a course
- Admins can view all courses a student registered for
- Admins can update student's details such as the names and email
- Admins can upload student's grade for each course
- Admins can upload student's GPA
academia.vid.mp4
Creating this project got me more exposed to:
- Debugging
- Restful API
- Thorough research
- Database Management
- Authentication
- Authorization
- Endpoint restriction
- Testing with unittest
- Testing with Postman
- Swagger UI
- API Documentation
To get a local copy up and running, follow the steps below.
Python3: Get Python
-
Clone this repo
git clone https://github.com/engrmarkk/Academia_API.git
-
Navigate into the directory
cd Academia_API
-
Create a virtual environment
python -m venv your_venv_name
-
Activate the virtual environment on powershell or cmd
your_venv_name\Scripts\activate.bat
On Bash ('Scripts' for windows, 'bin' for linux)
source your_venv_name/Scripts/activate.csh
-
Install project dependencies
pip install -r requirements.txt
-
Set environment variables
set FLASK_APP=run.py
On Bash
export FLASK_APP=run.py
-
Set the create_app function to run the app in development mode. Make sure the imported create_app function in the run.py looks like this
app = create_app()
and not like this
app = create_app(configure=config_object['prodcon'])
-
Create database
flask shell
>>> Course (hit enter) >>> Student (hit enter) >>> Admin (hit enter) >>> CourseRegistered (hit enter) >>> db (hit enter) >>> db.create_all() >>> exit()
-
Run Flask
flask run
or
python run.py
-
Use the link generated on the terminal to access the endpoints
http://127.0.0.1:5000
To use swagger-ui, use the link below
http://127.0.0.1:5000/
.
├── README.md
├── .gitignore
├── LICENSE
├── api
│ ├── __init__.py
│ ├── auth
│ │ ├── __init__.py
│ │── blocklist
│ │ ├── __init__.py
│ └── config
│ │ ├── __init__.py
│ │ ├── your_db.sqlite3
│ └── extensions
│ │ ├── __init__.py
│ └── models
│ │ ├── __init__.py
│ │ ├── admin.py
│ │ ├── course_registered.py
│ │ ├── courses.py
│ │ ├── students.py
│ └── resources
│ │ ├── __init__.py
│ │ ├── admin.py
│ │ ├── student.py
│ └── schemas
│ │ ├── __init__.py
│ │ ├── admin.py
│ │ ├── auth.py
│ │ ├── course.py
│ │ ├── score.py
│ │ ├── student.py
│ └── test
│ │ ├── __init__.py
│ │ ├── test_course.py
│ │ ├── test_student_profile.py
│ │ ├── test_students_by_admin.py
│ │ ├── test_user.py
│ └── utils
│ │ ├── __init__.py
├── your_venv_name
├── requirements.txt
└── run.py
POST (Register) http://127.0.0.1:5000/register
REQUEST
{
"first_name": "string",
"password": "string",
"email": "string@string.com",
"last_name": "string"
}
RESPONSE
{
"id": 1,
"first_name": "string",
"password": "string",
"email": "string@string.com",
"last_name": "string"
}
POST (Login) http://127.0.0.1:5000/login
REQUEST
{
"user_id": "USER_ID",
"password": "string"
}
RESPONSE
{
"access_token": "eyJhbGciOiJIUzIEyMjMtNj...................",
"refresh_token": "eyJhbGciOiJIUzLyADmyXA...................."
}
POST (Create Student) http://127.0.0.1:5000/create-student
@admin_required
REQUEST
{
"first_name": "string",
"last_name": "string",
"email": "string"
}
RESPONSE
{
"stud_id": "string",
"first_name": "string",
"last_name": "string",
"email": "string"
}
POST (Create course) http://127.0.0.1:5000/create-course
@admin_required
REQUEST
{
"teacher": "string",
"course_title": "string",
"course_code": "string",
"course_unit": 0
}
GET (Get all students) http://127.0.0.1:5000/students
@admin_required
RESPONSE
[
{
"stud_id": "string",
"id": 0,
"first_name": "string",
"email": "string",
"gpa": 0,
"registered_courses": {
"id": 0,
"course_title": "string",
"grade": 0,
"course_code": "string",
"course_unit": 0
},
"last_name": "string"
}
]
GET (Get specific course with registered students) http://127.0.0.1.5000/course/<course_id>
@admin_required
RESPONSE
{
"id": 0,
"created_at": "2023-03-14T01:59:20.927Z",
"teacher": "string",
"course_title": "string",
"year": 0,
"course_code": "string",
"course_unit": 0,
"student_registered": {
"stud_id": "string",
"first_name": "string",
"last_name": "string",
"grade": 0
}
}
GET (Get all courses with registered students) http://127.0.0.1:5000/courses-students
@admin_required
RESPONSE
[
{
"id": 0,
"created_at": "2023-03-14T01:59:20.927Z",
"teacher": "string",
"course_title": "string",
"year": 0,
"course_code": "string",
"course_unit": 0,
"student_registered": {
"stud_id": "string",
"first_name": "string",
"last_name": "string",
"grade": 0
}
}
]
GET (Get specific student) http://127.0.0.1:5000/student/<stud_id>
@admin_required
RESPONSE
{
"stud_id": "string",
"id": 0,
"first_name": "string",
"email": "string",
"gpa": 0,
"registered_courses": {
"id": 0,
"course_title": "string",
"grade": 0,
"course_code": "string",
"course_unit": 0
},
"last_name": "string"
}
Adeniyi Olanrewaju - @iamengrmark - adeniyiboladale@yahoo.com
Project Link: Academia Api
Live Link: Academia
This project was made possible by: