A simple ecommerce backend built with FastAPI, SQLAlchemy, and SQLite.
- User authentication (JWT)
- Role-based accounts (admin / user)
- Products, Categories, Carts, and Cart Items
- SQLite database with SQLAlchemy ORM models
- Auto table creation on startup
-
app/- application packagemodels/- SQLAlchemy modelsschemas/- Pydantic request/response schemasrouters/- FastAPI routers (endpoints)services/- business logicdb/- database setupcore/- configuration and securityutils/- shared utilities
-
main.py- entrypoint to run FastAPI (usesapp/main.py) -
run.py- alternate run script -
db.sqlite3- local SQLite database file
- Python 3.10+ (recommended)
Install dependencies:
pip install -r requirements.txtuvicorn app.main:app --reloadThen visit:
- Swagger UI:
http://127.0.0.1:8000/docs - ReDoc:
http://127.0.0.1:8000/redoc
The project uses SQLite (db.sqlite3) and automatically creates tables on startup via:
app/main.py(callsBase.metadata.create_all(bind=engine))
If you need to reset the database, delete db.sqlite3 and restart the app.
- The app currently defaults timestamps using SQLite-compatible
CURRENT_TIMESTAMP. - If you run into
sqlite3.OperationalError: unknown function: NOW(), deletedb.sqlite3and restart.
- Create a new branch
- Make changes
- Open a PR
If you'd like help adding tests, docker support, or expanding the API (orders, payments, etc.), just ask!