Skip to content
Introducing AI OS for Business & School — our most powerful products yet.Explore →
App Corp iconApp Corp
Engineering
Real-Time
Marketplace
Architecture

Engineering Kismaa: Three Systems Acting as One

The architecture behind a real-time psychic marketplace where user, psychic, and admin systems must stay in perfect sync

AE

App Corp Engineering

Editorial Team

September 20, 202614 mins read
14 mins readRead time
366Words
Sep 2026Published
App Corp Engineering·Editorial Team

Most marketplaces struggle with latency, coordination, and fragmented user experiences. Kismaa's bar was higher: three distinct systems — a user app, a psychic app, and an admin operating system — had to behave like one unified platform operating in real-time sync. Users expect instant connection, psychics expect session requests without delay, and billing must be continuous and accurate mid-session. Here's the engineering that made it possible.

The Three-Role Architecture

We designed the platform as three interacting roles before writing a line of UI: users (discover and book sessions), psychics (manage availability and conduct sessions), and admins (monitor and manage the platform). Each role has distinct permissions, lifecycle flows, and data access patterns. The critical insight: these aren't three separate apps — they're three views of one unified data model. A session created by a user instantly appears in the psychic's queue and the admin's dashboard.

Event-Driven State Synchronization

Every state change — a user books a session, a psychic comes online, a session starts — is an event that propagates to all connected clients in real-time. We used WebSocket connections with Redis Pub/Sub as the event bus. When a psychic's availability changes, the event is published to Redis, and all connected clients (user app, psychic app, admin dashboard) update within milliseconds. No polling, no refresh buttons, no stale data.

Note

WebSocket connections consume memory and file descriptors. We implemented connection pooling: a single WebSocket server handles up to 5,000 connections, with sticky sessions for in-memory state consistency.

The Matching Engine

The matching engine pairs users with available psychics under concurrent load. We used BullMQ (Redis-backed) to decouple match calculation from WebSocket connection management. When a user enters the queue, a 'match-request' job is added. When a psychologist comes online, a 'match-recalculate' job is triggered. The queue processor runs match scoring in batches, comparing pending requests against available practitioners. This decoupling meant WebSocket connections stayed lightweight — they only handled real-time messages, not complex scoring logic.

Session Lifecycle Orchestration

A session on Kismaa has 6 states: Request → Accept → Connect → Track → Charge → End. Each state transition is an event that triggers side effects: push notifications, billing updates, UI changes. The lifecycle is deterministic — a session can't skip states or reverse. We implemented a state machine that validates every transition and rejects invalid ones. This prevented edge cases like billing starting before a session is connected, or a session ending without final billing.

Conclusion

Building three systems that act as one requires a unified data model, event-driven state synchronization, and deterministic lifecycle management. The architecture's strength isn't in any single technology — it's in the separation of concerns: WebSocket connections handle real-time messages, Redis handles event routing, BullMQ handles match calculation, and PostgreSQL handles durable state.

Key Takeaways

  • Three roles (user, psychic, admin) sharing one unified data model eliminates sync issues
  • Event-driven state sync via Redis Pub/Sub updates all clients within milliseconds
  • BullMQ decouples match calculation from WebSocket connections for independent scaling
  • Deterministic session lifecycle with 6 states prevents edge cases and billing errors

We value your privacy

We use strictly necessary cookies to keep our site secure and functional. With your consent, we also use performance cookies to understand how you interact with our site, and functional cookies to remember your preferences. Read our full Cookie Policy