Skip to content
/ MEDA Public

This repository develops an event-driven architecture with FastAPI. The project replicates MADE.com and the book 'Architecture Patterns with Python' by Harry J.W Percival & Bob Gregory

Notifications You must be signed in to change notification settings

sbundaz/MEDA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MEDA

This repository contains an event-driven architecture with FastAPI. The project implements a furniture retailer MADE from the book Architecture Patterns with Python by Harry J.W Percival & Bob Gregory.

Setup project

  • (the first time) setup Python 3.13.5 with pyenv: pyenv local 3.13.5 to create the .python-version file
  • (the first time) create venv: python3 -m venv .venv
  • activate venv: source .venv/bin/activate
  • install the development mode: pip install -e .[dev]

Running MADE application

  • Execute containers: docker compose up -d
  • Start FastAPI project: fastapi dev made/entrypoints/main.py
  • Start the event consumer: python3 -m made.entrypoints.redis_eventconsumer
  • Stop containers: docker compose down

Documentation at http://127.0.0.1:8000/docs

Healthcheck endpoint

curl -X 'GET' \
    'http://127.0.0.1:8000/health' \
    -H 'Content-Type: application/json'

Create batch

curl -X 'POST' \
    'http://127.0.0.1:8000/batches' \
    -H 'accept: application/json' \
    -H 'Content-Type: application/json' \
    -d '{
        "reference": "batch-001",
        "sku": "CHAIR",
        "quantity": 100
    }'

Allocate order

curl -X 'POST' \
    'http://localhost:8000/allocate' \
    -H "Content-Type: application/json" \
    -d '{
        "orderid": "order-001",
        "sku": "CHAIR",
        "qty": 10
    }'

Change Batch Quantity

Publish a message on change_batch_quantity Redis channel. The event will be processed by the redis_eventconsumer.

redis-cli -p 63791 PUBLISH change_batch_quantity '{"batchref": "batch-001", "qty": 200}'

Testing

  • test (all): pytest

About

This repository develops an event-driven architecture with FastAPI. The project replicates MADE.com and the book 'Architecture Patterns with Python' by Harry J.W Percival & Bob Gregory

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages