Case Study — AI Session Architecture

Project-scoped AI conversation system with persistent .session SQLite files in Drive-backed storage.

<500ms
session load time
6
API endpoints
Isolated
multi-project sessions
SQLite
persistence layer

The challenge.

AI conversations in multi-tenant SaaS platforms are typically stateless or stored in a central database with no project isolation. When users switch projects, conversation history is lost. Sessions can't be shared, exported, or versioned alongside the project assets they relate to.

The existing chat architecture treated all conversations as global — a single bucket with no relation to the work a user was doing in a specific project. Switching between projects meant abandoning the conversation context, and there was no way to bundle AI chat history with project exports or backups.

The specific problems
  • No project-level scoping — all AI conversations lived in a global namespace with no isolation
  • Conversation context lost on project switch, forcing users to repeat themselves
  • Sessions could not be exported, versioned, or backed up alongside project assets
  • No API surface for managing sessions — creating, listing, or deleting conversations required direct database access

What was built.

A complete session architecture where every AI conversation is scoped to a project, persisted as a portable .session SQLite file, and managed through a dedicated REST API.

Project-Scoped Session Model
Designed a session architecture where every AI conversation is scoped to a specific project. Sessions live as dedicated .session SQLite files stored in Drive-backed project storage — the same system used for documents, images, and other project artifacts. This means sessions are portable, backup-able, and travel with the project on export and restore.
Session Lifecycle API
Built 6 REST API endpoints (/api/sessions CRUD) for creating, listing, fetching, updating, previewing, and deleting sessions. Each endpoint validates project membership, enforces access control, and returns structured metadata — last message preview, message count, created date, and associated tools.
SQLite Persistence Layer
Implemented a SQLite-backed storage engine where each .session file contains the full conversation history, tool call trace, context window, and configuration. This is lightweight, zero-infrastructure (no separate database), and enables instant project-level backup and restore without any additional services.
Frontend Integration
Wired the session API into the React frontend with a session sidebar, active session indicator, and seamless project-switching that preserves conversation context. Used TanStack Query for caching and optimistic updates, delivering instant UI feedback on session creation and deletion.

What shipped.

<500ms
session load time from API call to rendered conversation in the sidebar
6
REST API endpoints covering full CRUD + preview — create, list, fetch, update, preview, delete
Zero
cross-project contamination — sessions are fully isolated per project
Portable
sessions travel with project exports and backups as standalone .session files
No infra
no separate database or infrastructure — SQLite files in existing Drive storage
Optimistic
UI updates via TanStack Query with instant feedback on session create/delete
TypeScript NestJS React 18 TanStack Query SQLite MobX REST API Docker

The developer.

Varazdat Tsarukyan
Varazdat Tsarukyan
Full-Stack Engineer

7+ years building full-stack web applications with React, TypeScript, and NestJS. Deep experience designing and shipping multi-module AI workspace platforms — project-scoped AI sessions, file management, multi-platform communication channels (Telegram, Slack, Discord), and productivity app integrations (Mail, Google, Drive).

Need project-scoped AI sessions built for your platform?

Fixed-price sprints. PM included. First sprint free if we miss scope. Start with Sprint Zero at $2,500 — 2-week diagnostic, money-back guaranteed.