Microservice for rendering astrological natal charts as images using the nocturna-wheel library.
- 🎯 Natal Chart Rendering: Generate natal charts as PNG/SVG/JPEG images
- 🌍 Transit Charts: Overlay current transits on natal chart
- 💑 Synastry Charts: Compare two people's natal charts
- 🔄 Biwheel Charts: Generic dual chart support for progressions, solar returns, and more
- 🔒 API Key Authentication: Secure access control
- ⚡ Rate Limiting: Protect against abuse
- 📊 Prometheus Metrics: Built-in monitoring
- 🐳 Docker Ready: Easy deployment with containers
- 📝 OpenAPI Documentation: Complete API specification
- Node.js 20 LTS or higher
- Chrome/Chromium browser (automatically installed with Puppeteer)
# Clone repository
git clone <repository-url>
cd nocturna-chart-service
# Install dependencies
npm install
# Copy environment variables
cp .env.example .env
# Edit .env with your configuration
# Set API_KEY to a secure random string
# Start development server
npm run devThe service will start on http://localhost:3000
POST /api/v1/chart/render
Content-Type: application/json
Authorization: Bearer your-api-key
{
"planets": {
"sun": { "lon": 85.83, "lat": 0.0 },
"moon": { "lon": 133.21, "lat": 5.12 }
// ... other planets
},
"houses": [
{ "lon": 300.32 },
// ... 12 houses total
],
"renderOptions": {
"format": "png",
"width": 800,
"height": 800
}
}POST /api/v1/chart/render/transitPOST /api/v1/chart/render/synastryPOST /api/v1/chart/render/biwheel
Content-Type: application/json
Authorization: Bearer your-api-key
{
"inner": {
"name": "Natal Chart",
"planets": { /* ... */ },
"houses": [ /* ... */ ]
},
"outer": {
"name": "Progressed Chart",
"planets": { /* ... */ }
},
"biwheelSettings": {
"useHousesFrom": "inner",
"aspectSettings": {
"inner": { "enabled": true, "orb": 6 },
"outer": { "enabled": true, "orb": 6 },
"crossAspects": { "enabled": true, "orb": 3 }
}
},
"renderOptions": {
"format": "png",
"width": 1000,
"height": 1000
}
}GET /healthGET /metricsSee .env.example for all available configuration options:
| Variable | Default | Description |
|---|---|---|
PORT |
3000 |
Server port |
API_KEY |
- | API authentication key (required) |
MAX_CONCURRENT_RENDERS |
5 |
Max parallel browser instances |
RENDER_TIMEOUT |
10000 |
Render timeout in milliseconds |
RATE_LIMIT_MAX_REQUESTS |
100 |
Max requests per window |
LOG_LEVEL |
info |
Logging level (debug, info, warn, error) |
# Run in development mode with auto-reload
npm run dev
# Run tests
npm test
# Run tests in watch mode
npm run test:watch
# Lint code
npm run lint
# Format code
npm run formatUnified deployment scripts for all environments:
# Deploy to staging
./scripts/deploy.sh staging
# Deploy to production (blue-green)
./scripts/deploy.sh production
# Check status
./scripts/status.shSingle container for testing:
# Deploy
./scripts/deploy.sh staging
# Test
curl http://localhost:3013/health
# View logs
docker-compose -f deploy/stage/docker-compose.stage.yml logs -fPort: 3013
Zero-downtime deployment with two slots:
# Deploy to inactive slot (auto-detected)
./scripts/deploy.sh production
# Test new deployment
curl http://localhost:3014/health # blue
curl http://localhost:3012/health # green
# Switch traffic
./scripts/switch.sh
# Rollback if needed
./scripts/rollback.shPorts:
- Blue slot: 3014
- Green slot: 3012
Benefits:
- Zero downtime deployments
- Instant rollback capability
- Test before going live
- Both slots available for A/B testing
# Build image
docker build -t nocturna-chart-service .
# Run container
docker run -p 3011:3011 \
-e API_KEY=your-secret-key \
-e NODE_ENV=production \
nocturna-chart-serviceThe Dockerfile uses multi-stage builds with BuildKit cache:
# Fast build (uses cache)
DOCKER_BUILDKIT=1 docker build -t nocturna-chart-service .
# Full rebuild
docker build --no-cache -t nocturna-chart-service .Build stages:
- Base: System dependencies (Chromium, fonts)
- Dependencies: npm packages
- Production: Application code
Code changes trigger fast rebuilds (< 30 seconds) thanks to layer caching.
See docs/INTEGRATION.md for Python client implementation and usage examples.
| Metric | Target | Critical |
|---|---|---|
| Response Time (p95) | < 3 sec | < 5 sec |
| Throughput | 10 req/min | 5 req/min |
| Error Rate | < 1% | < 5% |
Prometheus metrics available at /metrics:
chart_renders_total- Total render countchart_render_duration_seconds- Render duration histogramchart_render_errors_total- Error count by typebrowser_instances_active- Active browser count
MIT
- API Documentation - Complete API reference
- Deployment Guide - Production deployment & blue-green setup
- Script Documentation - Deployment scripts usage
- Biwheel Charts - Dual chart support
- Integration Guide - Client implementation examples
- Project Structure - Codebase organization