Complete development environment setup for Piper Morgan. This guide will get you from zero to a fully functional development environment.
Piper Morgan specifically requires Python 3.11 for asyncio.timeout support and other 3.11-specific features. Using Python 3.12+ will cause compatibility issues.
# Clone the repository
git clone https://github.com/mediajunkie/piper-morgan-product.git
cd piper-morgan-product
# Verify .python-version file
cat .python-version # Should show 3.11
# Verify Python version (must be 3.11 exactly)
python --version # Should show Python 3.11.x
# Set up Python virtual environment with Python 3.11
python3.11 -m venv venv # Explicitly use Python 3.11
source venv/bin/activate # On Windows: venv\Scripts\activate
# Verify Python version in virtual environment
python --version # Should show Python 3.11.x
# Install dependencies
pip install -r requirements.txt
# Verify asyncio.timeout availability (requires Python 3.11)
python -c "import asyncio; asyncio.timeout(1.0); print('✅ Python 3.11 verified')"
Copy the example environment file and configure:
# Copy environment template
cp .env.example .env
# Edit .env with your API keys and configuration
Required Environment Variables:
# AI Integration
ANTHROPIC_API_KEY=required
OPENAI_API_KEY=required
# GitHub Integration
GITHUB_TOKEN=for_gh_commands
# Database Configuration
DATABASE_URL=postgresql://piper:dev_changeme_in_production@localhost:5433/piper_morgan
# Redis Configuration
REDIS_URL=redis://localhost:6379
Configuration Notes:
# Start infrastructure services
docker-compose up -d postgres redis
# Initialize the database
python scripts/init_db.py
# Verify database connection
docker exec -it piper-postgres psql -U piper -d piper_morgan
# Docker containers now use Python 3.11
docker-compose build
docker-compose up
# Verify container Python version
docker-compose exec app python --version # Should show Python 3.11.x
# Start the development server
python main.py # API runs on port 8001
# Start the web interface (separate terminal)
cd web && python -m uvicorn app:app --reload --port 8081
# Run comprehensive tests
PYTHONPATH=. python -m pytest tests/unit/ -v
# Verify asyncio.timeout functionality
python -c "import asyncio; asyncio.timeout(1.0); print('✅ Python 3.11 asyncio support verified')"
CRITICAL: Always use the full PYTHONPATH prefix. Never use bare pytest.
# Run all tests
PYTHONPATH=. pytest
# Run API query integration tests
PYTHONPATH=. pytest tests/test_api_query_integration.py
# Unit tests
PYTHONPATH=. python -m pytest tests/unit/ -v
# Integration tests
PYTHONPATH=. python -m pytest tests/integration/ -v
# Run with coverage reporting
PYTHONPATH=. python -m pytest tests/ --cov=services --cov-report=term-missing
# Fast failure mode for development
PYTHONPATH=. python -m pytest tests/ -x -v
# Database-free testing (Excellence Flywheel infrastructure)
python tests/orchestration/run_standalone_tests.py
# Specific test
PYTHONPATH=. python -m pytest tests/integration/test_file.py::TestClass::test_method -v
Testing Notes:
async_transaction fixture for database tests# Access PostgreSQL
docker exec -it piper-postgres psql -U piper -d piper_morgan
# View logs
docker-compose logs postgres
docker-compose logs redis
Follow the project’s architectural patterns:
services/domain/models.py drive everythingAsyncSessionFactory.session_scope() for all DB operationsservices/shared_types.pyservices/
├── domain/models.py # Source of truth - check first
├── shared_types.py # All enums here
├── orchestration/ # Workflows, multi-agent coordination
├── queries/ # Read operations (CQRS)
├── repositories/ # Data access only
└── integrations/ # GitHub, Slack, external
tests/
├── unit/ # Fast, mocked tests
├── integration/ # Real DB tests (port 5433)
└── conftest.py # Fixtures: async_session, async_transaction
Excellence Flywheel Methodology: Verify first → Implement second → Evidence-based progress
grep -r "pattern" services/ --include="*.py" -A 3 -B 3 # Find existing patterns
cat services/domain/models.py | grep "class" # Check domain models
find . -name "*.py" -exec grep -l "ADR-" {} \; # Find architectural decisions
services/domain/models.py)services/shared_types.pyPYTHONPATH=. python -m pytest [test] -v # Run actual tests
# See "X passed" before claiming success
services/domain/models.py (source of truth)alembic revision --autogenerate -m "description"alembic upgrade headAsyncSessionFactory.session_scope() patterndevelopment/session-logs/YYYY-MM-DD-log.mddocs/development/prompts/*-handoff-*.mdPYTHONPATH=. is used (never bare pytest)async_transaction fixture for database testspython main.py output# View all Docker services
docker-compose ps
# Restart a specific service
docker-compose restart postgres
# View application logs
docker-compose logs -f api
# View database and Redis logs
docker-compose logs postgres
docker-compose logs redis
# CLI Standup (Production Feature)
python main.py standup # <2 second execution, beautiful formatting
# Pre-commit Hook Strategy
# Check what pre-commit will do without changing files
pre-commit run --all-files --show-diff-on-failure
# Let pre-commit fix formatting issues
pre-commit run --all-files
# Skip specific hooks if needed (emergency use only)
SKIP=end-of-file-fixer,trailing-whitespace git commit -m "Your message"
For testing MCP integration and production readiness:
# One-command staging deployment
./scripts/deploy_staging.sh
# Verify staging deployment (14 comprehensive tests)
./scripts/verify_staging_deployment.sh
# Access staging services
# API: http://localhost:8001
# Web UI: http://localhost:8081
# Grafana: http://localhost:3001
# Prometheus: http://localhost:9090
Staging Features:
Domain-Driven Design:
services/domain/models.py drive everything - DB follows modelsAsyncSessionFactory.session_scope() for all DB operationsservices/shared_types.py onlyMCP + Spatial Intelligence:
Piper Morgan uses a three-tier documentation structure:
For production deployment, see the Production Guide. For API integration, see API Integration.