Retail App Service is a FastAPI-based application for managing a small-scale retail system, including users, customers, products, inventory, and orders. It uses Supabase as the database and is deployed via GitHub to Fly.io.
This project provides a RESTful API with endpoints for user authentication, customer management, product catalog, inventory tracking, and order processing. It’s designed to run locally or in the cloud, leveraging modern Python technologies and a PostgreSQL database hosted on Supabase.
- Clone the repository from GitHub:
git clone https://github.com/yourusername/retail-app.git cd retail-app
To isolate dependencies, set up a virtual environment:
-
Create the virtual environment:
python -m venv venv
-
Activate the virtual environment:
source venv/Scripts/activate
Install dependencies listed in requirements.txt:
- Run:
pip install -r requirements.txt
Here’s the project structure:
retail_app/- Root directorycore/- Core utilities and configurations__init__.pyconfig.py- App settings (e.g., JWT secret, database URL)database.py- Database setup and session managementsecurity.py- JWT authentication utilitiesauth_utils.py- Password hashing utilities
models/- SQLAlchemy models__init__.pydb_models.py- Database schema definitions
schemas/- Pydantic schemas for validation__init__.pyuser.pycustomer.pyproduct.pyinventory.pyorder.py
crud/- CRUD operations__init__.pyuser.pycustomer.pyproduct.pyinventory.pyorder.py
api/- API endpoints__init__.pydeps.py- Dependency injection utilitiesv1/- Versioned API endpoints__init__.pyuser.pycustomer.pyproduct.pyinventory.pyorder.py
main.py- App entry pointrequirements.txt- Dependency listfly.toml- Fly.io configurationProcfile- Process definition for deploymentREADME.md- This documentation
- FastAPI: High-performance web framework for building APIs with Python 3.6+.
- Uvicorn: ASGI server to run the FastAPI app.
- SQLAlchemy: ORM for database interactions.
- Supabase: PostgreSQL-based Backend-as-a-Service for database hosting.
- PyJWT: Library for JWT authentication.
- Passlib with bcrypt: Password hashing for security.
- psycopg2-binary: PostgreSQL adapter for Python.
- Fly.io: Cloud platform for deployment.
- GitHub Actions: CI/CD for automated deployment.
Follow these steps to deploy the app on your local machine
- Run:
uvicorn main:app
- Test:
http://127.0.0.1:8000/docs