01
Automated Data Pipeline
Apache AirflowHadoop / IcebergParquet
A scheduled, automated rebuild orchestrated by an Apache Airflow DAG — not something triggered by hand, and not something that runs per request. The output is a single, self-contained HTML file.
Rebuild pipeline · 5 stages
1
Apache Airflow orchestrate — scheduled DAG triggers the full rebuild on a recurring cadence, no manual kickoff needed.
2
Hadoop / Iceberg source — 16 tables (Revenue, Compliance, Network Transaction feeds), each with Actuals/Budget/Outlook.
3
Parquet files export — written to a local staging folder.
4
Build script build — reads every parquet file, embeds the entire dataset as JavaScript.
5
Dashboard HTML artifact — dashboard.html, ~265MB, fully self-contained once built.
Why this exists. This pipeline replaced a legacy manual process of exporting Excel
cubes by hand. The data platform now provides these 16 tables directly in Hadoop/Iceberg, and Airflow
handles scheduling the rebuild automatically, so there's no spreadsheet export chain and no one has to
remember to run it.
02
Application Server & Login
FastAPIJWTbcryptCSRF
A backend service that's the one thing actually running continuously — serves the dashboard behind authentication and owns the user database.
Backend service
Serving the dashboard
The root route returns the dashboard artifact, gated behind login.
Login identity
Bcrypt-hashed password → signed JWT (HS256, algorithm pinned explicitly) in an httponly cookie. CSRF protected by a separate session cookie. Re-checked fresh from the database on every request.
User data
A relational store holding users, access grants, and an audit log.
Admin panel
Restricted to a fixed allowlist of usernames, deliberately not a database column, so no admin action can grant admin to anyone.
Bootstrap
A CLI script creates the first account directly, sidestepping the chicken-and-egg problem of needing an admin to create the first admin.
Brute-force lockout
In-memory, keyed on username + IP. Applies to every login, admins included.
03
Access Control (RLS)
Row-Level SecurityAudit LoggingGeo-Scoped Grants
A geo-scoped row-level-security model: who can see which regions/entities, independent of who can log in at all.
Access grants (per user)
Scope levels
All (everything), region, or entity — each paired with a specific value for the latter two.
Multiple grants per user
A user can hold several active grants at once; effective scope is the union of all active grants.
Soft revoke, upsert on grant
Revoking flips an active flag rather than deleting. Re-granting the same scope reactivates the existing row instead of accumulating duplicates.
Admin screens
Dedicated screens to grant/revoke per user, view full grant history, and review the audit log of every action.
Defined, not always fully enforced end-to-end. Access scoping logic can exist and be correct
while still not being wired into every downstream surface — a common real-world gap between "the model is
built" and "every code path respects it," worth calling out rather than glossing over.
04
Gen AI Chatbot
LangChainTool CallingStateless Proxy
A separate service on its own port, auto-started by the main backend but logically independent.
Chatbot service
Why it's a separate process
Keeps the real LLM API key server-side. The dashboard is a static file that could be opened or shared directly — it must never contain the real key.
Endpoints
A thin, stateless proxy — no conversation state kept server-side.
Model routing
An environment toggle switches between model providers (via LangChain), both pointing at the same internal LLM gateway.
Narrow tool surface
5 purpose-built tools — metric lookup, time-series, driver analysis, top-entity ranking, dimension discovery — instead of open-ended querying.
05
Browser & Data Flow
Client-Side ExecutionTrust Boundary
The most important property of this system: when the chatbot answers a question, the actual underlying data never leaves the user's browser.
Trust Boundary
The browser already holds the entire embedded dataset from the build step. When the LLM wants a number,
it doesn't fetch it from a server — it asks the browser to compute it from data the browser already has.
1
User asks a question — in the browser, e.g. a plain-language ask about a trend.
2
Conversation forwarded to the LLM — chatbot service → LLM gateway, along with available tool schemas.
3
LLM requests one or more tool calls — gateway → chatbot service → browser, e.g. a driver breakdown for a region/period.
4
Browser executes the tool locally — computes the real number from its own in-memory dataset. The dataset itself is never sent anywhere.
5
Only the small result is sent onward — browser → chatbot service → gateway, repeating up to 6 times until the LLM has enough to answer.
list_dimensionsget_metricget_time_seriesget_driversget_top_entities
Net effect. The confidential financial dataset never transits to the chatbot service or the
LLM gateway — only tool names, arguments, and small aggregated numeric results do.
06
Deployment / Release Process
Manual ReleaseBackup & RestoreDependency Management
Manual and human-operated — no CI/CD. A mandatory backup step and a known rollback path.
Release process · 5 steps
1
Local machine — package the backend, chatbot service, and dashboard artifact into a release bundle.
2
Jump host — transferred to an intermediary host, with re-authentication to elevate for the next hop.
3
Target server — transferred again, with freshly re-authenticated credentials.
4
Backup → replace — the live folder is backed up, then replaced by the new release — destructive by design, so the backup step is mandatory.
5
Lock & restart — deployed files set read-only, then the service is restarted.
Data-loss risk. The user database must live outside the deployed project folder, via a
persistent server-level environment variable — otherwise every redeploy wipes every user account and
access grant, since the folder containing the default database path gets deleted and recreated on each release.
Dependencies aren't in the release bundle. Packaging only places source files — it never
installs language runtime packages. The very first deploy to a new server needs one manual dependency
install against the exact interpreter the service uses — otherwise a service can fail to start with a
missing-module error. This is a one-time setup per server: once installed, every future redeploy keeps
working, since redeploys only replace code files, not the runtime environment.