A FastAPI-based microservice for managing an online shop's inventory, including goods, shops, and stock, basket levels.
This microservice provides RESTful APIs to manage:
- Goods: Products in the catalog with name, description, and price
- Shops: Physical or online store locations
- Stock: Inventory levels linking goods to specific shops
- Basket: Who Wants to bue what
Built with FastAPI, SQLAlchemy, and Pydantic for high performance and type safety.
- ✅ FastAPI with automatic OpenAPI documentation
- ✅ SQLAlchemy ORM with SQLite database
- ✅ Pydantic models for data validation
- ✅ RESTful API design
- ✅ Automatic database table creation
- 🔄 CRUD operations (Create currently implemented)
- 🔄 API endpoint validation
- 🔄 Authentication & Authorization
- 🔄 Unit & Integration tests
- 🔄 Advanced error handling
- Python 3.8+
- pip or poetry
POST /goods- Create a new good
POST /shops- Create a new shop
POST /stock- Create a stock entry
POST /basket- Create a basket entry
If you want to see more with examples, visit Endpoint Documentation.
The service uses SQLite with the following tables:
- goods: id, name, description, price
- shops: id, name, location
- stock: id, shop_id, good_id, quantity
- basket: id, user_id, stock_id, quantity
This opration is hard coded into the database you can use app/create_super_user.py use it via the container shell
docker exec -it shop-service sh
python3 -m app.create_super_user
-
It just gives a UUID from you and save the user as super user
-
You can also use this code to convert generated uuid to jwt :
import jwt
token = jwt.encode(
{"sub": "<UUID>"},
"dummy",
algorithm="HS256"
)
print(token)# Run tests (when implemented)
pytest- Create a docker compse usind the docker file
docker build -t shop-service .- for your docker run the programm needs an env variable which is the url of transactions in wallet servies
docker run -d \
--name shop-service \
-p 8000:8000 \
-e WALLET_TRANSACTION_URL=http://wallet-service:8000/transactions \
shop-service- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
🚧 In Development - Basic CRUD operations implemented. Additional features in progress.