Skip to content

The Inventory Service is the backbone of Shipr's infrastructure, responsible for tracking product availability and stock management.

Notifications You must be signed in to change notification settings

Abdullahxz/shipr-inventory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shipr 🚢

Shipr is a personal project aimed at helping folks understand distributed microservice architecture. It’s a simple, lightweight system designed to manage products, process orders, and handle payments.

Shipr inventory service 📦

The Inventory Service is the backbone of Shipr's infrastructure, responsible for tracking product availability and stock management.

  • Main Application (main.py): The core of the inventory service, powered by FastAPI. It exposes RESTful APIs for CRUD oeprations.

  • Consumer (consumer.py): In conjunction with the main service, the consumer listens to Redis streams for updates on completed orders. When an order is processed, it adjusts inventory levels in real-time, ensuring that stock data is always accurate. In the event of an error, it triggers a refund process to maintain data integrity and customer satisfaction.

Architecture

Shipr Architecture

Getting Started

Prerequisites

  • Python 3.x
  • Redis

Installation

As a best practice, it is advised to create a virtual environment to store this project's dependencies separately. You can install virtualenv with

  1. Install virtualenv (optional)

    pip install virtualenv
  2. Create env (optional)

    python -m venv .venv
  3. Activate virtualenv (optional)

    source env/bin/activate
  4. Install depndencies

    pip install -r requirements.txt
  5. Make sure you have a .env file with following variables.

    # Redis configuration
    REDIS_HOST=xxx
    REDIS_PORT=xxx
    REDIS_DB=xxx
    
    # CORS configuration
    ALLOW_ORIGINS=xxx
    ALLOW_METHODS=xxx
    ALLOW_HEADERS=xxx
    
  6. Run server

    uvicorn main:app
  7. Run message consumer

    python consumer.py

About

The Inventory Service is the backbone of Shipr's infrastructure, responsible for tracking product availability and stock management.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages