Databricks Apps Deployment Guide
Overviewβ
The Oral Health Policy Pulse application has been refactored as a React + FastAPI Databricks App, providing:
- π¨ Modern React UI with TypeScript, Tailwind CSS, and interactive visualizations
- β‘ FastAPI Backend serving both API and static frontend
- βοΈ Databricks Apps Deployment with Unity Catalog integration
- π Enterprise Security via Databricks secrets and authentication
- π Real-time Analytics powered by Delta Lake and Model Serving
Architectureβ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Databricks Workspace β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Databricks App (This Application) β β
β β β β
β β ββββββββββββββββ ββββββββββββββββββββ β β
β β β React β ββββΆ β FastAPI Backend β β β
β β β Frontend β β β β β
β β β (TypeScript) β β β’ REST API β β β
β β β β β β’ Static Serving β β β
β β ββββββββββββββββ ββββββββββββββββββββ β β
β β β β β
β βββββββββββββββββββββββββββββββββΌββββββββββββββββββ β
β β β
β βββββββββββββββββββββββββββββββββΌββββββββββββββββββ β
β β Unity Catalog & Delta Lake β β
β β β’ raw_documents β β
β β β’ classified_documents β β
β β β’ advocacy_opportunities β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Model Serving Endpoints β β
β β β’ policy-classifier-prod β β
β β β’ sentiment-analyzer-prod β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Prerequisitesβ
1. Databricks Workspaceβ
- Databricks Runtime 14.3 LTS ML or higher
- Unity Catalog enabled
- Model Serving enabled
2. Local Development Toolsβ
- Python 3.11+
- Node.js 20+
- Databricks CLI
3. API Keysβ
- OpenAI API key (for LLM-based classification)
- Anthropic API key (optional)
Local Developmentβ
Setupβ
# Clone and setup
cd open-navigator
./scripts/setup-local.sh
Run Development Serverβ
Option 1: Separate Frontend + Backend (Hot Reload)
# Terminal 1 - Backend
source venv/bin/activate
uvicorn api.app:app --reload
# Terminal 2 - Frontend
cd frontend
npm run dev
Visit: http://localhost:3000
Option 2: Production Mode (Serves Built Frontend)
# Build frontend first
cd frontend
npm run build
cd ..
# Run app
source venv/bin/activate
python scripts/test-app.py
Visit: http://localhost:8000
Deploying to Databricks Appsβ
Step 1: Configure Environmentβ
# Set Databricks credentials
export DATABRICKS_HOST=https://your-workspace.cloud.databricks.com
export DATABRICKS_TOKEN=dapi1234567890abcdef
# Set API keys
export OPENAI_API_KEY=sk-...
export ANTHROPIC_API_KEY=sk-ant-...
Step 2: Deployβ
# One-command deployment
./scripts/deploy-databricks-app.sh
This script will:
- β Build React frontend (optimized production build)
- β Create Databricks secrets for credentials
- β Deploy app to Databricks Apps
- β Configure Model Serving endpoints
- β Provide access URL
Step 3: Access Your Appβ
Once deployed, access at:
https://your-workspace.cloud.databricks.com/apps/open-navigator
Configurationβ
app.yamlβ
The main configuration file for Databricks Apps:
command:
- "uvicorn"
- "api.app:app"
- "--host"
- "0.0.0.0"
- "--port"
- "8000"
env:
- name: DATABRICKS_HOST
valueFrom:
databricksSecret:
key: host
scope: oral-health-app
- name: OPENAI_API_KEY
valueFrom:
databricksSecret:
key: openai_key
scope: oral-health-app
resources:
- name: policy-classifier-endpoint
modelServing:
endpoint: policy-classifier-prod
port: 8000
Environment Variablesβ
| Variable | Description | Required |
|---|---|---|
DATABRICKS_HOST | Workspace URL | Yes |
DATABRICKS_TOKEN | Access token | Yes |
DATABRICKS_WAREHOUSE_ID | SQL warehouse ID | Yes |
OPENAI_API_KEY | OpenAI API key | Yes |
ANTHROPIC_API_KEY | Anthropic API key | No |
CATALOG_NAME | Unity Catalog name | Yes |
SCHEMA_NAME | Schema name | Yes |
Frontend Featuresβ
Dashboardβ
- π Real-time statistics
- π Topic distribution charts
- π Recent opportunities list
Interactive Heatmapβ
- πΊοΈ Geographic visualization
- π― Filterable by state, topic, urgency
- π‘ Click markers for details
Documents Browserβ
- π Full-text search
- π Paginated results
- π·οΈ Topic tags
Opportunities Managerβ
- π¨ Urgency-based filtering
- βοΈ One-click email generation
- π Meeting calendar integration
Settings Panelβ
- βοΈ Configure target states
- π Select policy topics
- π Email notifications
- π Agent status monitoring
API Endpointsβ
Core Endpointsβ
GET /api/health - Health check
GET /api/dashboard - Dashboard statistics
GET /api/opportunities - List opportunities (filterable)
GET /api/documents - List documents (searchable)
POST /api/workflow/start - Start analysis workflow
GET /api/workflow/{id}/status - Check workflow status
POST /api/advocacy/email/{id} - Generate advocacy email
GET /api/settings - Get settings
PUT /api/settings - Update settings
GET /api/agents/status - Agent health status
API Documentationβ
Once deployed, access interactive API docs at:
- Swagger UI:
https://your-app-url/api/docs - ReDoc:
https://your-app-url/api/redoc
Monitoringβ
View App Logsβ
databricks apps logs open-navigator
Check App Statusβ
databricks apps get open-navigator
Monitor Model Servingβ
databricks serving-endpoints get policy-classifier-prod
databricks serving-endpoints get sentiment-analyzer-prod
Troubleshootingβ
Issue: "Frontend not built"β
Solution:
cd frontend
npm install
npm run build
Issue: "Databricks CLI not found"β
Solution:
pip install databricks-cli
databricks configure --token
Issue: "Secrets not accessible"β
Solution:
# Recreate secrets scope
databricks secrets create-scope --scope oral-health-app
databricks secrets put --scope oral-health-app --key host --string-value "$DATABRICKS_HOST"
databricks secrets put --scope oral-health-app --key openai_key --string-value "$OPENAI_API_KEY"
Issue: "App deployment failed"β
Check logs:
databricks apps logs open-navigator --follow
Cost Optimizationβ
Databricks Apps Pricingβ
| Component | Cost Estimate |
|---|---|
| App hosting | $0.10-0.30/hour |
| Model Serving (Small) | $0.10-0.50/hour |
| Delta Lake storage | $0.023/GB/month |
| SQL Warehouse | Pay per query |
Total estimated cost: ~$50-150/month for moderate usage
Cost Savings Tipsβ
- Scale-to-zero: Model serving endpoints automatically scale down when idle
- Batch processing: Process documents in batches rather than real-time
- Hybrid classification: Use keyword matching before LLM calls (saves ~70% LLM costs)
- Delta Lake optimization: Enable auto-compaction and Z-ordering
Securityβ
Authenticationβ
Databricks Apps automatically integrate with:
- β Workspace SSO
- β OAuth 2.0
- β SCIM user provisioning
Data Accessβ
All data access is governed by:
- β Unity Catalog permissions
- β Row-level security
- β Column-level masking
Secrets Managementβ
Sensitive credentials stored in:
- β Databricks Secrets
- β Never in code or logs
- β Automatic rotation support
Next Stepsβ
-
Deploy Model Serving Endpoints
python -m databricks.deployment -
Initialize Delta Lake Tables
-- Run in Databricks SQLCREATE SCHEMA IF NOT EXISTS main.agents; -
Start Data Ingestion
- Configure target municipalities
- Run initial scraping workflow
- Monitor agent status
-
Customize UI
- Edit frontend components in
frontend/src/ - Rebuild:
npm run build - Redeploy:
./scripts/deploy-databricks-app.sh
- Edit frontend components in
Supportβ
- π Documentation: See README.md and DATABRICKS_MIGRATION.md
- π Issues: Report via GitHub Issues
- π¬ Community: Join discussions
Licenseβ
MIT License - See LICENSE file for details