A clean and production-style CRUD Inventory System built with FastAPI + SQLModel + SQLite, designed to demonstrate backend development, REST API design, and SQL analytics capabilities.
This project is perfect for showcasing skills in Python, SQL, backend engineering, testing, and API developmentβideal for Software Developer and Backend Engineer roles.
- Create, Read, Update, Delete (CRUD) inventory items
- Pagination & keyword search
- Auto-generated documentation (Swagger / ReDoc)
- SQLite database integration with SQLModel
- Timestamped records (created_at, updated_at)
- Background DB initialization on startup
- Clean project structure
- API-first design
- Unit tests with PyTest
- Easy to run and extend
- Beginner-friendly, but production-ready patterns
| Layer | Technology |
|---|---|
| Language | Python |
| Framework | FastAPI |
| ORM | SQLModel (SQLite backend) |
| Testing | PyTest, TestClient |
| Server | Uvicorn |
| Database | SQLite (file-based, no setup needed) |
inventory-system/
βββ main.py
βββ models.py
βββ database.py
βββ requirements.txt
βββ README.md
βββ tests/
β βββ test_items.py
βββ .gitignore
pip install -r requirements.txtuvicorn main:app --reload- Swagger UI β http://127.0.0.1:8000/docs
- ReDoc β http://127.0.0.1:8000/redoc
GET / - Returns a welcome message + endpoint info.
| Method | Endpoint | Description |
|---|---|---|
| POST | /items | Create a new item |
| GET | /items | List all items (pagination + search) |
| GET | /items/{item_id} | Get item by ID |
| PUT | /items/{item_id} | Update item |
| DELETE | /items/{item_id} | Delete item |
Run all tests:
pytestIncludes:
- Test for creating new items
- Test for listing items
Item table:
| Field | Type | Description |
|---|---|---|
| id | Integer (PK) | Auto-generated |
| name | Text | Item name |
| sku | Text | Unique stock code |
| qty | Integer | Quantity available |
| price | Float | Unit price |
| created_at | Timestamp | Auto-set on create |
| updated_at | Timestamp | Auto-updated on update |
{
"name": "Tablet",
"sku": "TB-001",
"qty": 15,
"price": 40000
}Here are powerful SQL queries you can run in DB Browser for SQLite.
SELECT * FROM item;SELECT COUNT(*) AS total_items FROM item;SELECT SUM(qty * price) AS total_value FROM item;SELECT name, qty FROM item WHERE qty < 5;SELECT name, price FROM item ORDER BY price DESC LIMIT 5;SELECT * FROM item WHERE price BETWEEN 500 AND 2000;SELECT * FROM item WHERE name LIKE '%lap%';SELECT
CASE
WHEN price < 500 THEN 'Under 500'
WHEN price BETWEEN 500 AND 2000 THEN '500β2000'
WHEN price BETWEEN 2001 AND 5000 THEN '2001β5000'
ELSE 'Above 5000'
END AS price_range,
COUNT(*) AS total
FROM item
GROUP BY price_range;SELECT AVG(price) FROM item;SELECT * FROM item ORDER BY created_at DESC;You can populate your database with this sample data:
INSERT INTO item (name, sku, qty, price, created_at, updated_at)
VALUES ("Laptop", "LP-001", 10, 55000, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);Varun Rathore
π Ujjain, MP
π GitHub: https://github.com/VarunRathore137
π LinkedIn: https://www.linkedin.com/in/varun-rathore137
Give the repo a β on GitHub β it helps!

