Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

Online Shop Microservice

A FastAPI-based microservice for managing an online shop's inventory, including goods, shops, and stock, basket levels.

Description

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.

Tech Stack

Python Version FastAPI SQLAlchemy Pydantic SQLite Uvicorn pytest Git

Features

  • ✅ 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

Installation

Prerequisites

  • Python 3.8+
  • pip or poetry

Usage

API Documentation

API Endpoints

Goods

  • POST /goods - Create a new good

Shops

  • POST /shops - Create a new shop

Stock

  • POST /stock - Create a stock entry

Basket

  • POST /basket - Create a basket entry

If you want to see more with examples, visit Endpoint Documentation.

Database Schema

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

Super User create

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)

Testing

# Run tests (when implemented)
pytest

Run the service

  • 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

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

Project Status

🚧 In Development - Basic CRUD operations implemented. Additional features in progress.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages