Keyboard shortcuts

Press โ† or โ†’ to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Quick Start Guide

Get the Pricing Engine running in 5 minutes.


Prerequisites

  • Docker and Docker Compose installed
  • Git for cloning the repository

๐Ÿš€ Setup Steps

1. Clone Repository (if not already)

cd /path/to/projects
git clone https://github.com/hungryhub-team/pricing-engine.git
cd pricing-engine

2. Start Services

# Start PostgreSQL, Redis, and API
docker-compose up -d

# Verify services are running
docker-compose ps

Expected output:

NAME                    STATUS
pricing-engine-api      Up
pricing-engine-db       Up
pricing-engine-redis    Up

3. Run Database Migrations

docker-compose exec api bundle exec rails db:migrate

4. Verify API is Running

curl http://localhost:3001/health

Expected response:

{
  "status": "ok",
  "timestamp": "2025-12-09T10:30:00Z"
}

๐Ÿงช Test the API

  1. Open Postman
  2. Import collection: docs/postman/Pricing_Engine_API.postman_collection.json
  3. Import environment: docs/postman/Pricing_Engine_Local.postman_environment.json
  4. Select โ€œPricing Engine - Localโ€ environment
  5. Get an OAuth token from your authentication service
  6. Try: Pricing Rules โ†’ List Rules

See POSTMAN_GUIDE.md for detailed setup.

Option 2: Using cURL

# Get OAuth token first (from your auth service)
TOKEN="your_bearer_token"

# List pricing rules
curl -X GET http://localhost:3001/api/partner/v1/pricing_rules \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json"

โœ… Verification Checklist

  • Docker containers running (docker-compose ps)
  • Database migrated successfully
  • Health endpoint returns {"status":"ok"}
  • Can authenticate with Bearer token
  • Can list pricing rules

๐Ÿ› Common Issues

Port 3001 Already in Use

# Check what's using the port
lsof -ti:3001

# Stop and restart
docker-compose down
docker-compose up -d

Database Connection Error

# Reset database
docker-compose down -v
docker-compose up -d
docker-compose exec api bundle exec rails db:setup

Authentication Failed

  • Verify PARTNER_ENGINE_BASE_URL in environment
  • Check OAuth token is valid
  • Ensure token is prefixed with Bearer

๐Ÿ“– Next Steps

Now that your environment is running:

  1. Understand Authentication: AUTHENTICATION.md
  2. Explore DateTime Rules: datetime-rule/README.md
  3. Read API Reference: API_REFERENCE.md
  4. Setup Postman: postman/SETUP_GUIDE.md

๐Ÿ› ๏ธ Useful Commands

# View logs
docker-compose logs -f api

# Run tests
docker-compose exec api bundle exec rspec

# Rails console
docker-compose exec api bundle exec rails console

# Stop services
docker-compose down

# Rebuild after code changes
docker-compose down
docker-compose build api
docker-compose up -d

Estimated Time: โฑ๏ธ 5 minutes
Difficulty: ๐ŸŸข Beginner
Next: AUTHENTICATION.md