Skip to content

Latest commit

 

History

History
514 lines (426 loc) · 12.8 KB

File metadata and controls

514 lines (426 loc) · 12.8 KB

Academia API



Contributors Forks Stargazers Issues Twitter



Table of Contents
  1. About the project
  2. Demo
  3. Exposure
  4. Usage
  5. Contact
  6. Acknowledgments

back to top


About Academia-API

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.

Features

  • 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

back to top

Built With:

Python Flask SQLite

back to top


Demo

academia.vid.mp4


back to top


Exposure

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

back to top


Usage

To get a local copy up and running, follow the steps below.

Prerequisites

Python3: Get Python

Installation

  1. Clone this repo

    git clone https://github.com/engrmarkk/Academia_API.git
  2. Navigate into the directory

    cd Academia_API
  3. Create a virtual environment

    python -m venv your_venv_name
  4. 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
  5. Install project dependencies

    pip install -r requirements.txt
  6. Set environment variables

    set FLASK_APP=run.py

    On Bash

    export FLASK_APP=run.py
  7. 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'])
  8. Create database

    flask shell
    >>> Course (hit enter)
    >>> Student (hit enter)
    >>> Admin (hit enter)
    >>> CourseRegistered (hit enter)
    >>> db (hit enter)
    >>> db.create_all()
    >>> exit()
  9. Run Flask

    flask run

    or

    python run.py
  10. 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/

Project structure

.
├── 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

Endpoints


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"
}

back to top


Contact

Adeniyi Olanrewaju - @iamengrmark - adeniyiboladale@yahoo.com

Project Link: Academia Api

Live Link: Academia

back to top


Acknowledgements

This project was made possible by:

back to top