Streaming 24h · Cash session shut · Connecting · --:--:-- UTC

USD/INR—0.00%EUR/INR—0.00%GBP/INR—0.00%JPY/INR—0.00%AUD/INR—0.00%SGD/INR—0.00%CHF/INR—0.00%HKD/INR—0.00%
Reliance Industries → Singapore · ₹475 cr · ODI

How CorpVidesh AI is built.

Layers, domains, record integrity, agents and tests — the engineering behind one pre-validated record for Indian outbound capital.

By Raja Mukherjee · Team Quantum Leap18 November 202612 min readDepartment of Law · Brainware University

5

Layers

4

Server domains

12

Database migrations

5

Agent desk tools

137

Automated checks

4

CI contract gates

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.

  1. 01Precision. Every legal answer cites a provision; every price shows its source time.
  2. 02Separation. Rules live in pure modules; servers do I/O; screens only display.
  3. 03Append, never edit. Filings and reviews are added as new events, never overwritten.
  4. 04Least authority. Roles and company memberships are checked on the server for every write.
  5. 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.

ConcernChoiceWhy
InterfaceReact 19, TanStack Router, Tailwind CSSType-safe routes; one design token set for the red/white grid
ServerTanStack Start server functions on edge workersValidated inputs, no exposed keys, low latency
DataLovable Cloud Postgres with row-level securityIsolation enforced by the database, not by the screen
IdentityEmail/password and Lovable sign-in, server-assigned rolesRoles stored separately from profiles
AILovable AI Gateway called only from server modulesModel keys stay server-side; answers carry sources
VisualsSVG diagrams, Three.js loaded only in the browser3D never blocks server rendering
QualityVitest, Playwright checks, GitHub ActionsEach 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.

Fig. 1 · System architectureOpen interactive →
01USERSCorporate treasuryCFO · treasury deskAD Category-I bankauthorised dealerGIFT IFSC desksnine review rolesRegulator reviewerssix authority lanesFund investorsoffshore proposals02WORKSPACESTreasury consolefilings · Form FCGIFT clearance portalmulti-party caseSecure Form FC portalregulator actionsFund portalproposal trackingAgent deskfive AI agentsEvidence studioproof · mechanism03SERVER DOMAINSLegal triageFEMA · OI Rules 2022Filingssnapshot · appendMarkets & FX52 hubs · benchmarksAgentsgraph · copilot · reader04SAFEGUARDSSign-in & rolesserver-checkedRow isolationper company / deskAppend-only + hashSHA-256 chainQA vetofails closedTrace IDspayload-free logs05DATA & SOURCESCloud databaseencrypted recordsStatute corpuscited provisionsFX providersECB · market feedsRBI ODI releasesdaily syncAI gatewayserver-side keysNot connected today: RBI FIRMS · IFSCA systems · SWIFT · bank core ledgersplanned integrations — require authorised access agreements
Swipe sideways to see the full diagramUsers → workspaces → server domains → safeguards → data. The dashed band lists official systems that are deliberately not connected today.

§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:

src/lib/legal-services.functions.tsexcerpt
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.

Fig. 2 · Functional flowOpen interactive →
01Select companytop-1,000 · hub · currency02Choose class & amount212 ODI / OPI purposes03Route triageAutomatic vs Approval04Document checkliststatute-linked gating05File Form FCappend-only record06Six-lane reviewparallel · simulated07Hash-chained recordtamper-evident trail08Proof packetexport & replaycompletemissing document → blockedEvery arrow writes to the same case record. Regulator responses are demonstrations, not official approvals.
Swipe sideways to see the full diagramEight steps from selection to proof packet. Regulator responses in the prototype are demonstrations, not official approvals.

Every server operation gets a fresh trace ID and a duration/outcome log line — with no payloads, identities or automatic retries:

src/lib/services/runtime.server.tsexcerpt
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:

drizzle/migrations/0007_gift_atomic_filing_and_workflow.sqlexcerpt
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.

Fig. 3 · Trust & isolationOpen interactive →
EVENT 1Case openedprev: genesishash: h1linksEVENT 2Checklist completeprev: h1hash: h2linksEVENT 3Form FC filedprev: h2hash: h3linksEVENT 4Lane actionsprev: h3hash: h4linksEVENT 5Proof issuedprev: h4hash: h5Changing any earlier event breaks every later hash — tampering becomes visible. This is record integrity, not blockchain consensus.Private deskscompany-scoped recordsassigned regulator rolesROW ISOLATIONPublic showcase desksshared demo sign-inscannot see private casesServer checks every writerole → company → workflow orderno client-side authority
Swipe sideways to see the full diagramEach event carries the previous hash; editing history breaks every later link. This proves record integrity — it is not blockchain consensus.

§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.

Fig. 4 · Agent graphOpen interactive →
Statutory retrievercited provisionsRoute triageAutomatic / ApprovalTax & treatySection 195 · DTAAFX outlookconditional scenariosDocument readerextract & flagEvidence writerappend-only outcomeveto → re-planQA vetofail closedCoordinatorplans · routes · mergesbounded shared context
Swipe sideways to see the full diagramCoordinator, seven specialists and a fail-closed quality veto. AI outputs are advisory and cannot file, approve or move money.

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:

.github/workflows/service-ci.ymlexcerpt
matrix:
  - service: Legal     # legal, investments, feasibility
  - service: Filings   # access, submissions, register, service
  - service: Market    # fx
  - service: Agents    # integration, outlook, frontier, runtime, evaluation

Browser 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.