Full Installation Guide¶
This guide provides complete instructions for setting up a CalcBridge development environment with all components, including the API server, database, cache, workers, and optional frontend.
System Requirements¶
Minimum Requirements¶
| Component | Requirement |
|---|---|
| CPU | 4 cores |
| RAM | 8 GB |
| Disk | 20 GB free space |
| OS | macOS 12+, Ubuntu 20.04+, Windows 10+ (WSL2) |
Software Dependencies¶
| Software | Version | Required |
|---|---|---|
| Python | 3.11 or 3.12 | Yes |
| Docker | 24.0+ | Yes |
| Docker Compose | 2.20+ | Yes |
| Git | 2.30+ | Yes |
| Node.js | 18+ | Optional (frontend) |
| npm | 9+ | Optional (frontend) |
Step 1: Clone the Repository¶
# Clone the repository
git clone https://github.com/InsightCapital/calcbridge.git
cd calcbridge
# Verify you're in the right directory
ls -la
# You should see: docker-compose.yml, pyproject.toml, src/, etc.
Step 2: Create Python Virtual Environment¶
Step 3: Install Python Dependencies¶
# Install all dependencies (recommended for development)
pip install -e ".[dev,test]"
# Or install from requirements files
pip install -r requirements.txt # Production only
pip install -r requirements-dev.txt # Development + testing
Dependency Groups
| Group | Includes |
|---|---|
| Base | FastAPI, SQLAlchemy, Celery, pandas, openpyxl |
dev | ruff, mypy, pre-commit |
test | pytest, pytest-asyncio, testcontainers, hypothesis |
loadtest | locust, gevent |
Step 4: Set Up Environment Variables¶
Copy the example environment file and customize it:
# Copy the example file
cp .env.example .env
# Open in your editor
code .env # or vim .env, nano .env
Required Changes for Production
The following values MUST be changed before deploying to production:
Update these values in .env:
Essential Configuration¶
# Environment
ENVIRONMENT=development
DEBUG=false
LOG_LEVEL=INFO
# Database (matches docker-compose.yml)
DATABASE_URL=postgresql+psycopg://calcbridge:calcbridge_dev@localhost:5433/calcbridge
# Cache (matches docker-compose.yml)
VALKEY_HOST=localhost
VALKEY_PORT=6380
# Security (CHANGE IN PRODUCTION)
JWT_SECRET_KEY=change-me-in-production-use-a-secure-random-key
ENCRYPTION_MASTER_KEY=change-me-in-production-use-a-secure-random-key
Step 5: Start Infrastructure Services¶
Start PostgreSQL and Valkey using Docker Compose:
# Start core infrastructure
docker compose up -d postgres valkey
# Verify services are healthy
docker compose ps
# View logs if needed
docker compose logs -f postgres valkey
Expected Output
Service Details¶
| Service | Container | Port (Host) | Port (Container) |
|---|---|---|---|
| PostgreSQL | calcbridge-postgres | 5433 | 5432 |
| Valkey | calcbridge-valkey | 6380 | 6379 |
Step 6: Run Database Migrations¶
Apply the SQL migrations to set up the database schema:
Verify Migration Success
Step 7: Start the API Server¶
Launch the FastAPI server with development settings:
# Development mode with hot reload
PYTHONPATH=. uvicorn src.api.main:app --reload --port 8000
# Or with more workers for testing
PYTHONPATH=. uvicorn src.api.main:app --workers 4 --port 8000
Verify the Server¶
- Health Check: http://localhost:8000/health
- API Documentation: http://localhost:8000/docs
- OpenAPI Schema: http://localhost:8000/openapi.json
Server Running
Step 8: Start Celery Workers (Optional)¶
For background task processing (Excel parsing, calculations):
Step 9: Start the Frontend (Optional)¶
If you want to use the web interface:
# Navigate to frontend directory
cd frontend
# Install dependencies
npm install
# Start development server
npm run dev
# Access at http://localhost:3002
Frontend Port
The frontend runs on port 3002 by default to avoid conflicts with other services.
Verify Installation¶
Run the test suite to verify everything is working:
# Run unit tests (no Docker required)
PYTHONPATH=. pytest tests/unit/ -v
# Run integration tests (requires Docker)
PYTHONPATH=. pytest tests/integration/ -v
# Run all tests with coverage
PYTHONPATH=. pytest tests/ --cov=src --cov-report=html
Quick Smoke Test¶
# Test API health
curl http://localhost:8000/health
# Test API readiness (database + cache)
curl http://localhost:8000/health/ready
# Register a test user
curl -X POST http://localhost:8000/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{"email":"test@example.com","password":"TestPass123!","full_name":"Test User","organization_name":"Test Org"}'
Docker Compose Services Reference¶
The full docker-compose.yml includes these services:
| Service | Profile | Purpose |
|---|---|---|
postgres | default | PostgreSQL 16 database |
valkey | default | Valkey cache (Redis-compatible) |
api | default | FastAPI application |
celery-worker | default | Default task worker |
celery-worker-calc | default | Calculation worker |
celery-worker-dlq | default | Dead letter queue worker |
celery-beat | default | Task scheduler |
flower | monitoring | Celery monitoring UI |
prometheus | monitoring | Metrics collection |
grafana | monitoring | Metrics visualization |
alertmanager | monitoring | Alert routing |
Starting Different Profiles¶
# Core services only
docker compose up -d postgres valkey
# All default services
docker compose up -d
# With monitoring stack
docker compose --profile monitoring up -d
Directory Structure¶
After installation, your directory should look like this:
calcbridge/
├── .venv/ # Python virtual environment
├── .env # Environment configuration
├── docker-compose.yml # Service orchestration
├── pyproject.toml # Python project config
├── src/
│ ├── api/ # FastAPI application
│ ├── calculations/ # Formula engine
│ ├── core/ # Core utilities
│ ├── db/ # Database layer
│ ├── imports/ # Excel parser
│ ├── services/ # Business services
│ └── workers/ # Celery tasks
├── db/
│ └── migrations/ # SQL migrations
├── tests/
│ ├── unit/ # Unit tests
│ ├── integration/ # Integration tests
│ └── security/ # Security tests
├── frontend/ # Next.js frontend
└── config/ # Prometheus, Grafana configs
Next Steps¶
- Your First Workbook: Learn to upload and work with Excel files
- Configuration Guide: Detailed environment variable reference
- API Reference: Explore the REST API
- Compliance Testing: Set up automated tests