An outbound investment from India touches a treasury desk, an authorised dealer bank and several authorities. Each keeps its own copy of the facts. CorpVidesh AI is built around one idea: a single, pre-validated, tamper-evident record that every desk reads. This post explains how that record is engineered.
§01
Design principles
We borrowed from Swiss graphic design and Swiss banking alike: a strict grid, very few colours, and a refusal to decorate what should be stated plainly. In engineering terms that became five rules.
- 01Precision. Every legal answer cites a provision; every price shows its source time.
- 02Separation. Rules live in pure modules; servers do I/O; screens only display.
- 03Append, never edit. Filings and reviews are added as new events, never overwritten.
- 04Least authority. Roles and company memberships are checked on the server for every write.
- 05Honest labels. Simulations, estimates and pilot targets are marked as such on screen.
§02
The stack
CorpVidesh AI is a full-stack React 19 application on TanStack Start. Pages render on the server for fast first paint and shareable links; all private logic runs in typed server functions on edge workers, so secrets and database credentials never reach the browser.
| Concern | Choice | Why |
|---|---|---|
| Interface | React 19, TanStack Router, Tailwind CSS | Type-safe routes; one design token set for the red/white grid |
| Server | TanStack Start server functions on edge workers | Validated inputs, no exposed keys, low latency |
| Data | Lovable Cloud Postgres with row-level security | Isolation enforced by the database, not by the screen |
| Identity | Email/password and Lovable sign-in, server-assigned roles | Roles stored separately from profiles |
| AI | Lovable AI Gateway called only from server modules | Model keys stay server-side; answers carry sources |
| Visuals | SVG diagrams, Three.js loaded only in the browser | 3D never blocks server rendering |
| Quality | Vitest, Playwright checks, GitHub Actions | Each domain has its own test gate |
§03
Five layers, one direction of trust
Requests flow downward: people use workspaces; workspaces call server domains; every write passes the safeguard layer before it reaches data. Nothing in an upper layer can grant itself authority from a lower one.
§04
Four server domains, one deployment
The backend is split into Legal, Filings, Markets and Agents. Each domain exposes a versioned contract (a validated input schema), keeps its rules in a pure policy module that is easy to test, and does its I/O in a server-only implementation. Here is the real entry point for the legal route assessment:
export const assessInvestmentRoute = createServerFn({ method: "POST" })
.inputValidator((input: unknown) => legalCaseSchema.parse(input))
.handler(async ({ data }) => {
const { assessLegalRoute } = await import("./services/legal.server");
const { serviceOperation } = await import("./services/runtime.server");
return serviceOperation("legal.assess", () => assessLegalRoute(data));
});Three things happen in seven lines: the input is rejected unless it matches the contract, the server-only implementation is loaded only inside the handler, and the work is wrapped in a traced operation.
Modular domains, one integrated deployment — we do not pretend to run independent microservices.
§05
Life of a request
A treasury user picks a company, hub, currency, investment class and amount. That choice travels through eight steps, each writing to the same case record. A missing document blocks the flow rather than letting it continue with a warning.
Every server operation gets a fresh trace ID and a duration/outcome log line — with no payloads, identities or automatic retries:
const traceId = crypto.randomUUID();
setResponseHeader("X-CorpVidesh-Trace-ID", traceId);
setResponseHeader("Cache-Control", "private, no-store");
// ... run the work, then log only:
{ event: "service-operation", operation, traceId, durationMs, outcome }§06
Record integrity & isolation
Case events in the GIFT clearance portal are chained inside the database. A trigger locks the case, reads the previous hash and computes the new one, so order is enforced even if two reviewers act at the same moment:
NEW.prev_hash := COALESCE(last_hash, 'genesis');
NEW.hash := encode(extensions.digest(
NEW.prev_hash || '|' || NEW.case_id || '|' || NEW.seq || '|' ||
NEW.party || '|' || NEW.action || '|' || NEW.note || '|' ||
array_to_string(NEW.documents, ',') || '|' || NEW.created_at::text,
'sha256'), 'hex');Isolation is enforced the same way. Row-level security policies separate private company records from public showcase desks, and corporate filing rights come from server-managed company memberships — never from a company name typed into a form.
§07
The agent graph
Five tools sit on one Agent Desk: the statutory graph, the AI copilot, the document reader, the currency outlook and read-only connected tools. Inside the graph, a coordinator calls specialists and merges their findings. A quality veto checks the merged answer; malformed or unsupported output fails closed and forces a re-plan instead of being shown as verified.
Signed-in runs are saved as owner-scoped, append-only outcomes; anonymous demonstrations are not stored. Impact figures on the Agent Desk count only real runs from the current browser session.
§08
Market data without theatre
The 52-hub INR board, Indian and London FX, and the global benchmarks (FTSE 100, NYSE Composite, S&P 500, Shanghai, Hang Seng and more) are fetched on the server from public sources and polled about every minute. We show the source time beside every number and never invent ticks between observations. Five-year history comes from business-day ECB reference rates; unsupported currencies show an error instead of synthetic history.
If a number has no source time, it does not belong on a treasury screen.
§09
Tests & delivery
The repository holds 28 test files with 137 automated checks, all passing on 18 November 2026. Continuous integration runs four independent contract gates — Legal, Filings, Market and Agents — before a single application build:
matrix:
- service: Legal # legal, investments, feasibility
- service: Filings # access, submissions, register, service
- service: Market # fx
- service: Agents # integration, outlook, frontier, runtime, evaluationBrowser checks with Playwright cover the main journeys at phone and desktop widths, including menus, the clearance flow and the demo booking form.
§10
What is not built yet
A credible architecture says where it stops. Today CorpVidesh AI does not:
- submit to RBI FIRMS, IFSCA systems, SWIFT or bank core ledgers — these need authorised access agreements;
- produce real regulator approvals or release money — review lanes are simulated;
- run independently hosted services, message queues or measured scaling targets;
- hold a security certification, a patent grant or licensed real-time market data.
The pilot roadmap names technologies we intend to evaluate for those stages — a permissioned ledger, zero-knowledge headroom proofs, an event stream and a separate model-serving API — and they are labelled as planned, not implemented.