Skip to content

yariv1025/messaging-system-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Messaging System REST API (Backend)

Requirements:

  • Python 3.7
  • MongoDB
  • PyCharm IDE (recommended)

Run the app:

1) Clone the project:

git clone git@github.com:yariv1025/messaging-system-rest-api.git

2) Install dependencies:

pip install pipenv            #Install pipenv and create the virtual environment
pipenv install                #Install packages
pipenv install all --dev      #Install all dev dependencies
pipenv lock                   #Generate a lockfile

3) Create your MongoDB atlas cluster:

  • Use MongoDB Atlas website to create your own database and cluster

4) Edit configuration:

  • Add new configuration:

    • Press + button
      • Python
        • name: APP
        • Script path: "YOURS-PATH"\messaging-system-rest-api\src\app.py
        • Environment variables: ;FLASK_ENV=development;FLASK_APP=./src/app.py;MONGO_USER="YOURS-USERNAME";MONGO_PASS="YOURS-PASSWORD";MONGO_URI="YOURS_DB_URI";SECRET_KEY="YOUR_SECRET_KEY"
  • Complete MongoDB URI should look like: f'mongodb+srv://{username}:{password}{mongo_uri}'

Attention: You must change MONGO_USER, MONGO_PASS, YOURS-PATH, etc. variables.

Execute requests using Postman:

  • Open Postman

  • Create API collection

  • Create the next CRUD requests:

    • POST:
    • Create a new user | WEB_ROUTE/user
      • Body fields: first_name, last_name, email, password
      • Response:
        • Status: 201
        • Body:
          * id: <> * first_name: <> * last_name: <> * email: <> * password: <> * created_at: <> * last_login: <>
    • Login | WEB_ROUTE/login
      • Body fields: email, password
      • Response:
        • Status: 200
        • Body: * status: <> * message: <> * access_token: <> * refresh_token: <>
    • Logout | WEB_ROUTE/oauth/logout
      • Authorization Bearer Token filed: access_token
      • Response:
        • Status: 200
        • Body: * message: <>
    • Refresh access token | WEB_ROUTE/oauth/refresh
      • Authorization Bearer Token filed: access_token.
      • Body:
        • key: grant_type, value: refresh_token
        • key: refresh_token, value: refresh_token
      • Response:
        • Status: 200
        • Body: * user_id: <> * email: <> * exp: <> * new_access_token: <>
    • Write message | WEB_ROUTE/messages
      • Authorization Bearer Token filed: access_token.
      • Body fields:
        • key: sender, value: sender
        • key: receiver, value: receiver
        • key: subject, value: subject
        • key: message, value: message
      • Response:
        • Status: 201
        • Body: * message_id: <>
    • GET:
      • Get all messages | WEB_ROUTE/messages
        • Authorization Bearer Token filed: access_token.
        • Response:
          • Status: 200
          • Body: * message_id: <> * sender_id: <> * sender_name: <> * receiver_name: <> * subject: <> * message: <> * created_at: <> * is_read: <>
    • Get message by id | WEB_ROUTE/messages/<message_id>
      • Authorization Bearer Token filed: access_token.
      • Response:
        • Status: 200
        • Body: * message_id: <> * sender_id: <> * sender_name: <> * receiver_name: <> * subject: <> * message: <> * created_at: <> * is_read: <>
    • DELETE:
    • Delete message | WEB_ROUTE/messages/<message_id>
      • Authorization Bearer Token filed: access_token.
      • Response:
        • Status: 200
        • Body: number of deleted messages
* You can check your requests on Heroku demo server
* "Seed" data could be found in the next path: "YOUR_PROJECT_PATH/api/static/INIT_DATA.json".

About

A simple rest API backend system for handling messages between users.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages