UAI

Architecture of LTM

How the system that remembers everything is built

What is LTM architecture

LTM is a system built on the principle of distributed intelligence. Just as the brain consists of centers (visualization, memory, speech, analysis), LTM consists of servers and modules, each responsible for its own task.

Architecture is not "how to make it beautiful", but "how to make the system work for years".

Now: three servers

In the current implementation, the system runs on three servers:

Interface server

Responsible for interaction with the user. Accepts requests from the browser, checks which page is requested, and passes control to the page server. Knows nothing about data — only about pages.

Page server

Creates pages, assembles content, renders templates. Knows about pages and templates, but not about the database directly — requests data from the data server.

Data server

Stores the database system, knowledge storage, modules (users, projects, branches, messages, files). Knows about data, but not about pages.

Each server is independent. If one fails, the others continue to work.

Future: server separation

When donations appear, we will separate knowledge storage, database system, and AI into separate servers. Each will be responsible for its own task:

  • Knowledge storage server — knowledge storage (not only files, but also the future knowledge base for AI: tags, crosslinks, connections).
  • Database server — database system that stores queries.
  • AI server — AI agents (DeepSeek, GPT, Claude) + vector knowledge base (tags, crosslinks, meanings, associative connections, core information, compressed meaning of messages, behavior rules, communication rules).

It is like a brain: each center is responsible for its own, and neural connections unite them into a single system.

AI agents — self-improvement of the system

The system has AI agents that monitor self-improvement:

  • Read logs (errors, warnings).
  • Search for problems (analysis, search).
  • Manage debug mode of modules.
  • Help with diagnostics.

Vector knowledge base is a key part of AI agents. It stores tags, crosslinks, meanings, associative connections, core information, compressed meaning of messages, behavior rules, communication rules (which are formed each time).

AI agents work with their own vector knowledge base (answer by meanings), and only if specific details are needed (quote, exact fragment) — they turn to the database system.

This reduces the load on the database: agents do not load it with unnecessary requests, work with their local knowledge base, and access the DB only when necessary.

AI agents are the "brain" of the system that learns from mistakes and suggests improvements.

Modules — black boxes

A module = contract + implementation. Contract is the interface (what the module does). Implementation is hidden (how it does it).

  • User management
  • Projects and discussions
  • Branches
  • Messages
  • Files
  • Database queries (via XML, without direct SQL)

No one sees the internals of a module — only the interface. This allows replacing parts of the system without stopping the whole.

Event system — nervous system

All modules communicate through events. The event system is a bus that accepts an event and passes it to the right module.

Example: user request → event system → data module → database.

Event-Driven is not a trend, but a necessity: the system sees all communication, can analyze patterns, add logging and caching.

Internal optimization — 100x speedup

Problem: when there are many events, the system iterates through all listeners for each event — slowly.

Solution: we created an internal optimization system. It remembers the module's handler in a local cache. The first call — through the event system, the next — direct call.

Each module has its own local cache (5–10 events that it actually calls), not a shared one for everything.

This sped up the system ~100x on repeated requests.

Memory cache — cache of repeated requests

If a request is repeated (from the user or from another module) — the system immediately returns the ready answer without reaching the module.

Reference books, static, translations — cached in memory. Repeated requests — instantly.

Two levels of cache: external (repeated requests) + internal (results). Repeated requests — do not reach the database.

Reload without restart

You can add a new module or reload an existing one without restarting the server.

  • Add module — add a new module at runtime.
  • Reload module — reload an existing module.
  • Re-read config — re-read config (e.g., list of pages).

This is important for development: added a page — no need to restart the server.

AI-First — AI in architecture from the start

AI is not "added later". It is built in from the start: each module collects metrics, analyzes errors, suggests improvements.

In plans: AI agents (DeepSeek, GPT, Claude) — which read context from memory and help work with the system.

AI-First is not an add-on, but architecture. The system becomes smarter with each user.