/Teachers-Hub-Backend

Backend Flask API of the Teachers Hub Application

Primary LanguagePython

Teachers Hub Backend

Codacy Badge Build Status Coverage Status

About

The purpose of this project is to provide inclusive, equitable and quality education for all people, globally. Its targets to span a variety of challenges related to inclusion of marginalized populations at multiple levels of education and in the workforce.

This project addresses the following SDG targets:

  • Increased supply of qualified teachers in the community
  • Increased networking among teachers
  • Training of teachers by more qualified bodies
  • Accessibility to employment opportunities

Usage

AUTHENTICATION

REQUEST ROUTE FUNCTIONALITY
POST api/v1/auth/login Logs in a user
POST api/v1/auth/signup Registers a user

COURSES

REQUEST ROUTE FUNCTIONALITY
GET api/v1/courses Fetches all courses
GET api/v1/courses/<course_id> Fetches a single course
POST api/v1/courses Adds a new course
PUT api/v1/courses/<course_id> Updates a single course
DELETE api/v1/courses/<course_id> Deletes a course
POST api/v1/courses/<course_id>/enroll Enroll for a course
POST api/v1/courses/<course_id>/modules Add module to course
GET api/v1/courses/<course_id>/modules Fetch modules on a course
GET api/v1/courses/<course_id>/modules/<module_id> Fetch module content for a single module
POST api/v1/courses/<course_id>/modules/<module_id> Create module content for a single module
GET api/v1/courses/enrolled Fetch courses enrolled for

PARTNERS

REQUEST ROUTE FUNCTIONALITY
GET api/v1/organizations Fetches all organisations
GET api/v1/organizations/<organization_id> Fetches a single organisation
POST api/v1/organizations Adds a new organisation
PUT api/v1/organizations/<organization_id> Updates a single organisation
DELETE api/v1/organizations/<organization_id> Deletes an organisation

USERS

REQUEST ROUTE FUNCTIONALITY
GET api/v1/auth/profile Fetches a user's profile

BLOG

REQUEST ROUTE FUNCTIONALITY
GET api/v1/articles Fetch all articles
POST api/v1/articles Add New Article
DELETE api/v1/articles/<article_id> Delete an article
PUT api/v1/articles/<article_id> Update an article
GET api/v1/articles/<article_id> Fetch single article

COMMUNITY QUESTIONS

REQUEST ROUTE FUNCTIONALITY
GET api/v1/questions Fetches all organisations
GET api/v1/questions/<question_id> Fetches a single question
POST api/v1/questions Adds a new question
PUT api/v1/questions/<question_id> Updates a single question
DELETE api/v1/questions/<question_id> Deletes a question

Setup

  1. You should have Python 3.5+ and git installed.
  2. Inorder to get started, clone this repository using git clone https://github.com/BuildForSDG/Teachers-Hub-Backend.git
  3. Change in the repository directory cd teachers-hub-backend
  4. Set up a virtual environment by running python3 -m venv <name_of_the_environment>
  5. Install requirements by running pip install -r requirements.txt
  6. Start the flask server by running python run.py
  7. Navigate to http://localhost:8000 in the browser to view the api.
  8. Alternatively, open postman to test the url endpoints

Postman Setup for API Testing

Open this collection in postman by clicking the button below:

Run in Postman

If you're using Postman for testing the REST api, you can use the following setup:

  • Make sure you have an environment set for your collection.

  • POST to http://localhost:5000/api/v1/auth/signup and add your details to sign up

  • POST to http://localhost:5000/api/v1/auth/login/ to obtain token

  • Paste this code in Tests which will save the token to the environment.

    var jsonData = JSON.parse(responseBody);
    postman.setEnvironmentVariable("token", jsonData.token);
    
  • In the Authorization section of your subsequent posts, set the Authorization type as Bearer Token and add {{token}} in the token section

Heroku deployment

View the deployed application here Teachers Hub API

Authors

LICENSE

MIT