File Map — Where Does X Live?
A lookup table from features, routes, components, and concerns to their source path
and the doc that covers them. Optimized for fast "where is this?" navigation.
Paths are relative to the repo root. When in doubt, this map is the fastest way to jump
from a feature name to the code and the relevant documentation.
Pages (routes → source → doc)
API Routes (route → source → doc)
Features (feature → key source → doc)
Feature
Key source
Doc
State management (context)
lib/database-connection-options.tsx
state-management.md
Storage abstraction
lib/storage/storage-provider.ts (+ local/api impls)
auth-and-data-layer.md
Auth / OIDC
lib/auth/auth-options.ts, lib/auth/require-auth.ts
auth-and-data-layer.md
App DB pool
lib/db/pool.ts
auth-and-data-layer.md
Migrations
lib/db/migrations/*.sql, lib/db/migrate.ts, instrumentation.ts
auth-and-data-layer.md
Repositories
lib/db/repositories/*.ts
auth-and-data-layer.md
Password encryption
lib/db/encryption.ts
auth-and-data-layer.md
Credential resolution
lib/database/connection-validator.ts
auth-and-data-layer.md
Database adapters
lib/database/adapters/*.adapter.ts, lib/database/factory.ts
adding-database-support.md
SQL dialect queries
lib/database/queries/*.queries.ts
adding-database-support.md
Read-only SQL validator (AST)
lib/database/sql-validator.ts (validateReadOnlySql, heuristicReadOnly fallback)
query-endpoints.md
Query audit log
lib/query-log.ts (logQuery), lib/query-log-file.ts, lib/db/repositories/query-log-repository.ts
auth-and-data-layer.md
Learn-from-queries (corrections + few-shot)
utils/schema-fingerprint.ts, utils/example-relevance.ts, utils/query-corrections.ts, app/api/query/generate/route.ts (buildLearningSections), lib/db/repositories/query-correction-repository.ts, app/api/data/corrections/route.ts (+ [id])
query-endpoints.md
OpenAI integration
lib/openai/schema-upload.ts, query/schema routes
openai-integration.md
Reasoning effort (gpt-5 / o-series only)
app/api/query/generate/route.ts (REASONING_EFFORTS, asReasoningEffort; env OPENAI_REASONING_EFFORT)
query-endpoints.md
Model / effort request override (eval-only)
app/api/query/generate/route.ts (modelOverride, effortOverride; gated on env EVAL_ALLOW_MODEL_OVERRIDE=true)
evals/README.md
Token usage reporting (cost accounting)
app/api/query/generate/route.ts (usage field on the generate response — generate route only)
query-endpoints.md
Rate limiting
utils/rate-limiter.ts
api/overview.md
BYOK (user API key)
hooks/use-openai-key.tsx, hooks/use-openai-fetch.tsx
infrastructure.md
Error sanitization
utils/error-sanitizer.ts
openai-integration.md
Schema change detection
utils/compare-schemas.ts
pages.md
Dashboard metric status/formatting
utils/metric-status.ts
features.md
Report parameter substitution
utils/substitute-params.ts
features.md
API response helpers
lib/api/response.ts
data-endpoints.md
Components (component → file → doc)
Component
File
Doc
SchemaExplorer
components/schema-explorer.tsx
features.md
SchemaUpdateModal
components/schema-update-modal.tsx
features.md
QueryResultsDisplay
components/query-results-display.tsx
features.md
QueryTabContent
components/query-tab-content.tsx
features.md
DirtyReadToggle
components/dirty-read-toggle.tsx
query-endpoints.md
FollowupDialog
components/followup-dialog.tsx
features.md
ChartDisplay + charts/
components/chart-display.tsx, components/charts/*
features.md
ComposedChart
components/charts/composed-chart.tsx
features.md
ChartCustomizer
components/chart-customizer.tsx
features.md
Report components
components/save-report-dialog.tsx, edit-report-dialog.tsx, parameter-config.tsx, parameter-input-dialog.tsx, saved-reports.tsx
features.md
Export / Import Reports
components/export-reports-dialog.tsx, components/import-reports-dialog.tsx
features.md
Dashboard widgets (KPIs / trend chart)
components/executive-metrics.tsx, components/performance-chart.tsx, app/page.tsx (loadDashboardWidgets)
features.md
Query accuracy stat / override
app/page.tsx (stat card), components/query-tab-content.tsx (thumbs), lib/database-connection-options.tsx (recordQueryOutcome/overrideQueryOutcome), lib/db/repositories/query-accuracy-repository.ts, app/api/data/query-accuracy/route.ts, models/query-accuracy.interface.ts
—
Dashboard (demo) components
components/quick-actions.tsx, recent-reports.tsx, scheduled-reports.tsx, report-templates.tsx
features.md
Providers
components/auth-provider.tsx, openai-api-provider.tsx, theme-provider.tsx
infrastructure.md
ContentLoadingGate / ErrorBoundary
components/content-loading-gate.tsx, error-boundary.tsx
infrastructure.md
Navigation / Theme
components/navigation.tsx, theme-toggle.tsx
infrastructure.md
ShareDialog / DataMigrationDialog
components/share-dialog.tsx, data-migration-dialog.tsx
infrastructure.md
ConfirmationModal
components/confirmation-modal.tsx
infrastructure.md
API key (BYOK) UI
components/api-key-dialog.tsx, api-key-indicator.tsx
infrastructure.md
Item
File
Doc
TypeScript interfaces
models/*.interface.ts, models/common-types.ts
models/overview.md
QueryAccuracy / QueryCorrection
models/query-accuracy.interface.ts, models/query-correction.interface.ts
models/overview.md
DashboardWidgetConfig + SavedReport.visualization
models/saved-report.interface.ts
features.md
ComposedChartConfig + CHART_TOOLS
models/chart-config.interface.ts
features.md
Custom hooks
hooks/use-*.ts(x)
components/overview.md
Standalone NL→SQL evaluation harness — a tsx CLI (pnpm eval) that checks whether generated SQL
executes and returns results matching authored golden SQL, across models, reasoning efforts,
latency, and cost. Full usage: evals/README.md .
Item
File
Notes
Runner (CLI entry)
evals/run-eval.ts
Invoked by the eval package script (tsx evals/run-eval.ts)
Question dataset
evals/dataset.ts
32 questions: core 16 + extended 16
Golden-SQL verifier
evals/verify-goldens.ts
Checks the authored golden queries run against the target DB
Pricing rates
evals/pricing.json
USD per 1M tokens; ships with NULL rates, so cost renders as "—" until filled in
Shared types
evals/types.ts
Result/run shapes used across the harness
API client
evals/lib/api-client.ts
Typed fetch wrappers over the running dev server (generate sends model / effort, plus execute / introspect)
Failure classification
evals/lib/classify.ts
Classifies generate + execute failures (incl. mock-fallback / JSON-parse-fallback signals)
Result comparison
evals/lib/compare.ts (tests: tests/unit/compare.test.ts)
Compares generated vs golden result sets per the question's comparison mode
Cost accounting
evals/lib/pricing.ts
Applies pricing.json rates to reported token usage (breakdowns are subsets, never additive)
HTML report builder
evals/lib/report.ts
Builds the self-contained HTML report (no dependencies)
Schema vector store
evals/lib/vector-store.ts
Standalone schema upload + ingestion wait; mirrors lib/openai/schema-upload.ts without importing it
Run output (gitignored)
evals/results/*.jsonl, evals/results/*.html
Per-run raw records plus the HTML report