Features at a Glance

A teenager-friendly guide to PiSovereign’s architecture and features

What is PiSovereign? It’s your own private AI assistant that runs on your computer (or a Raspberry Pi) instead of sending your data to the cloud. Think of it as having ChatGPT, but it lives in your house and keeps all your conversations private.

This page explains all the cool stuff PiSovereign can do using simple terms and real-world comparisons.


How It’s Built (Architecture)

PiSovereign is organized like a well-run school where each department has clear responsibilities and rules about who talks to whom.

The Layer Cake

┌─────────────────────────────────────────────────────────────┐
│  🖥️  PRESENTATION  (What you see and interact with)        │
│      Web UI, REST API, Command Line                         │
├─────────────────────────────────────────────────────────────┤
│  🔌  INFRASTRUCTURE  (The plumbing)                         │
│      Database, Cache, Secrets, Metrics                      │
├─────────────────────────────────────────────────────────────┤
│  🔗  INTEGRATION  (Connections to the outside world)        │
│      WhatsApp, Signal, Email, Calendar, Weather, Transit    │
├─────────────────────────────────────────────────────────────┤
│  🧠  AI  (The smart stuff)                                  │
│      LLM Inference, Speech-to-Text, Text-to-Speech          │
├─────────────────────────────────────────────────────────────┤
│  ⚙️  APPLICATION  (Business logic)                          │
│      Services, Use Cases, Rules                             │
├─────────────────────────────────────────────────────────────┤
│  💎  DOMAIN  (Core rules and data)                          │
│      Entities, Value Objects, Commands                      │
└─────────────────────────────────────────────────────────────┘

The Golden Rule: Inner layers never depend on outer layers. The Domain layer doesn’t care if you’re using WhatsApp or a CLI — it just knows about messages and conversations.

Architecture Patterns Explained

PatternReal-World AnalogyWhat It Does
Clean ArchitectureA school with separate buildings for classes, admin, and sportsKeeps code organized so the AI brain doesn’t need to know about databases
Ports & AdaptersUniversal phone charger that fits any outletDifferent services (WhatsApp, Email) plug in without changing the core code
Decorator ChainMatryoshka (Russian nesting) dollsEach layer wraps the previous one, adding features like caching or sanitization
Dependency InjectionLEGO bricks that snap togetherEasy to swap real services for test versions without rewriting code
Event-DrivenWaiter who takes your order while the kitchen cooksBackground tasks run without making you wait for responses
Circuit BreakerElectrical fuse that prevents house firesWhen a service fails repeatedly, stop trying and use a backup plan
Multi-Layer CacheSticky notes (fast) + notebook (permanent)Frequently used data stays in memory; everything else on disk

Feature Quick Reference

Here’s everything PiSovereign can do, explained simply:

⚡ Performance Features

FeatureWhat It DoesReal-World AnalogyWhy It’s Cool
Adaptive Model RoutingSends easy questions to small, fast AI; hard questions to bigger AIExpress checkout vs. full-service lane at the grocery store4× faster for simple questions
Semantic CachingRemembers similar questions you asked before, even if worded differentlyA teacher who remembers “What’s 2+2?” and “Two plus two equals?” are the same questionNo waiting for repeat questions
Multi-Layer CacheStores answers in fast memory + disk backupSticky notes on your desk (fast) + a notebook in your drawer (permanent)Under 1ms for cached answers
In-Process Event BusHandles background work (saving memories, logging) without slowing your replyA restaurant where the waiter takes your order while another waiter clears tables100-500ms saved per message
Proactive Pre-ComputationPrepares common answers before you askA friend who checks the weather before your camping tripInstant morning briefings
Template ResponderAnswers trivial questions instantly without using AIAutomated phone menu for simple requestsUnder 10ms for “Hello!”

🧠 AI Features

FeatureWhat It DoesReal-World AnalogyWhy It’s Cool
ReAct Agent (Tool Calling)AI can use 18 tools: check weather, search web, read calendar, send emailsAn assistant who can look things up instead of just guessingAI acts, not just talks
Multi-Agent OrchestrationMultiple AIs work together on complex tasksA group project where each person handles their specialtyParallel work = faster results
RAG Memory SystemRemembers your preferences, name, and past conversationsA personal diary that the AI actually reads“Hey, I remember you like dark mode!”
Fact ExtractionAutomatically pulls important facts from conversationsHighlighting key points in a textbookNever forgets important stuff
Complexity ClassificationFigures out how hard a question is before answeringA teacher deciding if it’s a pop quiz or a final examRight-sized AI for every question

🔒 Security Features

FeatureWhat It DoesReal-World AnalogyWhy It’s Cool
Prompt Injection DefenseBlocks 60+ patterns of attempts to trick the AIA bouncer checking IDs at a club entranceStops “ignore your instructions” attacks
Output SanitizationHides sensitive info (passwords, credit cards, emails) from responsesA TV censor bleeping out swear wordsPII protection with 17 detection patterns
Context SanitizationCleans external data (web results, tool outputs) before feeding to AIAirport security scanning luggageBlocks hidden malicious instructions
Secret ManagementStores API keys and passwords in a secure vaultA safe with a combination lockSecrets never appear in logs
Encryption at RestEncrypts your memories and conversations on diskA locked diary with a key only you haveXChaCha20-Poly1305 encryption
Rate LimitingPrevents abuse by limiting requests per minuteA “take a number” system at a deli counterAuto-cleanup of old entries
HMAC Tool ReceiptsSigns tool results to detect tamperingA wax seal on a medieval letterCryptographic proof nothing was changed

🔊 Speech Features

FeatureWhat It DoesReal-World AnalogyWhy It’s Cool
Speech-to-Text (STT)Converts voice messages to textA court stenographerLocal processing via Whisper
Text-to-Speech (TTS)Reads responses aloudAn audiobook narratorPiper voices for natural speech
Hybrid ProviderFalls back to OpenAI if local processing failsHaving a backup phone charger99.9% uptime even when hardware struggles

Integrations (External Services)

PiSovereign connects to 8 external services. Each one plugs in via the Ports & Adapters pattern, so adding new ones is easy.

ServiceWhat You Can DoExample Commands
WhatsAppSend and receive messages via WhatsApp Cloud API“Send Mom: Don’t forget the groceries!”
SignalPrivate encrypted messaging via signal-cli“Message my Signal group: meeting at 5pm”
Calendar (CalDAV)View, create, and manage events on any CalDAV server“What’s on my calendar this week?”
Contacts (CardDAV)Look up phone numbers and emails“What’s Sarah’s email address?”
Email (IMAP/SMTP)Read inbox, search, draft, and send emails“Any new emails from GitHub?”
Weather (Open-Meteo)Current conditions and 7-day forecast“Will it rain tomorrow in Berlin?”
Web Search (Brave/DDG)Search the internet privately“Search for vegan pasta recipes”
Transit (HAFAS)German public transport schedules“Next train from Munich to Hamburg?”

How a Request Flows Through the System

Here’s what happens when you ask “What’s the weather tomorrow?”:

1. 📱 You send message via Web UI / WhatsApp / Signal
         │
         ▼
2. 🚦 Adaptive Model Routing classifies complexity
   │   → "weather question" = Simple tier
   │
   ▼
3. 💾 Check Semantic Cache
   │   → Similar question asked before? Return cached answer!
   │   → No hit? Continue...
   │
   ▼
4. 🧠 ReAct Agent decides to use the weather tool
   │   → Calls Open-Meteo API
   │   → Sanitizes the result (removes any hidden tricks)
   │
   ▼
5. 🤖 Small AI model (gemma3:1b) formats the response
         │
         ▼
6. 📤 Output Sanitizer checks for leaked secrets
         │
         ▼
7. 💬 Response sent back to you: "Tomorrow: 18°C, partly cloudy"
         │
         ▼
8. 📝 Event Bus (background): Save to cache, extract facts, log metrics

Total time: ~500ms (vs. 5-8 seconds without optimizations)


The 18 Crates (Code Modules)

PiSovereign is split into 18 Rust crates (think of them as LEGO sets that snap together):

LayerCrateOne-Line Description
DomaindomainCore rules: what is a message, user, conversation?
ApplicationapplicationBusiness logic: how do we handle a chat request?
AIai_coreOllama LLM inference and model routing
AIai_speechSpeech-to-text and text-to-speech
InfrastructureinfrastructureDatabase, cache, secrets, metrics adapters
Integrationintegration_whatsappWhatsApp Cloud API connector
Integrationintegration_signalSignal messenger via signal-cli
Integrationintegration_caldavCalDAV calendar protocol
Integrationintegration_carddavCardDAV contacts protocol
Integrationintegration_emailIMAP/SMTP email
Integrationintegration_weatherOpen-Meteo weather API
Integrationintegration_websearchBrave Search + DuckDuckGo fallback
Integrationintegration_transitGerman public transit (HAFAS)
Presentationpresentation_httpREST API with Axum web framework
Presentationpresentation_cliCommand-line interface
Presentationpresentation_webSolidJS web frontend

Technology Stack

CategoryTechnologyWhy We Use It
LanguageRust 2024Fast, safe, no garbage collector pauses
Async RuntimeTokioHandle thousands of requests concurrently
Web FrameworkAxumType-safe, fast HTTP handling
FrontendSolidJS + Tailwind CSSReactive UI without React’s overhead
DatabasePostgreSQL + pgvectorSQL + vector similarity search
CacheMoka (memory) + Redb (disk)Multi-layer for speed + persistence
LLMOllamaRun AI models locally, no cloud needed
SecretsHashiCorp VaultEnterprise-grade secret storage
ContainersDocker ComposeEasy deployment with profiles
ObservabilityPrometheus + Grafana + LokiMetrics, dashboards, logs

Glossary

TermSimple Definition
LLMLarge Language Model — the AI brain that generates text
RAGRetrieval-Augmented Generation — giving the AI context from your memories
EmbeddingConverting text to numbers so computers can measure similarity
InferenceThe process of the AI generating a response
PortAn interface (contract) that says “I need X capability”
AdapterA concrete implementation that fulfills a port’s contract
DecoratorA wrapper that adds behavior to something without changing it
Circuit BreakerPattern that stops calling a failing service to let it recover
Event BusA message highway where components publish and subscribe to events
STT/TTSSpeech-to-Text / Text-to-Speech
CalDAV/CardDAVCalendar / Contact protocols (like HTTP for calendars)
HAFASGerman public transit API standard

Learn More

Want the full technical details? Check out these pages: