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
- 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.
.
├── 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
- 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/
Automatic Interactive Docs (Swagger UI): http://localhost:8000/docs
Automatic Alternative Docs (ReDoc): http://localhost:8000/redoc
- Execute http://localhost:8000/docs#/Others/reset_reset_post to reset the app with default values.
- Login with default admin user username: username@example.com password: string
- Now you can create, update or delete users or products