Skip to content

JulioJair/catalog-fastapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 

Repository files navigation

REST API

Basic catalog system to manage products:

  • Non registered users can read data about the products.
  • Admin users can create, read, update and delete products and users.

About the framework: FastAPI framework, high performance, easy to learn, fast to code, ready for production Documentation: https://fastapi.tiangolo.com Source Code: https://github.com/tiangolo/fastapi

Special requirements

  • Every time a show product is executed by whoever user the times_requested is incremented by one.
  • When a user admin update a product all admins are notified by email.

Database Diagram

image

Project Structure

.
├── app                     # root of the API project
│   ├─ catalog.db           # project database
│   ├─ main.py              # "main" module, e.g. import app.main
│   ├─ requirements.py      # necessary packages
│   └─ app                  # "app" is a "Python subpackage"
│      ├─ __init__.py       # makes "routers" a "Python subpackage"
│      ├─ database.py       # Connection and config to database related
│      ├─ hashing.py        # Encrypt and validate passwords
│      ├─ models.py         # Models with their relations
│      ├─ oauth2            # Authorization by token
│      ├─ token             # JWT tokens implementation
│      ├─ controllers       # To separate logic from endpoint
│      ├─ __init__.py 
│      │    ├─ ..
│      │    ├─ ..
│      │    └─ auth.py      # Include login function
│      ├─ routers           # points of entry organized by prefix
│      │    ├─ __init__.py
│      │    ├─ users.py
│      │    ├─ products.py
│      │    └─ analytics.py
│      └─ schemas           # Pydantic to validate inputs and responses
│           ├─ __init__.py 
│           ├─ users.py
│           ├─ products.py
│           └─ analytics.py

Backend Requirements

Backend local development

  • Build the Docker image

docker build -t catalog-api backend

  • Run the Docker container

docker run -d --name catalog-container -p 8000:8000 catalog-api

  • Now you can open your browser and interact with these URLs:

Backend, JSON based web API based on OpenAPI: http://localhost:8000/api/

API docs

Automatic Interactive Docs (Swagger UI): http://localhost:8000/docs

Screenshot_20210629_080127

Automatic Alternative Docs (ReDoc): http://localhost:8000/redoc

image

Login as admin

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published