Skip to content

Hoomanfr/harry

Repository files navigation

Harry is a personal project exploring a microservices architecture to process returned items in a warehouse. It uses NATS for messaging and Centrifugo with WebSockets to notify fulfillment clients in real time, which helps unblock fulfillment items.

Architecture

Receive Returned Items Flow

Getting Started

Prerequisites

  • Docker & Docker Compose
  • Make

Quick Start

  1. Start all services:

    make run-all

    This will automatically:

    • Start infrastructure services (PostgreSQL, NATS, Redis, Centrifugo)
    • Create databases and run migrations
    • Build and start all microservices
  2. Generate Centrifugo token for WebSocket testing:

    docker exec -it centrifugo centrifugo gentoken -u 123722

    Copy the generated token for use in .env files and Postman.

Testing the Flow

  1. Create test data in fulfillment database:

    INSERT INTO dbo.fulfillment
    (id, order_id, sku, quantity, status, fulfilled_at)
    VALUES(nextval('dbo.fulfillment_id_seq'::regclass), 10, 'sku-1234', 2, 'blocked', CURRENT_TIMESTAMP);
    
    SELECT id, order_id, sku, quantity, status, fulfilled_at
    FROM dbo.fulfillment;
  2. Connect to WebSocket using Postman:

    Connect to: ws://localhost:8000/connection/websocket?cf_ws_frame_ping_pong=true

    Send these messages:

    {"id": 1, "connect": { "token": "<the_generated_token>"}}
    {"id": 2, "subscribe": {"channel": "fulfillment.order_unblocked"}}
  3. Test the return item API:

    curl --location 'http://localhost:8080/return-item' \
    --header 'Content-Type: application/json' \
    --data '{
        "sku": "sku-5234",
        "quantity": 2
    }'

Available Commands

  • make run-all - Build and start all services (detached)
  • make dev-up - Build and start all services (foreground with logs)
  • make stop-all - Stop all services
  • make logs - View logs from all services
  • make restart - Restart all services

Individual Service Commands

See the Makefile for individual service build/run commands for development.

About

Harry is a personal project exploring a microservices architecture to process returned items in a warehouse. It uses `NATS` for `messaging` and `Centrifugo` with `WebSockets` to notify fulfillment clients in real time, which helps unblock fulfillment items.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors