File size: 2,537 Bytes
61d29fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---
sidebar_position: 4
displayed_sidebar: developersSidebar
---

# 🚀 Quick Reference Card - Databricks App

## Development Commands

```bash
# Backend only (hot reload)
make dev

# Frontend only (hot reload)
make dev-frontend

# Both together
make dev-full

# Production build + run
make run

# Deploy to Databricks
make deploy-databricks
```

## URLs

| Environment | Backend | Frontend | Type |
|-------------|---------|----------|------|
| Development | :8000 | :3000 | Separate |
| Production | :8000 | :8000 | Combined |
| Databricks | [your-workspace]/apps/oral-health-policy-pulse | Same | Combined |

## File Structure

```
frontend/src/
  pages/
    Dashboard.tsx      # /
    Heatmap.tsx        # /heatmap
    Documents.tsx      # /documents
    Opportunities.tsx  # /opportunities
    Settings.tsx       # /settings
  components/
    Layout.tsx         # Sidebar + nav

api/
  app.py              # FastAPI (NEW)
  main.py             # Legacy CLI
  static/             # Built React

scripts/
  deploy-databricks-app.sh
  setup-local.sh
  test-app.py
```

## API Endpoints

```
GET  /api/health
GET  /api/dashboard
GET  /api/opportunities?state=CA&topic=fluoride
GET  /api/documents?search=dental&page=1
POST /api/workflow/start
POST /api/advocacy/email/{id}
GET  /api/settings
PUT  /api/settings
GET  /api/agents/status
```

## Common Tasks

### Add New Page
1. Create `frontend/src/pages/NewPage.tsx`
2. Add route in `frontend/src/App.tsx`
3. Add nav item in `frontend/src/components/Layout.tsx`

### Add API Endpoint
1. Add route in `api/app.py`
2. Add query in `pipeline/delta_lake_queries.py`
3. Call from frontend with `axios.get('/api/...')`

### Deploy Changes
```bash
cd frontend && npm run build && cd ..
./scripts/deploy-databricks-app.sh
```

## Troubleshooting

| Issue | Solution |
|-------|----------|
| "Frontend not built" | `cd frontend && npm run build` |
| "Module not found" | `source venv/bin/activate` |
| Backend not responding | Check port 8000 is free |
| Frontend proxy error | Ensure backend running on :8000 |

## Environment Variables

```bash
export DATABRICKS_HOST=https://...
export DATABRICKS_TOKEN=dapi...
export OPENAI_API_KEY=sk-...
```

## Cost Estimate

| Component | Cost/hour | Cost/month |
|-----------|-----------|------------|
| Databricks App | $0.10-0.30 | $75-225 |
| Model Serving | $0.10-0.50 | $75-375 |
| Delta Lake | - | $25-100 |
| **Total** | **$0.20-0.80** | **$150-700** |

*With scale-to-zero, costs drop to near $0 when idle*

---

**Keep this card handy! 📌**