Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
File size: 4,432 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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | ---
sidebar_position: 3
---
# Quick Start Guide - React + FastAPI Databricks App
## π Deploy to Databricks Apps (5 minutes)
### Prerequisites
- Databricks workspace with Apps enabled
- OpenAI API key
### Steps
```bash
# 1. Set environment variables
export DATABRICKS_HOST=https://your-workspace.cloud.databricks.com
export DATABRICKS_TOKEN=dapi1234567890abcdef
export OPENAI_API_KEY=sk-...
# 2. Deploy!
./scripts/deploy-databricks-app.sh
# 3. Access your app
# https://your-workspace.cloud.databricks.com/apps/open-navigator
```
That's it! π
---
## π» Local Development (10 minutes)
### Option A: Hot Reload (Recommended for UI development)
```bash
# Terminal 1 - Backend
source venv/bin/activate
uvicorn api.app:app --reload
# http://localhost:8000
# Terminal 2 - Frontend (hot reload!)
cd frontend
npm install
npm run dev
# http://localhost:3000
```
### Option B: Production Mode (Test full build)
```bash
# Build frontend
cd frontend
npm install
npm run build
cd ..
# Run app
source venv/bin/activate
python scripts/test-app.py
# http://localhost:8000
```
---
## π Project Structure
```
open-navigator/
βββ frontend/ # React app
β βββ src/
β β βββ pages/ # Dashboard, Heatmap, etc.
β β βββ components/ # Layout, etc.
β βββ package.json
β
βββ api/
β βββ app.py # NEW: FastAPI for Databricks App
β βββ main.py # LEGACY: Original CLI API
β
βββ scripts/
β βββ deploy-databricks-app.sh # Deploy to cloud
β βββ setup-local.sh # Setup dev environment
β βββ test-app.py # Test production build
β
βββ app.yaml # Databricks App config
βββ Dockerfile.app # Container image
```
---
## π― Common Tasks
### Deploy to Databricks
```bash
./scripts/deploy-databricks-app.sh
```
### View App Logs
```bash
databricks apps logs open-navigator --follow
```
### Update Frontend
```bash
cd frontend
# Make changes...
npm run build
cd ..
./scripts/deploy-databricks-app.sh
```
### Run Tests
```bash
source venv/bin/activate
pytest tests/
```
### Check Agent Status
```bash
curl http://localhost:8000/api/agents/status
```
---
## π Frontend Pages
| Page | Route | Description |
|------|-------|-------------|
| Dashboard | `/` | Stats, charts, recent activity |
| Heatmap | `/heatmap` | Interactive map of opportunities |
| Documents | `/documents` | Browse analyzed documents |
| Opportunities | `/opportunities` | Manage advocacy opportunities |
| Settings | `/settings` | Configure system |
---
## π§ Configuration
### Environment Variables
| Variable | Required | Description |
|----------|----------|-------------|
| `DATABRICKS_HOST` | Yes | Workspace URL |
| `DATABRICKS_TOKEN` | Yes | Access token |
| `OPENAI_API_KEY` | Yes | OpenAI API key |
| `DATABRICKS_WAREHOUSE_ID` | Yes | SQL warehouse |
### Databricks Secrets
```bash
# Create secrets scope
databricks secrets create-scope --scope oral-health-app
# Add secrets
databricks secrets put --scope oral-health-app --key host --string-value "$DATABRICKS_HOST"
databricks secrets put --scope oral-health-app --key token --string-value "$DATABRICKS_TOKEN"
databricks secrets put --scope oral-health-app --key openai_key --string-value "$OPENAI_API_KEY"
```
---
## π Troubleshooting
### "Frontend not built"
```bash
cd frontend && npm install && npm run build
```
### "Module not found"
```bash
source venv/bin/activate
pip install -r requirements-cpu.txt
```
### "Databricks CLI not found"
```bash
pip install databricks-cli
```
### "Can't connect to backend"
Check that backend is running on :8000 and frontend proxies to it.
---
## π Documentation
- **Full Deployment Guide**: `DATABRICKS_APP_GUIDE.md`
- **Refactoring Details**: `REACT_REFACTORING.md`
- **Agent Bricks Info**: `databricks/README.md`
- **Main README**: `README.md`
---
## π Need Help?
1. Check logs: `databricks apps logs open-navigator`
2. Review docs in the `/docs` folder
3. Open an issue on GitHub
---
## β‘ Pro Tips
- Use `npm run dev` for instant hot reload during UI development
- Deploy often - deployment takes ~2 minutes
- Monitor with `databricks apps get open-navigator`
- Scale to zero saves costs when idle
- Use Chrome DevTools to debug React components
---
**Happy Advocating! π¦·β¨**
|