A simple hello world template that demonstrates how to build full-stack applications using Node.js (React) frontend with FastAPI backend for Databricks Apps.
Nextjs Frontend (TypeScript + Tailwind + Shadcn + Zustand)
↓ API calls
FastAPI Backend (Python)
↓ Serves static files + API
Databricks Apps
- Install Python dependencies:
pip install -r requirements.txt- Install Node.js dependencies:
npm installThe application uses a two-tier environment configuration system:
.env- Production/base configuration.env.local- Local development overrides (gitignored)
See env-example.md for detailed configuration examples.
Create a .env.local file in the project root:
# Environment mode
ENVIRONMENT=local
# Database configuration for local development
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgresCreate a .env file in the project root:
# Environment mode
ENVIRONMENT=production
# Databricks database configuration
DATABRICKS_INSTANCE_NAME=your_instance_name
[email protected]
# Databricks authentication
DATABRICKS_HOST=https://your-workspace-url/
DATABRICKS_TOKEN=your-access-tokenThe Databricks SDK uses default authentication methods in the following order:
- Databricks CLI configuration (
~/.databrickscfg) - Environment variables (
DATABRICKS_HOST,DATABRICKS_TOKEN, etc.) - Azure CLI (for Azure Databricks)
- Service Principal authentication
- Google Cloud authentication (for GCP Databricks)
For explicit authentication, you can also set:
# Token-based authentication
DATABRICKS_HOST=https://your-workspace-url/
DATABRICKS_TOKEN=your-access-token
# Or Service Principal authentication
DATABRICKS_HOST=https://your-workspace-url/
DATABRICKS_CLIENT_ID=your-service-principal-id
DATABRICKS_CLIENT_SECRET=your-service-principal-secretNote: In production mode, the application will automatically:
- Connect to your Databricks workspace using the configured authentication
- Get database instance details using
get_database_instance() - Generate fresh database credentials using
generate_database_credential() - Use SSL-required connections (
sslmode=require)
- Start FastAPI backend:
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000- In another terminal, start React dev server:
npm run dev- Frontend: http://localhost:5173 (with API proxy)
- Backend API docs: http://localhost:8000/docs
Build and run:
npm run build
uvicorn backend.main:app --host 0.0.0.0 --port 8000Configured for Databricks Apps with app.yaml. Uses DATABRICKS_APP_PORT environment variable automatically.
Create the Databricks App in the Databricks UI and follow the instructions after the app is created.
The Databricks App Deployment consumes the .env.production file and must not include the NEXT_PUBLIC_API_URL
npm run build
databricks sync --watch . /Workspace/Users/[email protected]/{{Databricks App Here}}
databricks apps deploy {{Databricks App Here}} --source-code-path /Workspace/Users/[email protected]//{{Databricks App Here}}The npm run build will place the static files in the backend folder.
GET /api/hello- Hello world messageGET /api/health- Health check endpointGET /api/db-test- Test database connection and return version infoGET /api/env-info- Show environment configuration (no secrets)GET /docs- FastAPI interactive documentation