Skip to content

Orbital Manager Backend

Welcome to the Orbital Manager Backend team wiki! ๐Ÿš€

๐ŸŒŸ What You'll Find Here

This comprehensive documentation covers everything you need to know about our backend microservices architecture.

๐Ÿค– AI Agents Start Here: This is the main entry point for understanding the codebase.

๐Ÿ“š Recent Updates

๐Ÿ—๏ธ System Architecture

graph TB
    subgraph External
        M[(MongoDB)]
        F[Frontend]
    end

    subgraph "Order Management Service :8000"
        ML[MongoDB Listener]
        OC[Order Client]
    end

    subgraph "Kitchen Batch Tool Service :8001"
        OS[Order Server :50051]
        SSE[SSE Endpoint]
        API[REST API]
    end

    M -->|Change Stream| ML
    ML -->|gRPC| OC
    OC -->|OrderRequest| OS
    OS -->|Events| SSE
    SSE -->|Real-time| F
    API -->|HTTP| F

๐Ÿ“ฆ Services

Order Management Service

Monitors MongoDB for new orders and distributes them to kitchen services.

Key Features: - MongoDB change stream monitoring - Async connections with retry logic - gRPC client for order sending

Kitchen Batch Tool Service

Receives orders and manages batch item processing.

Key Features: - gRPC server for order receiving - Server-Sent Events for real-time updates - REST API for batch item management - PostgreSQL for data persistence

๐Ÿ”ง Shared Components

Databases

  • MongoDB async initialization
  • PostgreSQL connection management
  • Connection retry logic

gRPC

  • Order client implementation
  • Order server implementation
  • Protocol buffer definitions

Patterns

  • BackgroundService base class
  • SingletonManager pattern

๐Ÿš€ Quick Start

# 1. Clone and install
git clone <repo-url>
cd orbital-manager-backend
pip install -r requirements.txt

# 2. Configure environment
cp .env.example .env
# Edit .env with your settings

# 3. Start services
# Terminal 1
cd order_management_service && uvicorn app.main:app --reload --port 8000

# Terminal 2  
cd kitchen_batch_tool_service && uvicorn app.main:app --reload --port 8001

# 4. Test
curl http://localhost:8000/ping
curl http://localhost:8001/ping

๐Ÿ’ก Common Tasks

Insert Test Order

db.orders.insertOne({
  OtterOrderId: "test-001",
  BrandName: "Test Restaurant",
  StationOrders: [{
    OwnStationName: "Grill Station",
    OrderItems: [
      { Name: "Burger", Quantity: 2 }
    ]
  }]
})

Watch Order Events (SSE)

curl -N http://localhost:8001/orders/events

Run Tests

pytest
pytest --cov=app

Lint Code

ruff check .
ruff check --fix .

๐Ÿ“Š Tech Stack

  • Language: Python 3.9+
  • Framework: FastAPI
  • Databases: MongoDB (orders), PostgreSQL (batch items)
  • RPC: gRPC + Protocol Buffers
  • Build System: Bazel
  • Linting: Ruff
  • Testing: pytest
  • Documentation: MkDocs Material

๐ŸŽฏ Key Features

Feature Description
Async MongoDB Non-blocking with exponential backoff retry (1s โ†’ 60s)
gRPC Communication Type-safe, efficient inter-service messaging
Server-Sent Events Real-time order updates to frontend
Structured Logging Context-rich logging for debugging
Monorepo Shared components across all services
Graceful Degradation Services continue running during failures

๐Ÿ“ˆ Performance

  • 93% payload reduction: Structured proto vs full JSON
  • Async all the way: Non-blocking I/O throughout
  • Connection pooling: Efficient resource usage
  • Type safety: Catch errors at compile time

๐Ÿ›ก๏ธ Resilience

  • MongoDB listener retries with exponential backoff
  • gRPC error handling and recovery
  • Services start even if dependencies are down
  • Graceful shutdown with 5-second grace period

๐Ÿค Contributing

We welcome contributions! Please read our Contributing Guide before submitting PRs.

Quick Checklist

  • Follow coding standards (run ruff check)
  • Add tests (aim for 80%+ coverage)
  • Update documentation
  • Write clear commit messages
  • Create focused PRs

๐Ÿ“ž Get Help

  • Documentation: You're reading it! ๐Ÿ“š
  • Issues: Check GitHub issues for known problems
  • Team Chat: #backend-dev on Slack
  • Email: team@orbitalkitchens.com

Learn the Architecture

Start with Architecture Overview to understand how everything fits together.

Set Up Development

Follow Getting Started to get your environment running.

Understand the Services

  • Order Management Service - Order detection and distribution
  • Kitchen Batch Tool Service - Order processing and batch management

Work with Shared Code

  • Shared Components - Reusable libraries and patterns

**Built with โค๏ธ by the Orbital Kitchens Team** [Report a Bug](https://github.com/your-org/orbital-manager-backend/issues) ยท [Request a Feature](https://github.com/your-org/orbital-manager-backend/issues) ยท [View Source](https://github.com/your-org/orbital-manager-backend)