OllamaMax is an enterprise-grade distributed AI model platform that transforms single-node Ollama architecture into a horizontally scalable, fault-tolerant distributed system. This guide helps agents understand how to work effectively in this complex codebase.
- Backend: Go 1.24.5+ (primary), Node.js 18+ (API gateway)
- Frontend: JavaScript/TypeScript, React
- Database: PostgreSQL (primary), SQLite (development), Redis (caching)
- Infrastructure: Docker, Kubernetes, Docker Compose
- Monitoring: Prometheus, Grafana, Jaeger, ELK Stack
- Testing: Jest, Playwright, Go testing framework
🌐 Load Balancer (NGINX)
↓
🎛️ API Gateway (Node.js:13100)
↓
🔗 Consensus Layer (Raft-based)
↓
🌐 P2P Network (libp2p)
↓
🤖 Model Distribution & Serving
↓
💾 Storage (PostgreSQL + Redis)
.
├── cmd/ # Go command-line applications
├── pkg/ # Go packages (core business logic)
│ ├── api/ # API handlers & middleware
│ ├── auth/ # Authentication & JWT
│ ├── consensus/ # Raft consensus implementation
│ ├── distributed/ # Distributed systems logic
│ ├── p2p/ # Peer-to-peer networking
│ ├── scheduler/ # Intelligent scheduling
│ └── security/ # Security components
├── src/ # Node.js source code
│ ├── server.js # Main API server
│ ├── routes/ # API route handlers
│ ├── services/ # Business logic services
│ └── middleware/ # Express middleware
├── api-server/ # Legacy API server
├── web-interface/ # Frontend web interface
├── tests/ # Comprehensive test suites
├── scripts/ # Build, deployment, utility scripts
├── .bmad-core/ # Agent workflows & templates
├── .claude/ # Claude Flow integration
├── docker/ # Docker configurations
├── k8s/ # Kubernetes manifests
├── monitoring/ # Monitoring stack configs
└── docs/ # Documentation
# Install dependencies
npm ci
go mod download
# Set up environment
cp .env.example .env
# Edit .env with proper credentials
# Quick start
npm run dev# Build Go binary
make build-app
# OR
go build -o bin/ollamamax ./cmd/ollama-distributed
# Build Node.js application
npm run build
# Build Docker image
docker build -t ollamamax:latest .# Unit tests (Go)
go test -v ./pkg/... ./internal/... ./cmd/...
# Unit tests (JavaScript)
npm run test
# Integration tests
npm run test:integration
# E2E tests
npm run test:e2e
# Performance tests
npm run test:performance
# Security tests
npm run test:security
# Comprehensive test suite
npm run test:all
# Coverage validation (90% threshold)
npm run test:coverage# Local CI validation
npm run validate:ci
# Docker build & test
npm run build-and-test-docker
# Deployment validation
bash scripts/run-deployment-validation.sh- Error Handling: Use wrapped errors with
fmt.Errorf("context: %w", err) - Logging: Structured logging with
slog - Configuration: Centralized config with validation
- Testing: Table-driven tests, 90% coverage minimum
- Documentation: Comprehensive godoc comments
- Error Handling: Async/await with try-catch
- Authentication: JWT middleware pattern
- API Design: RESTful with OpenAPI specs
- Testing: Jest with 90% coverage minimum
- Security: Input validation, rate limiting, CORS
- JWT Authentication: RS256 with 2048-bit keys
- Password Hashing: bcrypt with 12 rounds
- Rate Limiting: Per-endpoint rate limiting
- Input Validation: Comprehensive validation middleware
- Security Headers: Helmet.js implementation
-
Unit Tests (90% coverage required)
- Go:
pkg/*/test.go - JavaScript:
*.test.js
- Go:
-
Integration Tests
- API integration tests
- Database integration tests
- Service-to-service tests
-
E2E Tests
- Playwright browser tests
- Full user workflow validation
- Cross-browser testing
-
Performance Tests
- Load testing with k6
- Stress testing
- Benchmarking
tests/
├── e2e/ # Playwright E2E tests
├── integration/ # Integration test suites
├── ml/ # Machine learning tests
├── deployment/ # Deployment validation
├── performance/ # Performance benchmarks
└── security/ # Security validation
# Run specific test types
npm run test:auth # Authentication tests
npm run test:api # API health tests
npm run test:load # Load tests
npm run test:performance # Performance tests
# Coverage reporting
npm run test:coverage:report
npm run test:coverage:ci# Development
export NODE_ENV=development
export LOG_LEVEL=debug
# Staging
export NODE_ENV=staging
export LOG_LEVEL=info
# Production
export NODE_ENV=production
export LOG_LEVEL=warn
export SSL_ENABLED=true
export TLS_ENABLED=true.env- Environment variablesconfig/*.yaml- Application configurationdocker-compose.yml- Docker servicesk8s/*.yaml- Kubernetes manifestsmonitoring/*.yaml- Monitoring configuration
# Validate configuration
ollama-distributed validate --fix
# Check environment
npm run validate:config# Build and run
docker-compose up -d
# Production deployment
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
# Health checks
curl http://localhost:13100/health# Deploy to Kubernetes
kubectl apply -f k8s/
# Helm deployment
helm install ollamamax ollamamax/ollamamax-cluster
# Monitoring deployment
kubectl apply -f monitoring/# Start monitoring
docker-compose up -d prometheus grafana alertmanager
# Access dashboards
echo "Grafana: http://localhost:3001"
echo "Prometheus: http://localhost:9090"# Agent commands
npm run agents:spawn
npm run agents:orchestrate
npm run agents:status
# Smart agent integration
node src/agents/claude-flow-integration.js spawn- Located in
.bmad-core/,.bmad-creative-writing/,.bmad-infrastructure-devops/ - YAML-based workflow definitions
- Template-driven documentation generation
- Checklist-based quality gates
web-bundles/teams/
├── team-all.txt # All agents
├── team-fullstack.txt # Fullstack team
├── team-ide-minimal.txt # Minimal IDE team
└── team-no-ui.txt # Backend-only team
- JWT Secrets: Must be 32+ characters, never use defaults
- Database Passwords: Required in production, 8+ characters minimum
- CORS Configuration: Restrict origins in production
- SSL/TLS: Required for production deployments
- Environment Variables: Never commit secrets to version control
- Port Conflicts: Uses non-standard ports (PostgreSQL: 15432, Redis: 16379)
- Coverage Thresholds: 90% minimum for both Go and JavaScript
- Docker Networking: Complex service dependencies
- Database Migrations: Must run before starting services
- Memory Requirements: High memory usage for AI models
- Model Loading: Large memory footprint for AI models
- Database Connections: Connection pooling required
- Redis Caching: Critical for performance
- Load Balancing: Round-robin with health checks
- Monitoring Overhead: Tracing and metrics impact
- Branch Strategy:
main(production),develop(staging), feature branches - Testing: All tests must pass before merge
- Code Review: Required for all changes
- Documentation: Auto-generated from code comments
- CI/CD: Automated testing and deployment
# Linting
npm run lint
go vet ./...
# Formatting
gofmt -s -w .
npm run format
# Dependency management
go mod tidy
npm audit# Performance monitoring
npm run test:performance:report
# Security scanning
npm run deploy:scan:vulnerabilities
# Coverage reporting
npm run coverage-report# Health checks
curl http://localhost:13100/health/live
curl http://localhost:13100/health/ready
# Metrics
curl http://localhost:13100/metrics
# Logs
docker-compose logs -fmain.go- Go backend entry pointsrc/server.js- Node.js API servercmd/ollama-distributed/main.go- CLI applicationweb-interface/index.html- Web interface
.env.example- Environment templatepackage.json- Node.js configurationgo.mod- Go module definitiondocker-compose.yml- Service orchestrationk8s/deployment.yaml- Kubernetes deployment
README.md- Project overviewdocs/- Detailed documentationclaudedocs/- Generated system analysisCOMPREHENSIVE_SYSTEM_REVIEW.md- System assessment
This guide provides agents with the essential knowledge to navigate, develop, test, and deploy the OllamaMax platform effectively.