We have evolved from in-memory lists to a persistent Relational Database (SQLite).
- Architecture: Monolith (Single file) with DB.
- Database: SQLite (File-based, persistent).
- Scale: 10-100 Users (Small Business).
- Introduced
SQLModel(ORM) for database interactions. - Defined Tables:
User,Product,Order,OrderItem. - Data persists after server restart in
ecommerce.db.
-
Install dependencies:
pip install -r requirements.txt
-
Run the server:
uvicorn main:app --reload
The database file
ecommerce.dbwill be created automatically. -
Open Swagger UI:
http://127.0.0.1:8000/docs
We now have relationships:
- Orders belong to Users.
- Orders have many Items (linked to Products).