Skip to content

Getting Started

๐Ÿš€ Quick Start Guide

This guide will help you set up the Orbital Manager Backend development environment.

Prerequisites

  • Python: 3.9 or higher
  • MongoDB: 4.0+ (for order storage)
  • PostgreSQL: 12+ (for batch items)
  • Bazel: 6.0+ (for building)
  • Git: For version control

๐Ÿ“ฅ Installation

1. Clone the Repository

git clone <repository-url>
cd orbital-manager-backend

2. Install Python Dependencies

pip install -r requirements.txt

3. Set Up Environment Variables

Create .env files for each service:

Order Management Service (.env in root or service folder):

# MongoDB
MONGO_URI=mongodb://localhost:27017
MONGO_DB=orbital_kitchen
MONGO_ORDERS_COLLECTION=orders

# gRPC
GRPC_TARGET=localhost:50051

Kitchen Batch Tool Service:

# PostgreSQL
POSTGRES_SUPABASE_URL=postgresql://user:pass@localhost:5432/orbital_kitchen

# gRPC
GRPC_PORT=50051

4. Set Up Databases

MongoDB:

# Start MongoDB
mongod --dbpath /path/to/data

# Create database (optional - auto-created on first insert)
mongosh
> use orbital_kitchen
> db.orders.insertOne({test: "order"})

PostgreSQL:

# Create database
createdb orbital_kitchen

# Tables are auto-created on service startup

๐Ÿƒ Running Services

Option 1: Using uvicorn (Development)

Terminal 1 - Order Management Service:

cd order_management_service
uvicorn app.main:app --reload --port 8000

Terminal 2 - Kitchen Batch Tool Service:

cd kitchen_batch_tool_service
uvicorn app.main:app --reload --port 8001

Option 2: Using Bazel

# Build all services
bazel build //...

# Run Order Management Service
bazel run //order_management_service:order_management_service

# Run Kitchen Batch Tool Service
bazel run //kitchen_batch_tool_service:kitchen_batch_tool_service

โœ… Verify Setup

Health Checks

# Check Order Management Service
curl http://localhost:8000/ping

# Check Kitchen Batch Tool Service
curl http://localhost:8001/ping

Test Order Flow

Insert a test order into MongoDB:

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

Expected Output:

  1. Order Management Service logs: "Order sent successfully"
  2. Kitchen Batch Tool Service console displays formatted order
  3. SSE stream (if connected) receives event

Test SSE Stream

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

๐Ÿงช Running Tests

# Run all tests
bazel test //...

# Run specific service tests
pytest order_management_service/tests/
pytest kitchen_batch_tool_service/tests/

# Run with coverage
pytest --cov=app tests/

๐Ÿ”ง Development Tools

Linting

# Check all code
ruff check .

# Auto-fix issues
ruff check --fix .

# Format code
ruff format .

Type Checking

# Run mypy (if configured)
mypy order_management_service/app/
mypy kitchen_batch_tool_service/app/

๐Ÿ› Troubleshooting

MongoDB Connection Issues

Problem: MongoDBconnection not available, retrying...

Solution: - Verify MongoDB is running: mongosh - Check MONGO_URI in .env - Check firewall settings

gRPC Connection Issues

Problem: gRPC client not connected

Solution: - Ensure Kitchen Batch Tool Service is running - Check GRPC_TARGET points to correct host:port - Verify GRPC_PORT matches on server side

Port Already in Use

Problem: Address already in use

Solution:

# Find process using the port
lsof -i :8000
lsof -i :8001

# Kill the process
kill -9 <PID>

๐Ÿ“š Next Steps

๐Ÿ’ก Tips

  • Use --reload flag during development for auto-restart
  • Check logs for detailed error messages
  • Monitor both service consoles when testing order flow
  • Use structured logging fields for better debugging