Skip to content

Commit 8d7f65a

Browse files
authored
docs: generate llms.txt from the docs and host it on docs website (#65)
* docs: generate `llms.txt` from docs and host in on docs website * chore: use camelCase for plugin names
1 parent 5acd841 commit 8d7f65a

14 files changed

Lines changed: 1212 additions & 1326 deletions

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ AppKit uses a **phase-based plugin architecture** with three initialization phas
172172
import { Plugin, toPlugin } from '@databricks/appkit';
173173

174174
class MyPlugin extends Plugin {
175-
name: string = "my-plugin";
175+
name: string = "myPlugin";
176176

177177
// Validate required environment variables
178178
validateEnv() {

docs/docs/api/appkit-ui/styling.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
sidebar_position: 4
3+
---
4+
5+
# Styling
6+
7+
This guide covers how to style AppKit UI components using CSS variables and theming.
8+
9+
## CSS import
10+
11+
In your main CSS file, import the AppKit UI styles:
12+
13+
```css
14+
@import "@databricks/appkit-ui/styles.css";
15+
```
16+
17+
This provides a default theme for your app using CSS variables.
18+
19+
## Customizing theme
20+
21+
AppKit UI uses CSS variables for theming, supporting both light and dark modes automatically.
22+
23+
### Full variable list
24+
25+
You can customize the theme by overriding CSS variables. See the [CSS variables](https://github.com/databricks/appkit/blob/main/packages/appkit-ui/src/react/styles/globals.css) for the full list of variables.
26+
27+
:::warning Important
28+
If you change any variable, you must change it for **both light and dark mode** to ensure consistent appearance across color schemes.
29+
:::
30+
31+
## Color system
32+
33+
AppKit UI uses the OKLCH color space for better perceptual uniformity. The format is:
34+
35+
```
36+
oklch(lightness chroma hue)
37+
```
38+
39+
Where:
40+
- **lightness**: 0-1 (0 = black, 1 = white)
41+
- **chroma**: 0-0.4 (saturation)
42+
- **hue**: 0-360 (color angle)
43+
44+
## Semantic color variables
45+
46+
### Core colors
47+
48+
- `--background` / `--foreground` - Main background and text
49+
- `--card` / `--card-foreground` - Card backgrounds
50+
- `--popover` / `--popover-foreground` - Popover/dropdown backgrounds
51+
52+
### Interactive colors
53+
54+
- `--primary` / `--primary-foreground` - Primary actions
55+
- `--secondary` / `--secondary-foreground` - Secondary actions
56+
- `--muted` / `--muted-foreground` - Muted/disabled states
57+
- `--accent` / `--accent-foreground` - Accent highlights
58+
59+
### Status colors
60+
61+
- `--destructive` / `--destructive-foreground` - Destructive actions
62+
- `--success` / `--success-foreground` - Success states
63+
- `--warning` / `--warning-foreground` - Warning states
64+
65+
### UI elements
66+
67+
- `--border` - Border colors
68+
- `--input` - Input field borders
69+
- `--ring` - Focus ring colors
70+
- `--radius` - Border radius
71+
72+
### Charts
73+
74+
- `--chart-1` through `--chart-5` - Chart color palette
75+
76+
### Sidebar
77+
78+
- `--sidebar-*` - Sidebar-specific colors
79+
80+
## See also
81+
82+
- [API Reference](/docs/api/appkit-ui) - Complete UI components API documentation

docs/docs/app-management.mdx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 3
2+
sidebar_position: 2
33
---
44

55
import Prerequisites from './_prerequisites.mdx';
@@ -16,12 +16,10 @@ See the [Quick start](./index.md) section to create a new Databricks app with Ap
1616

1717
## Configuration
1818

19-
Before deploying your app, configure it according to your needs. See the [Databricks Apps Configuration](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/configuration) documentation for details on:
20-
21-
- App configuration file (`app.yaml`)
22-
- Environment variables
23-
- Authorization and permissions
24-
- Networking configuration
19+
Before deploying your app, you need to configure it. See the [Configuration guide](./configuration.mdx) for details on:
20+
- `app.yaml` configuration and command specification
21+
- Environment variables and SQL warehouse binding
22+
- Local development authentication options
2523

2624
## Deploy app
2725

docs/docs/configuration.mdx

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
---
2+
sidebar_position: 5
3+
---
4+
5+
# Configuration
6+
7+
This guide covers environment variables and configuration options for AppKit applications.
8+
9+
## App deployment configuration
10+
11+
### `app.yaml` file
12+
13+
The `app.yaml` file configures your app's runtime environment in Databricks Apps.
14+
15+
**Basic example:**
16+
17+
```yaml
18+
command:
19+
- node
20+
- build/index.mjs
21+
env:
22+
- name: DATABRICKS_WAREHOUSE_ID
23+
valueFrom: sql-warehouse
24+
```
25+
26+
### Command specification
27+
28+
Specify how to start your app in the `command` field:
29+
30+
```yaml
31+
command:
32+
- node
33+
- build/index.mjs
34+
```
35+
36+
This runs the production build of your AppKit server (created by `npm run build`).
37+
38+
### Binding a SQL warehouse
39+
40+
To use the analytics plugin, bind a SQL warehouse in your `app.yaml`:
41+
42+
```yaml
43+
env:
44+
- name: DATABRICKS_WAREHOUSE_ID
45+
valueFrom: sql-warehouse
46+
```
47+
48+
This makes the warehouse ID available to your app at runtime. The `valueFrom: sql-warehouse` directive tells Databricks Apps to inject the configured warehouse ID.
49+
50+
For advanced configuration options (authorization, networking, resource limits), see the [Databricks Apps Configuration](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/configuration) documentation.
51+
52+
## Environment variables
53+
54+
### Required for Databricks Apps deployment
55+
56+
These are typically **provided by Databricks Apps runtime** (exact set can vary by platform/version):
57+
58+
| Variable | Description |
59+
|----------|-------------|
60+
| `DATABRICKS_HOST` | Workspace URL (e.g. `https://xxx.cloud.databricks.com`) |
61+
| `DATABRICKS_APP_PORT` | Port to bind (default: `8000`) |
62+
| `DATABRICKS_APP_NAME` | App name in Databricks |
63+
64+
### Required for SQL queries (analytics plugin)
65+
66+
| Variable | Description | How to Set |
67+
|----------|-------------|------------|
68+
| `DATABRICKS_WAREHOUSE_ID` | SQL warehouse ID | In `app.yaml`: `valueFrom: sql-warehouse` |
69+
70+
See the [App deployment configuration](#app-deployment-configuration) section above for details on how to bind this variable.
71+
72+
### Optional variables
73+
74+
| Variable | Description | Default |
75+
|----------|-------------|---------|
76+
| `DATABRICKS_WORKSPACE_ID` | Workspace ID | Auto-fetched from API |
77+
| `NODE_ENV` | `"development"` or `"production"` | — |
78+
| `FLASK_RUN_HOST` | Host to bind | `0.0.0.0` |
79+
80+
### Telemetry (optional)
81+
82+
| Variable | Description |
83+
|----------|-------------|
84+
| `OTEL_EXPORTER_OTLP_ENDPOINT` | OpenTelemetry collector endpoint |
85+
| `OTEL_SERVICE_NAME` | Service name for traces |
86+
87+
## Local development authentication
88+
89+
For local development, you need to authenticate with Databricks. Choose one of the following options:
90+
91+
### Option 1: Databricks CLI authentication (recommended)
92+
93+
Configure authentication once using the Databricks CLI:
94+
95+
```bash
96+
databricks auth login --host [host] --profile [profile-name]
97+
```
98+
99+
If you use `DEFAULT` as the profile name, you can run your dev server directly:
100+
101+
```bash
102+
npm run dev
103+
```
104+
105+
To run with a specific profile, set the `DATABRICKS_CONFIG_PROFILE` environment variable:
106+
107+
```bash
108+
DATABRICKS_CONFIG_PROFILE=my-profile npm run dev
109+
```
110+
111+
Note: Some Databricks SDK versions use `DATABRICKS_PROFILE` instead of `DATABRICKS_CONFIG_PROFILE`.
112+
113+
### Option 2: Environment variables
114+
115+
```bash
116+
export DATABRICKS_HOST="https://xxx.cloud.databricks.com"
117+
export DATABRICKS_TOKEN="dapi..."
118+
export DATABRICKS_WAREHOUSE_ID="abc123..."
119+
npm run dev
120+
```
121+
122+
### Option 3: `.env` file (auto-loaded by AppKit)
123+
124+
Create a `.env` file in your project root (add to `.gitignore`!):
125+
126+
```bash
127+
DATABRICKS_HOST=https://xxx.cloud.databricks.com
128+
DATABRICKS_TOKEN=dapi...
129+
DATABRICKS_WAREHOUSE_ID=abc123...
130+
```
131+
132+
Then run:
133+
134+
```bash
135+
npm run dev
136+
```
137+
138+
## Advanced configuration
139+
140+
For advanced Databricks Apps configuration (authorization, networking, resource limits), refer to the [Databricks Apps Configuration](https://docs.databricks.com/aws/en/dev-tools/databricks-apps/configuration) documentation.
141+
142+
## See also
143+
144+
- [App management](./app-management.mdx) - Deploying and managing apps
145+
- [Plugins](./plugins.md) - Plugin configuration options
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"label": "Development",
3+
"position": 7,
4+
"collapsible": true,
5+
"collapsed": false,
6+
"link": {
7+
"type": "generated-index",
8+
"title": "Development",
9+
"description": "Guides for developing AppKit applications"
10+
}
11+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
sidebar_position: 8
3+
---
4+
5+
# LLM Guide
6+
7+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
8+
9+
export function LlmsTxtLink({ children = '`llms.txt`' }) {
10+
const { siteConfig } = useDocusaurusContext();
11+
const llmsTxtUrl = `${siteConfig.baseUrl}llms.txt`;
12+
return <a href={llmsTxtUrl}>{children}</a>;
13+
}
14+
15+
This document provides prescriptive guidance for AI coding assistants generating code with Databricks AppKit. It is intentionally opinionated to ensure consistent, production-ready code generation.
16+
17+
:::note
18+
This file contains just a subset of the LLM guidance.
19+
To get the complete guidance, see the <LlmsTxtLink /> file for full guidance based on the AppKit documentation.
20+
:::
21+
22+
## High-level mission
23+
24+
Build **full-stack TypeScript apps** on Databricks using:
25+
26+
- **Backend**: `@databricks/appkit`
27+
- **Frontend**: `@databricks/appkit-ui`
28+
- **Analytics**: SQL files in `config/queries/*.sql` executed via the AppKit analytics plugin
29+
30+
This guide is designed to work even when you *do not* have access to the AppKit source repo. Prefer only public package APIs and portable project structures.
31+
32+
## Hard rules (LLM guardrails)
33+
34+
- **Do not invent APIs**. If unsure, stick to the patterns shown in the documentation and only use documented exports from `@databricks/appkit` and `@databricks/appkit-ui`.
35+
- **`createApp()` is async**. Prefer **top-level `await createApp(...)`**. If you can't, use `void createApp(...)` and do not ignore promise rejection.
36+
- **Always memoize query parameters** passed to `useAnalyticsQuery` / charts to avoid refetch loops.
37+
- **Always handle loading/error/empty states** in UI (use `Skeleton`, error text, empty state).
38+
- **Always use `sql.*` helpers** for query parameters (do not pass raw strings/numbers unless the query expects none).
39+
- **Never construct SQL strings dynamically**. Use parameterized queries with `:paramName`.
40+
- **Never use `require()`**. Use ESM `import/export`.
41+
42+
## TypeScript import rules
43+
44+
If your `tsconfig.json` uses `"verbatimModuleSyntax": true`, **always use `import type` for type-only imports** (otherwise builds can fail in strict setups):
45+
46+
```ts
47+
import type { ReactNode } from "react";
48+
import { useMemo } from "react";
49+
```
50+
51+
## LLM checklist (before finalizing code)
52+
53+
### Project setup
54+
55+
- `package.json` has `"type": "module"`
56+
- `tsx` is in devDependencies for dev server
57+
- `dev` script uses `NODE_ENV=development tsx watch server/index.ts`
58+
- `client/index.html` exists with `<div id="root"></div>` and script pointing to `client/src/main.tsx`
59+
60+
### Backend
61+
62+
- `await createApp({ plugins: [...] })` is used (or `void createApp` with intent)
63+
- `server()` is included (always)
64+
- If using SQL: `analytics({})` included + `config/queries/*.sql` present
65+
- Queries use `:param` placeholders, and params are passed from UI using `sql.*`
66+
- If query needs workspace scoping: uses `:workspaceId`
67+
68+
### Frontend
69+
70+
- `useMemo` wraps parameters objects
71+
- Loading/error/empty states are explicit
72+
- Charts use `format="auto"` unless you have a reason to force `"json"`/`"arrow"`
73+
- Charts use props (`xKey`, `yKey`, `colors`) NOT children (they're ECharts-based, not Recharts)
74+
- If using tooltips: root is wrapped with `<TooltipProvider>`
75+
76+
### Never
77+
78+
- Don't build SQL strings manually
79+
- Don't pass untyped raw params for annotated queries
80+
- Don't ignore `createApp()`'s promise
81+
- Don't invent UI components not listed in the documentation
82+
- Don't pass Recharts children (`<Bar>`, `<XAxis>`, etc.) to AppKit chart components

0 commit comments

Comments
 (0)