PriceRadar is a small FastAPI backend for tracking products and saving a target price for future alerts. The current version focuses on the core CRUD flow for tracked products and is structured so it can grow into later exercises without replacing the API foundation.
FastAPISQLModelSQLitepytest- Repository and service layers
- Create, view, update, and delete tracked products
- Persist data in a local
SQLitedatabase - Filterable list endpoint with
offsetandlimit - Auto-generated API docs with Swagger and ReDoc
- Sample seed script for demo data
- Input validation for URLs, prices, and required fields
Tracked products contain:
idnamestoreproduct_urlcurrent_pricetarget_pricecurrencyis_activecreated_at
- Create a virtual environment:
uv venv- Activate it on Windows PowerShell:
.venv\Scripts\activate- Install dependencies:
uv sync- Optional: set a custom database path.
PowerShell:
$env:DATABASE_URL="sqlite:///./priceradar.db"Bash:
export DATABASE_URL="sqlite:///./priceradar.db"An example is also available in .env.example.
- Optional: seed sample products:
uv run python scripts/seed_products.pyuv run uvicorn app.main:app --reloadThe API starts on http://127.0.0.1:8000.
Interactive docs:
- Swagger UI:
http://127.0.0.1:8000/docs - ReDoc:
http://127.0.0.1:8000/redoc
GET /GET /healthGET /productsGET /products/{product_id}POST /productsPUT /products/{product_id}DELETE /products/{product_id}
Example create request:
{
"name": "Sony WH-1000XM5",
"store": "KSP",
"product_url": "https://example.com/products/sony-wh1000xm5",
"current_price": 1299.9,
"target_price": 999.9,
"currency": "ILS",
"is_active": true
}Run the test suite with:
uv run pytestIf uv is not installed, use:
python -m pytestCurrent automated coverage includes:
- Empty-state listing
- Create, update, delete flows
- Missing-resource
404handling - Pagination behavior
- Validation failures for invalid URL and invalid target price
app/main.py: FastAPI app, routes, and startup lifecycleapp/models.py: SQLModel entities and request/response schemasapp/database.py: engine, session dependency, and table creationapp/repositories.py: data access layerapp/services.py: business logic layerscripts/seed_products.py: inserts demo products into the databasetests/test_main.py: API test coveragerequests.http: manual request collection for local testing
- The default database file
priceradar.dbis intentionally ignored bygit. - The app reads
DATABASE_URLdirectly from the environment;.env.exampleis documentation only unless you load it yourself. requests.httpcan be used from editors that support HTTP request files.- The layered structure keeps route handlers thin and makes later features easier to add.
- REST API implemented with
FastAPI - Persistent storage implemented with
SQLiteandSQLModel - Full CRUD for the main resource
tracked products - Separation between routes, service logic, and repository access
- Automated tests included and passing
READMEincludes setup, run, and test instructions- Manual request file included for quick demo during grading
If the lecturer opens the project for a quick review, this order is the clearest:
- Open Swagger at
http://127.0.0.1:8000/docs - Call
GET /health - Create a product with
POST /products - Show
GET /productsandGET /products/{id} - Update the price with
PUT /products/{id} - Delete it with
DELETE /products/{id} - Mention that tests pass with
python -m pytest
This project was developed with AI assistance for planning, scaffolding, and review. The code and documentation should still be verified locally by running the API and tests.