Skip to content

Directory Architecture

databricks-apps-survey-analysis/
โ”œโ”€โ”€ .github/workflows/deploy.yml   # Deploys on push to main/stg/prd
โ”œโ”€โ”€ .husky/pre-commit              # format:check + lint (the hook that actually runs)
โ”œโ”€โ”€ README.md                      # Setup and troubleshooting
โ””โ”€โ”€ nodejs-fastapi-hello-world-app/   # The app itself (run every command here)
    โ”œโ”€โ”€ backend/
    โ”‚   โ”œโ”€โ”€ main.py                # Router registration + SPA catch-all
    โ”‚   โ”œโ”€โ”€ settings.py            # Resolves env vars from .env / yaml
    โ”‚   โ”œโ”€โ”€ databricks_workspace.py  # Builds the WorkspaceClient
    โ”‚   โ”œโ”€โ”€ generate_models_from_databricks.py  # Generates Pydantic models from UC schemas
    โ”‚   โ”œโ”€โ”€ models/                # Pydantic models
    โ”‚   โ”œโ”€โ”€ routes/                # FastAPI routers (thin layer)
    โ”‚   โ”œโ”€โ”€ sql/                   # SQL queries and Databricks connection
    โ”‚   โ””โ”€โ”€ static/                # Built frontend (tracked in git)
    โ”œโ”€โ”€ frontend/
    โ”‚   โ”œโ”€โ”€ vite.config.ts         # outDir=backend/static, proxies /api to :8000
    โ”‚   โ””โ”€โ”€ src/
    โ”‚       โ”œโ”€โ”€ api/generated/     # orval-generated client (never hand-edit)
    โ”‚       โ”œโ”€โ”€ components/        # <category>/<Name>/index.tsx + index.scss
    โ”‚       โ”œโ”€โ”€ pages/             # <Name>/index.tsx + index.scss
    โ”‚       โ””โ”€โ”€ constants/         # dwh.ts (fixed catalog/schema), navigation.ts
    โ”œโ”€โ”€ scripts/
    โ”‚   โ”œโ”€โ”€ generate_openapi.py    # Dumps openapi.yaml from the FastAPI app
    โ”‚   โ””โ”€โ”€ setup-husky.mjs        # Points husky's install target at the repo root
    โ”œโ”€โ”€ _templates/component/new/  # hygen component scaffolds
    โ”œโ”€โ”€ app.yaml                   # Databricks Apps config (DATABRICKS_HTTP_PATH)
    โ”œโ”€โ”€ databricks.yml             # Asset Bundle config (workspace.host)
    โ”œโ”€โ”€ package.json
    โ””โ”€โ”€ requirements.txt

Directory Descriptions

Directory Description
backend/routes/ FastAPI routers. A thin layer that calls the synchronous SQL layer via asyncio.to_thread and maps exceptions to HTTP status codes
backend/sql/ The actual queries. databricks_client.run_query is the only entry point to the SQL Warehouse
backend/models/ Pydantic models. api.py is hand-written; per-table models are auto-generated
backend/static/ Output of npm run build. Tracked and committed in git
frontend/src/api/generated/ orval output. Never hand-edit it, nor openapi.yaml
frontend/src/components/ Structured as <category>/<Name>/index.tsx + index.scss
frontend/src/pages/ Route-backed pages, as <Name>/index.tsx + index.scss
frontend/src/constants/ dwh.ts (catalog cs / schema cs_dm), navigation.ts (sidebar items)
scripts/ Utilities for OpenAPI output and husky setup

Where to Add New Files

  • UI component โ†’ npm run generate:component (hygen creates frontend/src/components/<category>/<Name>/)
  • Page โ†’ create frontend/src/pages/<Name>/index.tsx, add a Route in App.tsx, and add a sidebar entry in constants/navigation.ts
  • API endpoint โ†’ add the query in backend/sql/, the model in backend/models/, and the router in backend/routes/, then register it in routers in backend/routes/__init__.py. Regenerate types with npm run generate:client
  • API client โ†’ never hand-write it; use the output of npm run generate:client

Do not forget to commit build output

What gets deployed is exactly what is in git, including backend/static/. After changing the frontend, the npm run build output must be committed or production will not reflect it.

A dead pre-commit hook

nodejs-fastapi-hello-world-app/.husky/pre-commit is unused. The hook that actually runs is .husky/pre-commit at the repository root; npm run prepare โ†’ scripts/setup-husky.mjs switches husky's install target to the root.