Architecture Overview
This section describes the overall architecture of the Plus261 system, including the main components, data flow, security, and scalability considerations.
Deployment and runtime
Section intitulée « Deployment and runtime »Applications are packaged as container images (nerdctl) and run on Kubernetes:
- Local: k3d + Traefik — see Local development
- Production: k3s + Traefik + registry — see Production
Full picture: Infrastructure overview and Deployment.
General Architecture
Section intitulée « General Architecture »Plus261 follows a monorepo architecture with clear separation of responsibilities:
┌─────────────────────────────────────────────────────────┐│ Web (SvelteKit) ││ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ││ │ UI Layer │ │ Offline DB │ │ Chat & calls │ ││ └──────────────┘ └──────────────┘ └──────────────┘ │└───────────────────────┬─────────────────────────────────┘ │ GraphQL │ WebSocket┌───────────────────────▼─────────────────────────────────┐│ API (GraphQL Yoga) ││ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ││ │ Auth/ACL │ │ Business │ │ Observability│ ││ └──────────────┘ └──────────────┘ └──────────────┘ │└───────────────────────┬─────────────────────────────────┘ │┌───────────────────────▼─────────────────────────────────┐│ PostgreSQL Database │└─────────────────────────────────────────────────────────┘Main Components
Section intitulée « Main Components »Web Client
Section intitulée « Web Client »The web client is a SvelteKit 5 application with offline-first architecture.
| Component | Technology | Purpose |
|---|---|---|
| Framework | SvelteKit 5 with Svelte 5 | Modern web framework |
| Local Storage | IndexedDB via Drizzle ORM | Offline data storage |
| Offline Mode | Service Worker | Offline operation and sync |
| Chat & calls | GraphQL subscriptions + LiveKit | Messaging, voice, calls |
| GraphQL | Generated client (@lib/client) |
Type-safe API client |
Learn more: Web Overview
API Server
Section intitulée « API Server »The API is a GraphQL server built with GraphQL Yoga and Type GraphQL Query.
| Component | Technology | Purpose |
|---|---|---|
| Framework | GraphQL Yoga | GraphQL server |
| Schema Builder | Type GraphQL Query | Automatic schema generation |
| Database | PostgreSQL with Drizzle ORM | Data persistence |
| Authentication | Sessions with Arctic | User authentication |
| ACL | Permission system | Access control |
| Observability | Prometheus, Loki, Tempo | Monitoring and logging |
Learn more: API Overview
Shared Libraries
Section intitulée « Shared Libraries »Shared libraries provide reusable functionality across applications.
| Library | Purpose |
|---|---|
@lib/db |
Database schema and ORM |
@lib/client |
Generated GraphQL client |
@lib/drizzle-query |
Query helpers |
@lib/type-graphql-query |
GraphQL schema builder |
Learn more: Libraries Overview
Data Flow
Section intitulée « Data Flow »GraphQL Queries
Section intitulée « GraphQL Queries »Web → GraphQL Client → API → Drizzle ORM → PostgreSQL ↓ IndexedDB (cache)Key Points:
- Queries are cached in IndexedDB for offline access
- Type-safe client ensures compile-time safety
- Automatic retry and error handling
Offline Mode
Section intitulée « Offline Mode »Web → IndexedDB (local) ↓ Service Worker ↓ Synchronization (reconnection) ↓ API → PostgreSQLKey Points:
- All operations work offline
- Changes are queued for synchronization
- Automatic conflict resolution
- Background sync on reconnection
Real-time Chat
Section intitulée « Real-time Chat »Web ──GraphQL (HTTP)──▶ API ──▶ PostgreSQL (conversations, messages, calls) ▲ │ └──WebSocket (chatEvents)◀── Redis pub/sub (every API instance)
Calls: Web ◀──WebRTC (UDP/TCP)──▶ LiveKit ──webhook──▶ APIKey Points:
- Messages, read state and call history are stored by the API (no external chat server)
- Real-time events per conversation, filtered by read access
- Audio/video media goes through a self-hosted LiveKit server; calls can be switched off when resources saturate
Learn more: Chat & Calls API
Security Architecture
Section intitulée « Security Architecture »Authentication
Section intitulée « Authentication »- ✅ Secure sessions with tokens
- ✅ Automatic refresh tokens
- ✅ OAuth support (via Arctic)
- ✅ Session management
Learn more: Security Architecture
Authorization
Section intitulée « Authorization »- ✅ Permission-based ACL
- ✅ Server-side verification
- ✅ Client-side permission caching
- ✅ Role-based access control
Learn more: API - Permissions
Data Protection
Section intitulée « Data Protection »- ✅ Encryption of sensitive data
- ✅ Input validation
- ✅ CSRF protection
- ✅ SQL injection prevention
Observability
Section intitulée « Observability »- ✅ Structured logs with Loki
- ✅ Configurable log levels
- ✅ Request context tracking
- ✅ Error tracking
Learn more: API - Logging
- ✅ Prometheus metrics
- ✅ Grafana dashboards
- ✅ Configurable alerts
- ✅ Performance monitoring
Learn more: API - Metrics
- ✅ Distributed tracing with Tempo
- ✅ Request correlation
- ✅ Performance monitoring
- ✅ Dependency tracking
Learn more: API - Tracing
Scalability
Section intitulée « Scalability »Database
Section intitulée « Database »- ✅ Optimized indexing
- ✅ Query optimization
- ✅ Connection pooling
- ✅ Read replicas support
Learn more: Database Architecture
- ✅ Cache for frequent queries
- ✅ Rate limiting
- ✅ Load balancing ready
- ✅ Horizontal scaling
Learn more: Scalability
- ✅ Code splitting
- ✅ Lazy loading
- ✅ Service Worker caching
- ✅ Optimized bundle size
Quick Reference
Section intitulée « Quick Reference »| Topic | Documentation |
|---|---|
| 🏗️ Detailed Architecture | Detailed Architecture |
| 🔐 Security | Security Architecture |
| 🚀 Deployment | Deployment Strategies |
| 📊 Database | Database Architecture |
| 📈 Scalability | Scalability |
| 📡 Data Flow | Data Flow |
| 📊 Monitoring | Monitoring |
Next Steps
Section intitulée « Next Steps »Dive deeper into specific areas:
- 🏗️ Detailed Architecture - Deep dive into architecture
- 🔐 Security - Security architecture
- 🚀 Deployment - Deployment strategies
- 📊 Database - Database architecture
Related Topics
Section intitulée « Related Topics »- API Overview - API architecture
- Web Overview - Web client architecture
- Code Structure - Codebase organization
- Development Guide - Development workflow