← All work

Cosmic AI

Companies onboard themselves and connect several databases to one AI copilot, kept apart

Cosmic AI's data copilot ran as a separate instance for each customer. We turned it into a multi-tenant SaaS where every organization onboards itself, connects several databases and invites its own team, without rebuilding the agent.

B2B SoftwareMulti-tenant AI analytics SaaSBuilt from zero

The super admin dashboard shows platform activity and every registered organization with its owner and status.

The challenge

Each customer ran on its own instance of the copilot, so selling it as a product needed self-serve onboarding, tenant isolation and role-based access.

What we did

We kept the proven agent and built organizations, onboarding with automatic training, super admin access control in middleware and several database connections per organization around it.

The outcome

Organization management, role-based access and multi-database support were delivered through QA, evaluated and handed over to Cosmic AI.

Before
A separate instance for each customer
After
Self-serve organizations on one platform
Roles
Super admin, organization admin, agent
Data
Several databases per organization, a canvas each

The starting point

The copilot lets business users ask plain English questions of their company's databases and documents. It had been proven with a Fortune 500 company and was in use at two companies, each on its own instance.

What had to change

Every new customer meant another separate instance. To sell it as a product, starting with e-commerce companies, it needed self-serve onboarding, tenant isolation and access control.

What could not break

  • Each organization sees only its own data
  • Access follows three roles: super admin, organization admin and agent
  • The proven text to SQL agent and its training layer stay as they are
  • An organization can connect more than one database

The calls we made

We kept the agent and changed what sits around it: organizations, roles and data connections.

  1. 01

    Keep the agent, add the tenancy around it

    The text to SQL agent and its training layer were already proven with real customers, so the multi-tenant work wrapped organizations, onboarding and access control around them.

  2. 02

    Self-serve onboarding with automatic training

    A company signs up, connects its databases, uploads documents and starts automatic training in one onboarding flow, so a new customer no longer needs its own instance.

    Ruled out

    Setting up a separate instance for every new customer.

  3. 03

    Access control in the middleware

    Super admin, organization admin and agent roles are enforced in middleware, so each request is checked against the organization and role before it reaches data.

  4. 04

    Several databases per organization

    Companies keep data in more than one database, so onboarding and training accept several connections, each database gets its own canvas and chat works across all of them.

    Ruled out

    One database per organization, as the single-customer instances worked.

  5. 05

    Route every query to the right database

    With several connections per organization, the backend identifies which database each request is for, and generated SQL was tested per engine, with fixes for PostgreSQL and SQL Server syntax.

How the system fits together

managesign up,connectquestionsaccess rulesautomatictrainingconnectionsallowed requestsSQL per orgreasoningchartsPlatform superadminsManage organizationsand accessOrganizationadminsOnboard, connectdata, add teamTeam membersAgent role, askabout their dataSuper adminconsoleOrganizations andtheir accessSelf-serveonboardingSSO, databases,documentsAccess middlewareChecks organizationand roleCopilot agentText to SQL, kept asbuiltOrganizationdatabasesSeveral perorganizationAzure OpenAIModel behind theagentCanvas perdatabaseAI built charts foreach one
PeopleBuilt by DaticsClient's existing systemAI modelData storeRoles are checked in middleware for every organization, and the agent and its training layer were kept as built while the platform around them changed.

What we built

Organization onboarding

Sign up with SSO, connect one or more databases, upload documents and start automatic training in one onboarding flow.

An organization connects a new data source by name and link, next to its list of connected databases and documents.

Team and user management

Organization admins invite people by link and give them the admin or agent role, next to the organization profile, summary and themes.

The organization admin dashboard lists team members with their status and role next to the active subscription.

A canvas per database

Each connected database gets its own canvas of AI built charts and its own Train with AI pass, and chat works across all of an organization's databases.

Each connected database has its own canvas of AI built charts and tables that can be moved, resized and refreshed.
04

Super admin console

A console where the platform's super admins look up every organization and its users, with search and pagination, backed by access control in the middleware.

How it works

Sign up

A company creates its organization and signs in with SSO.

Connect

Its admin connects one or more databases and uploads documents during onboarding.

Train

The copilot trains on each database automatically, and the admin can add question and SQL pairs and documentation.

Add the team

The admin invites team members by link as admins or agents, each working only inside their organization.

Ask across databases

Members ask questions across the organization's databases, and each database keeps its own canvas of charts.

A closer look

What changed

The copilot moved from one instance per customer to a platform where companies onboard themselves. Organization management, role-based access and multi-database support were delivered, evaluated and handed over to Cosmic AI.

Under the hood

Datics role
Product built by Datics
Tenancy and access
Organizations are kept apart, with super admin, organization admin and agent roles checked in middleware.
Sign in
Clerk with SSO for every organization.
Databases
PostgreSQL, MySQL and Azure SQL connections, several per organization, each identified on every request and given its own canvas.
Security plan
The SaaS plan set out data isolation per tenant, encryption at rest and in transit, and role-based access.

AI and models

LangGraphAzure OpenAI

Data and retrieval

PostgreSQL

Apps and APIs

Next.jsPython

Also in the stack

Vanna AIClerk

How it shipped

  1. One instance per customer

    The copilot ran as a separate instance for each customer: first a Fortune 500 company, then a second instance through QA.

  2. SaaS proposal

    A proposal set out the roles, self-serve onboarding with automatic training, and multitenancy with data isolation, encryption at rest and in transit and role-based access.

  3. Multi-tenant milestone

    Organization management, super admin access control in middleware, several database connections during onboarding and training, a canvas per database and chat across databases.

  4. Evaluation and handover

    QA cycles on each part, a solution evaluation of the SaaS version, then a knowledge transfer to the client.

A milestone with QA cycles

Organization management, access control and multi-database support shipped as one milestone, with each reported issue fixed and passed by QA before release.

Evaluated console by console

Solution evaluations covered the admin console and the agent console separately, then the SaaS version as a whole, before we closed with a knowledge transfer.

What this unlocked

With tenancy in place, the plan was to sell the copilot to many companies, starting with e-commerce.

Have a product with the same kind of constraints?

Tell us what already exists and what you want it to do. We will tell you what it takes.

Book a 30-minute Product Review