Setup Guide
This guide covers installing and configuring the NeuraSutra API Management server.
Prerequisites
- Python 3.14+
- Node.js 18+ (for admin dashboard)
- Redis (optional, for distributed rate limiting)
Backend Installation
Clone and Setup
cd /path/to/neurasutra_api_management/backend
# Create virtual environment
python3.14 -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
Generate Security Keys
# Generate bcrypt password hash for admin user
python -c "import bcrypt; print(bcrypt.hashpw(b'YOUR_PASSWORD', bcrypt.gensalt(12)).decode())"
# Generate JWT secret key
openssl rand -hex 32
# Generate Fernet encryption key for provider API keys
python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
Configure the Server
Copy the template and edit with your generated keys:
cp config.template.yaml config.yaml
config.yaml structure:
# Server Configuration
server:
host: "0.0.0.0"
port: 8000
workers: 4
# Database Configuration
database:
path: "./data/api_management.db"
wal_mode: true
# Admin Authentication
admins:
- username: admin
password_hash: "$2b$12$..." # Your bcrypt hash
# Session Management
session:
secret_key: "your-jwt-secret-from-openssl"
expiry_hours: 24
# API Key Settings
api_keys:
prefix: "sk_"
length: 48
# Batch Processing
batch:
max_size: 30
parallel_execution: true
max_parallel: 10
timeout_per_request: 60
# Provider Key Encryption
encryption:
key: "your-fernet-key"
# CORS Configuration
cors:
allowed_origins:
- "http://localhost:5173"
- "http://localhost:3000"
# Redis (optional)
redis:
enabled: false
url: "redis://localhost:6379/0"
Start the Server
# Development mode with auto-reload
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
# Production mode
uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 4
Frontend Dashboard (Optional)
cd /path/to/neurasutra_api_management/frontend
# Install dependencies
npm install
# Development mode
npm run dev
# Build for production
npm run build
Access the admin dashboard at http://localhost:5173
Docker Deployment
# Start all services
docker compose up -d
# View logs
docker compose logs -f backend
Verify Installation
# Health check
curl http://localhost:8000/api/v1/health
# Expected response:
# {"status": "healthy", "version": "1.0.0"}
Environment Variables
| Variable | Description | Default |
|---|---|---|
CONFIG_PATH |
Path to config.yaml | ./config.yaml |
LOG_LEVEL |
Logging verbosity | INFO |
DATABASE_URL |
Override database path | From config |
Next Steps
Once the server is running: