Skip to architecture content
AlkseaEngineering
THE ALKSEA ARCHITECTURE

Understand the system.
Follow every decision.

A visual field guide to how Alksea captures feedback, retrieves knowledge and controls model releases. Start with the whole system. Then trace the decisions inside it.

Code-grounded walkthrough Reviewed 06 Nov 2026
THE PRINCIPLE AT THE CENTER
Evidence
before action.
01 / Evidence02 / Evaluate03 / Approve04 / Publish

A new document, a correction or a passing test never changes a live release on its own.

Implemented

Shared API, versioned knowledge and explicit release workflows.

Configuration-gated

External model egress and operator-managed owned-model execution.

Still requires evidence

Production readiness, real-provider quality and hosted scale guarantees.

A modular core, connected by clear contracts.

Alksea is organized around one application API, a transactional database and background execution. The boxes below describe responsibilities—not a claim that every box is an independently deployed microservice.

SYSTEM / LOGICAL VIEW

One shared core. Clear boundaries.

Select a component to explore
Request / persistence Conditional model callArrows show the main relationships, not every database connection. Boxes represent logical responsibilities; some run in the same process.
TRACE THE CONNECTIONS

Clients → gateway → API → PostgreSQL

API → Redis → worker → database / private objects

Scheduler → Redis · API → private objects

API → model adapter, only when configured

COMPONENT / API

Application API

A modular monolith: Connect, Studio, Model Lab and Ownership share a FastAPI application. Modules enforce identities, tenant scoping, input contracts, release transitions and runtime policies. SQLAlchemy manages persistence; Alembic manages schema changes.

Why it exists

Keep transactions and invariants understandable before introducing the coordination costs of separate services.

What can go wrong

Invalid identity, stale evaluation or an inaccessible release fails closed. A UI button cannot bypass a server-side transition.

Find it in the code

app/main.pyapp/api/app/studio/app/ownership/Paths beginning with app/ live under services/api/.
CONTROL PLANE

Prepare what may become live.

Admins configure assistants, review source versions, freeze evaluation cases, inspect results and independently approve releases. This path changes governed state.

DATA PLANE

Serve what is already published.

A request binds to the active release, checks the caller, admits usage, retrieves permitted evidence and returns a validated response. This path consumes governed state.

Three paths. Different kinds of change.

These products share infrastructure, but they do not learn in the same way. A retrieval update, a correction workflow and a trained model artifact are distinct operations.

01

Connect

Improve an application you already run.

Interactions → reviewed feedback → candidate configuration → paired evaluation → explicit release.

Changes rules, prompts or retrieval configuration through review. Capture is bounded, best-effort and in memory.
02

RAG Studio

Answer from approved knowledge.

Sources → versioned chunks → approved snapshot → grounded answer with citations.

Retrieval augments a request with evidence. It does not change model weights. Default embeddings and answers are deterministic local implementations.
03

Own Model

Manage learned model artifacts.

Reviewed data → configured executor → evaluation → verified export → operator-managed serving.

Model Lab learns local text classifiers. Open-weight adaptation is a separate configured workflow; a diagram is not proof of a GPU run.

Follow the work, one decision at a time.

Choose a journey, then select any step. Each step explains what happens, why it exists and where the behavior lives in the code.

SYNCHRONOUS DATA PLANE

A visitor asks a fictional knowledge assistant a question. Every stage narrows what the system is allowed to use or return.

Illustrative walkthrough · fictional input · no request is sent
STEP 01 / 8

Identify the caller

The request arrives through a server credential, workspace identity or public widget session. The server resolves the tenant and assistant scope.

Why this step matters

The tenant is an authorization decision, not a browser-supplied label to trust.

Authentication tells us who is calling; authorization tells us what they may do.

THE SHAPE OF THE OPERATION
POST /v1/assistants/{assistant_id}/responses
{ input: 'When is the application deadline?' }
IMPLEMENTATION REFERENCE
app/studio/security.py · public_access.py
1 of 8

A document is not an answer. An index is not approval.

Knowledge passes through two different systems: a preparation pipeline that builds versioned evidence, and a request pipeline that selects what a particular caller may see.

01Authorize upload
02Encrypt & version
03Parse & chunk
04Build indexes
05Independent review
06Freeze snapshot

Two locks on every passage.

Lock 1: snapshot membership. The published release specifies exactly which source versions belong to its knowledge set. A newer draft does not enter by accident.

Lock 2: current authority. Tenant scope, assistant scope, current ACLs, provenance ACLs, effective dates and withdrawal rules still apply. A frozen snapshot cannot resurrect withdrawn evidence.

app/studio/retrieval.py → candidates()
BEFORE RELEVANCE RANKING
Tenant + assistant boundary
Published snapshot membership
Approved, active, effective version
Current + provenance permissions
Withdrawal / injection exclusions
Only permitted candidates can rank.
HOW RANKING WORKS

Words + vectors, combined by rank.

Lexical search rewards matching terminology. Dense ranking compares numeric text representations. Reciprocal rank fusion combines their ordering; lexical coverage and snippet deduplication narrow the result.

score = 1 / (60 + lexical rank)
+ 1 / (60 + dense rank)

Current default: local-hash32-v1. Hash embeddings are deterministic testable features, not a pretrained semantic model. Better representation quality requires separate evaluation.

HOW GROUNDING WORKS

The answer carries its evidence.

A supported response requires citations and typed structured output. References preserve source/version identity and precise locators such as a page or line. Citation access is authorized again when inspected.

grounding_statussupportedcitationsource v2 · page 4 · snippet hashhuman reviewrequired

Insufficient evidence can yield an abstention. Sensitive or disallowed requests can yield a refusal. Neither should invent supporting citations.

Evidence can move forward. Live behavior cannot drift.

Connect and Studio use different records, but share the same safety principle: proposed changes, test evidence, approval and active behavior remain separate.

1DraftEditable future state
2EvaluateFrozen comparison
3Independent approvalSeparate authority
4PublishExplicit pointer change
5Observe / roll backRetain the evidence

Draft workspace

New sources, raw feedback, configuration edits and candidate proposals.

May change freely within permissions
Evaluation
+ independent approval
+ publication

Published release

Versioned configuration + frozen snapshot + bound evaluation and approval.

Runtime follows the active release

Stale evidence is rejected

Changing the draft, snapshot or evaluated evidence invalidates the basis for approval. Publication rechecks hashes, revisions and current authority.

Self-approval is restricted

A contributor cannot simply turn their own feedback or proposal into an independently reviewed release. Server rules enforce separate roles and actors.

Rollback is explicit

Restore an eligible earlier release through a recorded transition. Runtime rechecks the release before delivery, so an in-flight request can be stopped after rollback.

Studio: app/studio/releases.py · Connect: app/api/routes.py · Audit: app/domain/store.py

Store identity, evidence and behavior separately.

A single database does not mean a single undifferentiated record. The important relationships make version identity, ownership and release authority inspectable.

OWNERSHIP
Organization / tenant

The authorization boundary

Membership + assistant

Who can act; which assistant owns the work

Draft + configuration

Editable future behavior

KNOWLEDGE
Source → SourceVersion

Origin, checksum, provenance and approval

Chunk

Text, embedding and citation locator

Snapshot + SnapshotItem

Fixed version membership + manifest hash

RELEASE EVIDENCE
EvalCase → EvalRun

Frozen cases, config and paired results

Approval → Release

Independent decision + versioned behavior

RuntimeTrace → Feedback

Observed answer + pending review evidence

Two schema styles coexist.

Connect uses tenant-scoped Resource records with typed payloads for traces, proposals, evaluations, releases and jobs. Studio uses normalized tables such as SourceVersion, Snapshot and EvalRun.

app/db/models.py · app/studio/models.py

Bytes live beside metadata.

The database stores identifiers, state and references. Private object storage holds larger source/report payloads. Studio source encryption and private Connect JSON archives are separate storage guarantees.

app/studio/blobs.py · app/domain/storage.py

Every boundary must earn the next hop.

Security is a chain of narrow decisions. Browser settings, a secret-looking identifier or a successful request to one endpoint cannot substitute for server-side authorization.

Identity & membership

Cookie sessions use session-bound CSRF protection for writes. Optional Firebase authentication binds verified identities to application accounts; organization membership still determines authority.

app/core/security.py · app/api/firebase_auth.py

Tenant-scoped data

Queries and references carry tenant scope. Studio adds PostgreSQL scope/role policies. Source ACL and immutable snapshot restrictions are applied before ranking.

app/db/session.py · app/studio/security.py · retrieval.py

Public widget boundary

The public widget ID is publishable. The server checks the release, allowed origin, audience, session and quotas. CORS is a browser rule, not authentication.

app/studio/public_access.py · public_api.py

Scoped server credentials

Server keys are kept on the backend, hashed for lookup and constrained by scope/assistant or project. Keys are not embedded in the public widget or browser bundle.

app/studio/keys_api.py · app/core/security.py

External-call admission

Provider egress requires explicit policy, operator configuration and a model catalog. Durable reservations and attempt linkage prevent uncertain retries from becoming invisible paid work.

app/studio/provider_transport.py · spend.py · runtime_attempts.py

Object & artifact references

Source reads require current authorization and tenant ownership. Encrypted Studio blobs need the correct secret; owned-model serving must match the expected artifact manifest.

app/studio/blobs.py · app/ownership/runtime.py

A green process is only the beginning.

Separate code structure, deployed topology and verified behavior. They answer different questions: what exists, where it runs and what has actually worked.

LOCAL DEVELOPMENT

Disposable & fast to iterate.

React dev server or built frontend, FastAPI, PostgreSQL/pgvector, Redis and MinIO. Local Compose embeds the scheduler in one worker. SQLite + eager execution supports focused tests but skips the real broker/storage topology.

docker-compose.yml · Makefile
ISOLATED HOSTED PILOT

Real dependencies. Fictional data.

A separate Railway Hobby environment: API, worker, one scheduler, PostgreSQL, Redis and a private S3-compatible bucket. No hosted GPU service or live model-provider quality is implied.

docs/CONNECT_STAGING_SETUP.md
What the recorded pilot established

On 5 November 2026, the Connect acceptance drill at revision a0bb212 passed real asynchronous jobs, private artifact checks, SDK outage/lost-ack recovery, tenant isolation and the independent approval/activation/rollback journey. Later optimization changes have their own local evidence; the earlier hosted result does not verify every later revision.

Failure behavior to understand and test
FailureExpected boundaryWhat it teaches
SDK delivery outageBounded retry; stable trace identity; possible in-memory loss on process crash.Availability and durability are different properties.
Broker or worker unavailableJobs remain non-successful; readiness/recovery and durable state need inspection.Queued does not mean completed.
Evaluation incomplete or failedCandidate cannot advance as if it passed.A release gate must fail closed.
Private storage unavailableDo not claim a successful artifact round-trip or encrypted-source restoration.Database health is not object-storage health.
Provider result uncertainKeep the conservative usage hold; suppress repeat paid attempts and reconcile explicitly.A timeout does not prove the provider did no work.
Permission / release changes in flightRecheck authority and active release before delivery; reject stale output.Correctness depends on time as well as identity.

Understand the tradeoff, not just the technology.

Every architectural choice buys something and costs something. These are the decisions to revisit when measurements—not fashion—show the current shape is limiting the product.

01

One API before many services

What this buys

Shared transactions and fewer network boundaries keep release invariants easier to reason about.

What to watch

Modules still need clear ownership. Split a service only when independent scaling or isolation justifies coordination overhead.

02

A database-backed workflow

What this buys

Revisions, immutable references, audit receipts and usage holds survive application-process restarts.

What to watch

Careful locking, indexes and migrations matter. SQLite success is not a PostgreSQL concurrency result.

03

A queue for slower work

What this buys

Evaluations and maintenance do not need to occupy an interactive HTTP request.

What to watch

Messages can be retried or interrupted. Durable job state, idempotency and recovery are essential.

04

RAG before retraining

What this buys

Approved knowledge can be updated through review without changing model parameters.

What to watch

Retrieval quality depends on chunking, representation, filtering and evaluation. Hash embeddings have clear quality limits.

05

Explicit release transitions

What this buys

A candidate cannot silently overwrite the behavior users are receiving.

What to watch

Review adds friction. Better tooling should make evidence easier to inspect, rather than deleting the approval boundary.

06

Measured performance budgets

What this buys

Lazy routes reduce initial download; SQL pagination avoids loading all history; warm retrieval batches manifest/index checks.

What to watch

The local 40-document benchmark fell from 81 queries to 3. Real hosted PostgreSQL performance and page-specific polling still need measurement.

WANT TO READ THE CODE?

Trace one vertical slice.

Start at a route, follow its authorization and database calls, then inspect the matching tests. This is more useful than reading every file from top to bottom.

  1. Entry pointapp/main.py → route registration + middleware
  2. One runtime requestapp/studio/runtime_api.py → answers.py → retrieval.py
  3. One publicationapp/studio/evaluation.py → releases.py → models.py
  4. Evidence & testsservices/api/tests/ · e2e/tests/ · docs/studio/BUILD_STATUS.md

Keep the concepts within reach.

Plain-language definitions, tied to how this system uses them. Search a term—or an idea inside its explanation.

42 of 42 concepts

API
An application programming interface: the contract another program uses to request behavior. FastAPI implements Alksea's HTTP routes; the browser and SDKs are clients of those contracts.
HTTP & JSON
HTTP carries requests and responses, including methods and status codes. JSON carries structured payloads. A 200 response is transport/application success, not proof an AI answer is true.
RAG
Retrieval-augmented generation: retrieve permitted evidence, provide it to an answer path, and return grounded output. The current default uses deterministic extraction; retrieval does not retrain a model.
Nginx
The web server and reverse proxy in the frontend container. It serves static/prerendered pages and forwards designated paths to the application API.
SQLAlchemy
The Python database toolkit and ORM used to express scoped queries, load records and coordinate transactions. ORM convenience does not replace tenant predicates or authorization.
Alembic
The schema-migration tool that moves a database through versioned structural changes. A real staging database is migrated, rather than recreated from test metadata.
Redis
The service used as Celery's message broker in this architecture. It hands work to workers; PostgreSQL remains the authoritative record of workflow outcomes.
Celery
The Python background-task system. Workers execute jobs; beat schedules periodic work. The database still needs to record whether a task actually succeeded.
Object storage
Storage for larger bytes addressed by object keys, such as encrypted sources and report archives. A database reference to an object must still be authorized, and an object backup is separate from a database backup.
Authentication vs authorization
Authentication establishes the caller's identity. Authorization checks their permission for a particular tenant, operation, assistant, source or release. Signing in does not grant access to every record.
Structured output
A response that follows a validated schema rather than an arbitrary text blob. Alksea's answer contract includes grounding status, citations and template-specific result fields.
Synthetic mock
A controlled implementation that makes fictional behavior reproducible for development and tests. Passing mock scenarios does not measure live model quality or prove production safety.
Control plane
The administrative side that prepares configuration, reviews evidence and authorizes a release. It decides what may become live.
Data plane
The runtime path that serves a request using an already published release and the caller's current permissions.
Modular monolith
One application deployment containing clearly separated modules. It can use independent workers without turning every module into a microservice.
Reverse proxy
A server that accepts client requests and forwards selected paths to another service. Here Nginx serves the frontend and proxies API routes.
Tenant
An organization boundary. Records, credentials, source references and retrieval queries must remain scoped to it.
ACL
An access control list describing who may use a source. Current source ACLs and the version's frozen provenance restrictions both matter.
Snapshot
A fixed set of source-version references and its manifest hash. It freezes knowledge membership without making revoked permissions permanent.
Embedding
A numeric representation used to compare text. The current default is a deterministic 32-dimensional hash vector, not a semantic embedding model.
pgvector
The PostgreSQL extension used for vector storage and similarity ranking. Its presence alone does not establish retrieval quality.
Lexical search
Matching words and text patterns. It complements vector ranking, especially for exact terminology and named identifiers.
Reciprocal rank fusion
A way to combine ordered result lists using rank positions. A chunk gains score for ranking well in both lexical and dense search.
Grounding
Tying an answer to approved supporting evidence. An output contract can require citations or an explicit abstention.
Abstention
Returning that there is insufficient support rather than inventing an answer. This is a valid system result, not necessarily an outage.
Provenance
A record of origin, version, checksum, ownership, review and locators that lets someone inspect where evidence came from.
Idempotency
Making retries of the same logical operation produce a consistent result rather than duplicate side effects. Changed content must not reuse that identity.
Queue / broker
A delivery mechanism for asynchronous work. Redis passes jobs to Celery; the database still records authoritative workflow state.
Worker
A separate process that performs slower jobs and persists outcomes. Worker success must be recorded, not inferred from a queued message.
Scheduler
A process that periodically enqueues maintenance work. The hosted pilot has one separate scheduler.
Transaction
A database unit of work that commits coordinated changes or rolls them back. Useful when state, accounting and audit evidence must agree.
Optimistic concurrency
Rejecting a write when the version has changed since it was read. Release/configuration revision checks prevent stale updates from winning silently.
Row-level security
Database policies that restrict which rows a configured role can access. Studio combines explicit tenant predicates with PostgreSQL tenant scope and role policies.
CSRF
A class of unwanted browser-authenticated writes. Session-bound CSRF tokens and origin checks protect cookie-based mutation routes.
CORS
Browser cross-origin response rules. CORS is not authentication; a permitted origin still needs the right session, release, scope and quotas.
Content hash
A digest that identifies bytes or structured content. It detects changed evidence; it does not prove the content is true.
Budget reservation
A durable hold admitted before external model work. Uncertain outcomes retain a conservative hold until explicit reconciliation.
Evaluation gate
A recorded rule that must pass before a candidate can advance. It complements, rather than replaces, independent approval.
Rollback
An explicit return to a prior eligible release. It changes active behavior while preserving historical traces and audit receipts.
Readiness vs liveness
Liveness says a process responds. Readiness checks whether required dependencies work. Neither alone proves the complete product workflow.
Fine-tuning / LoRA
Changing model parameters, often through a smaller adapter, using training examples. This requires a real configured executor and differs from RAG.
SLO
A service-level objective: a measurable reliability target. An architecture diagram is not evidence that a latency or availability target was achieved.
KEEP ONE QUESTION IN MIND

What evidence authorizes
the next decision?

That question connects the whole architecture—from the first request to the release a user receives.

Back to the system map