/Backend-2

Backend

Primary LanguagePythonMIT LicenseMIT


Ogma app logo
Ogma App Backend

Summary

This project delivers and API that includes a CRUD type service for users for our app.

How To Use

To clone and run this application, you'll need Git and Python 3 installed on your computer. From your command line:

# Clone this repository
$ git clone https://github.com/OgmaCapStone/Backend.git

# Go into the repository
$ cd backend

# Create virtual enviroment
$ python -m venv .env

# Enter the virtual enviroment
$ source .env/bin/activate

# Install dependencies
$ pip install -r requirements.txt

# Don't forget to set up your own .env file

# Run the app
$ uvicorn app.main:app

Credits

This software uses :

With the supervision of Erik Ochoa, Academic Coach at Platzi Master

Collaborators

This app was created with 💚 by:

Elsa Portilla  ·  Frontend Developer  ·  LinkedIn @elsaportilla  ·  GitHub @elsargentpepper  · 

Jorge Delgadillo  ·  Backend Developer (backend repo)  ·  LinkedIn @jorge-alberto-delgadillo-alonso-7b58501aa  ·  GitHub @49122  · 

Juan Camilo Garcés  ·  Frontend Developer  ·  LinkedIn @juancamilogarcesviveros  ·  GitHub @camilogarcesv  ·  Twitter @Camilo_GarcesV  · 

Juan Daniel Martínez  ·  Frontend Developer  ·  juanda.dev  ·  GitHub @juandadev  ·  Twitter @juanda_dev_

Sebastián Ballen  ·  Frontend Developer  ·  sebastianbc09.github.io  ·  LinkedIn @sebastian-ballen-87851518a  ·  GitHub @SebastianBC09  · 

API

Users

/users/create

-- Post -- Expected request body:

	{
	  "name": str,
	  "email": str,
	  "password": str,
	  "login_type": str,
	  "username": str,
	}

-- Expected response:

	{
	  "response": "User created"
	}

-- Possible errors:

  • 422: If the information given in the request body does not align with what is asked of it.
  • 400: If the information given was invalid

/user

-- GET -- Expected request param (One or the other):

  • username: str
  • email: str

-- Expected response:

	{
	  "response": {
	    "name": str,
	    "email": str,
	    "username": str,
	    "badges": [
	      str
	    ],
	    "prefered_technologies": [
	      str
	    ],
	    "profile_pic": str
	  }
	}

-- Possible errors:

  • 422: If the information given in the param does not align with what is asked of it.
  • 400: If the information given was invalid
  • 400: If you tried to send both email and username
  • 400: If the user does not exist

/user/edit

-- POST -- Expected request body:

 {
	    
	    "name": Optional[str],
	    "email": Optional[str],
	    "username": Optional[str],
	    "password": Optional[str],
	    "login_type": Optional[str],
	    "badges": Optional[[
	      str
	    ]],
	    "prefered_technologies": Optional[[
	      str
	    ]],
	    "profile_pic": Optional[str]
	  
	}

-- Expected response:

	{
	  "response": "User updated"
	}

-- Possible errors:

  • 422: If the information given in the param does not align with what is asked of it.
  • 400: If the information given was invalid
  • 400: If the user does not exist

/user/delete

-- DELETE -- Expected request body:

 {
	    
	    "name": MANDATOY[str],
	    "email": Optional[str],
	    "username": Optional[str],
	    "password": Optional[str],
	    "login_type": Optional[str],
	    "badges": Optional[[
	      str
	    ]],
	    "prefered_technologies": Optional[[
	      str
	    ]],
	    "profile_pic": Optional[str]
	  
	}

-- Expected response:

	{
	  "response": "User delete"
	}

-- Possible errors:

  • 422: If the information given in the param does not align with what is asked of it.
  • 400: If the information given was invalid
  • 400: If the user does not exist

Questions

/questions

-- GET -- Expected request params:

  • technology: str
  • level: str
  • number_of_questions: int

-- Expected response:

	{

	"response": {

		"questions": [

			{

			"question": str,

			"answers": [str],

			"correct_answer_index": int,

			"image": str

			}
		]
	}

-- Possible errors:

  • 422: If the information given in the param does not align with what is asked of it.
  • 400: If the data base does not have enough questions to give a proper response

/questions/add

-- POST -- Expected request body:

{

	"question": str,

	"answers": [str],

	"right_answer": str,
	
	"level": int,

	"technology": int,

	"image": str,

	"password": str

}

-- Expected response:

	{
	  "response": "Question added"
	}

-- Possible errors:

  • 422: If the information given in the param does not align with what is asked of it.
  • 401: If the credentials are not valid
  • 400: If the question already exist

Technologies

/user/technology/add

-- POST -- Expected request body:

{
 "user":{	    
	    "name": MANDATOY[str],
	    "email": Optional[str],
	    "username": Optional[str],
	    "password": Optional[str],
	    "login_type": Optional[str],
	    "badges": Optional[[
	      str
	    ]],
	    "prefered_technologies": Optional[[
	      str
	    ]],
	    "profile_pic": Optional[str]
	  
	},
"technology":{
		"name": str
	}
}

-- Expected response:

	{
	  "response": "Technology added"
	}

-- Possible errors:

  • 422: If the information given in the param does not align with what is asked of it.
  • 400: If the credentials user does not exist
  • 400: If the user already has the technology added

/user/technology/remove

-- DELETE -- Expected request body:

{
 "user":{	    
	    "name": MANDATOY[str],
	    "email": Optional[str],
	    "username": Optional[str],
	    "password": Optional[str],
	    "login_type": Optional[str],
	    "badges": Optional[[
	      str
	    ]],
	    "prefered_technologies": Optional[[
	      str
	    ]],
	    "profile_pic": Optional[str]
	  
	},
"technology":{
		"name": str
	}
}

-- Expected response:

	{
	  "response": "Technology removed"
	}

-- Possible errors:

  • 422: If the information given in the param does not align with what is asked of it.
  • 400: If the credentials user does not exist
  • 400: If the user already does not have selected technology

/technologies

-- GET -- Expected request params: None -- Expected response:

	{
	  "response": [
		  {
			  "name": str,
			  "image" str,
			  "summary": str
		  }
	  ]
	}

-- Possible errors:

Progress

-- /user/progress/update -- POST -- Expected request body:

{
 "user":{	    
	    "name": MANDATOY[str],
	    "email": Optional[str],
	    "username": Optional[str],
	    "password": Optional[str],
	    "login_type": Optional[str],
	    "badges": Optional[[
	      str
	    ]],
	    "prefered_technologies": Optional[[
	      str
	    ]],
	    "profile_pic": Optional[str]
	  
	},
"technology":{
		"name": str
	},
"percentage": int
}

-- Expected response:

	{
	  "response": "Progress updated"
	}

-- Possible errors:

  • 422: If the information given in the param does not align with what is asked of it.
  • 400: If the credentials user does not exist

Levels

-- /levels -- GET -- Expected request params: None

-- Expected response:

	{
	  "response": [
		 str
	  ]
	}

-- Possible errors: