# databricks/app-templates architecture

> Architecture diagram of the GitHub repository databricks/app-templates, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/databricks/app-templates
- Repository: https://github.com/databricks/app-templates

## Overview

##### Project type and purpose
- This is an open-source monorepo of “app templates” (README just says “app-templates”).
- It contains dozens of lightweight starter projects (Python Flask, Dash, Streamlit, Gradio, Shiny) plus a more advanced Next.js “e2e-chatbot-app-next” sample with Databricks integration, database migrations, and end-to-end tests.
- Use-cases: provide boilerplates for different web-framework stacks and a showcase reference implementation of a chat UI + backend + data persistence + external AI provider.

##### File structure
- Top-level directories:
· dash-*, flask-*, gradio-*, shiny-*, streamlit-*: each folder is a standalone template.
· e2e-chatbot-app-next: a full-stack Next.js 13 App Router project.
· mcp-server-hello-world, nodejs-fastapi-hello-world-app: additional examples.
- Patterns:
· Each Python template has app.py (entry), requirements.txt, app.yaml (deployment config).
· The Next.js sample has “app/” (App Router pages & API routes), “components/”, “databricks/” (auth, db, providers), “lib/”, “scripts/”, “tests/”.
- CI/config:
· e2e sample has .github/workflows, playwright.config.ts, drizzle.config.ts, databricks.yml.

##### Diagramming main components and relationships
a. Monorepo overview
- Monorepo root
→ Python templates (each isolated)
→ Node.js/Next.js template
→ Shared docs, LICENSE, NOTICE
b. Drill into “e2e-chatbot-app-next”
- Frontend (Next.js App Router):
- UI pages, components, global layout
- API routes (app/(chat)/api/*):
- chat streaming, history, session endpoints
- Databricks integration (databricks/):
- Auth module → Chat transport utility → Language model providers
- Database (drizzle.config.ts + databricks/db/):
- Connection & migrations → query layer → Postgres
- Testing & CI:
- Playwright E2E tests → API mocking server → GitHub Actions workflows
- Scripts: deployment, reset database, generate OAuth tokens
c. Relationships
- Frontend calls API routes
- API routes orchestrate Databricks calls and DB queries
- Tests simulate front-end and API interactions
- CI pipeline triggers linting, tests, deploy scripts

##### Architectural patterns & design principles
- Template isolation: each folder is a self-contained app
- For Next.js: App Router (React server/client components), layered service modules (auth, providers, db)
- Clear separation: UI vs API vs data vs external AI services vs tests

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Monorepo Root"
        direction TB
        subgraph "Python Templates"
            direction TB
            dash["dash-chatbot-app"]:::python
            flask["flask-database-app"]:::python
            gradio["gradio-chatbot-app"]:::python
            shiny["shiny-hello-world-app"]:::python
            streamlit["streamlit-data-app"]:::python
        end
        subgraph "e2e-chatbot-app-next" 
            direction TB
            subgraph "Frontend (Next.js App Router)" 
                direction TB
                FE_App["app/"]:::next
                FE_Comp["components/"]:::next
            end
            subgraph "API Routes" 
                direction TB
                API_Chat["chat/route.ts"]:::next
                API_Stream["[id]/stream/route.ts"]:::next
                API_Hist["history/route.ts"]:::next
                API_Session["session/route.ts"]:::next
            end
            subgraph "Databricks Integration" 
                direction TB
                DB_Auth["auth/"]:::external
                DB_DB["db/"]:::external
                DB_Prov["providers/"]:::external
                DB_Util["utils/"]:::external
            end
            subgraph "Database Layer" 
                direction TB
                Drizzle["drizzle.config.ts"]:::next
                Postgres["Postgres"]:::external
            end
            subgraph "CI/CD & Config" 
                direction TB
                GH_WF[".github/workflows/"]:::ci
                DB_YML["databricks.yml"]:::ci
                App_YML["app.yaml"]:::ci
            end
            subgraph "Tests" 
                direction TB
                E2E_T["tests/e2e/"]:::ci
                API_Mock["tests/api-mocking/"]:::ci
                Uni_Routes["tests/routes/"]:::ci
                Uni_Pages["tests/pages/"]:::ci
            end
            subgraph "Scripts" 
                direction TB
                S_Deploy["scripts/deploy.sh"]:::ci
                S_Reset["scripts/reset-database.ts"]:::ci
                S_OAuth["scripts/get-oauth-token.ts"]:::ci
            end
        end
        docs["README, LICENSE, NOTICE"]:::code
    end

    %% Relationships
    FE_App -->|"renders UI"| FE_Comp
    FE_App -->|"calls"| API_Chat
    API_Chat -->|"orchestrates"| DB_Auth
    API_Chat -->|"queries"| DB_DB
    API_Chat -->|"calls"| DB_Prov
    DB_DB -->|"connects"| Postgres
    DB_Auth -->|"auth to"| DB_Prov
    E2E_T -->|"tests"| FE_App
    E2E_T -->|"tests"| API_Chat
    API_Mock -->|"mocks"| API_Chat
    GH_WF -->|"triggers"| E2E_T
    GH_WF -->|"runs"| S_Deploy

    %% Click Events
    click dash "https://github.com/databricks/app-templates/tree/main/dash-chatbot-app/"
    click flask "https://github.com/databricks/app-templates/tree/main/flask-database-app/"
    click gradio "https://github.com/databricks/app-templates/tree/main/gradio-chatbot-app/"
    click shiny "https://github.com/databricks/app-templates/tree/main/shiny-hello-world-app/"
    click streamlit "https://github.com/databricks/app-templates/tree/main/streamlit-data-app/"
    click FE_App "https://github.com/databricks/app-templates/tree/main/e2e-chatbot-app-next/app/"
    click FE_Comp "https://github.com/databricks/app-templates/tree/main/e2e-chatbot-app-next/components/"
    click API_Chat "https://github.com/databricks/app-templates/blob/main/e2e-chatbot-app-next/app/(chat)/api/chat/route.ts"
    click API_Stream "https://github.com/databricks/app-templates/blob/main/e2e-chatbot-app-next/app/(chat)/api/chat/[id]/stream/route.ts"
    click API_Hist "https://github.com/databricks/app-templates/blob/main/e2e-chatbot-app-next/app/(chat)/api/history/route.ts"
    click API_Session "https://github.com/databricks/app-templates/blob/main/e2e-chatbot-app-next/app/(chat)/api/session/route.ts"
    click DB_Auth "https://github.com/databricks/app-templates/tree/main/e2e-chatbot-app-next/databricks/auth/"
    click DB_DB "https://github.com/databricks/app-templates/tree/main/e2e-chatbot-app-next/databricks/db/"
    click DB_Prov "https://github.com/databricks/app-templates/tree/main/e2e-chatbot-app-next/databricks/providers/"
    click DB_Util "https://github.com/databricks/app-templates/tree/main/e2e-chatbot-app-next/databricks/utils/"
    click Drizzle "https://github.com/databricks/app-templates/blob/main/e2e-chatbot-app-next/drizzle.config.ts"
    click GH_WF "https://github.com/databricks/app-templates/tree/main/e2e-chatbot-app-next/.github/workflows/"
    click DB_YML "https://github.com/databricks/app-templates/blob/main/e2e-chatbot-app-next/databricks.yml"
    click App_YML "https://github.com/databricks/app-templates/blob/main/e2e-chatbot-app-next/app.yaml"
    click E2E_T "https://github.com/databricks/app-templates/tree/main/e2e-chatbot-app-next/tests/e2e/"
    click API_Mock "https://github.com/databricks/app-templates/tree/main/e2e-chatbot-app-next/tests/api-mocking/"
    click Uni_Routes "https://github.com/databricks/app-templates/tree/main/e2e-chatbot-app-next/tests/routes/"
    click Uni_Pages "https://github.com/databricks/app-templates/tree/main/e2e-chatbot-app-next/tests/pages/"
    click S_Deploy "https://github.com/databricks/app-templates/blob/main/e2e-chatbot-app-next/scripts/deploy.sh"
    click S_Reset "https://github.com/databricks/app-templates/blob/main/e2e-chatbot-app-next/scripts/reset-database.ts"
    click S_OAuth "https://github.com/databricks/app-templates/blob/main/e2e-chatbot-app-next/scripts/get-oauth-token.ts"

    %% Styles
    classDef python fill:#CCE5FF,stroke:#3399FF,color:#000
    classDef next fill:#DFF2BF,stroke:#4F8A10,color:#000
    classDef ci fill:#FFE5CC,stroke:#FF9933,color:#000
    classDef external fill:#FFCCCC,stroke:#CC0000,color:#000
    classDef code fill:#F5F5F5,stroke:#999,color:#000
```
