DEV Community

usemanusai
usemanusai

Posted on

More Than Cache: Architecting a Redis 8–Powered Web OS

Redis AI Challenge: Beyond the Cache

This is a submission for the Redis AI Challenge: Beyond the Cache.

JAEGIS Web OS — Beyond the Cache (Redis 8)

Title: JAEGIS Web OS: RedisJSON + RediSearch + Streams as a Primary Data Layer
Date: 11 August 2025

What We Built (Database‑First with Redis 8)

We use Redis 8 as the database and event engine for two Web OSes. RedisJSON stores core entities; RediSearch (when enabled) accelerates queries; Streams power analytics and pipelines. This submission focuses on Redis as the primary data layer — not as a cache.

  • OS #2 — Agent Ecosystem Web OS (flagship; start here)
    • JSON documents for users/sessions/conversations; optional RediSearch indexes; Streams for events
    • Metrics endpoint parses Redis INFO → used_memory, ops/sec
  • OS #1 — Core Developer OS (baseline)
    • Applies the same Redis patterns with a smaller surface area

Repository (update after push):

Docs:

  • web-os-2/README.md — full API docs, Docker Compose, diagrams
  • web-os-1/README.md — core OS overview

Deep Dive: Redis 8 Beyond Cache (OS #2)

1) JSON as System of Record

  • Keys: user:{id}, session:{id}, chat:conversation:{id}
  • Server JSON ops: web-os-2/src/lib/redis-server.ts → jsonSet/jsonGet()
  • Client lifecycle: web-os-2/src/lib/redis-client.ts

2) RediSearch Indexes & Queries

  • Init: web-os-2/src/lib/redis-init.ts → initializeSearchIndexes()
  • Commands:
FT.CREATE idx:user ON JSON PREFIX 1 user: SCHEMA \
  $.email AS email TEXT SORTABLE \
  $.handle AS handle TEXT SORTABLE
FT.CREATE idx:session ON JSON PREFIX 1 session: SCHEMA \
  $.token AS token TEXT \
  $.userId AS userId TEXT
Enter fullscreen mode Exit fullscreen mode

3) Streams for Pipelines & Audit

  • web-os-2/src/lib/redis-streams.ts: sendToAgent (XADD), read groups, ack, dead letter
  • MAXLEN bounding to control memory; consumer groups scale out

4) Access Patterns, TTLs, and Sessions

  • Sessions as JSON with expirations; EXPIRE/setex for ephemeral caches in prod

5) Telemetry & Introspection

  • web-os-2/src/app/api/system/metrics/route.ts → parseRedisInfo() + dbSize()

6) Boot & Operations

  • web-os-2/server.ts → initializeRedisSystem() at startup (connection + index checks)

OS #1 Summary

  • web-os-1/ — presents the same architecture motifs; ideal as a clean baseline
  • Focus fields: auth/session JSON storage; dev‑friendly flows

Setup & Verification

cd web-os-2
npm install
npm run dev
npm run smoke
Enter fullscreen mode Exit fullscreen mode

Optional Redis Stack

docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest
Enter fullscreen mode Exit fullscreen mode

Docker Compose

docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

API Summary

  • Auth: /api/auth/register, /api/auth/login
  • Health: /api/health
  • Metrics: /api/system/metrics
  • AI: /api/ai/chat, /api/ai/image, /api/ai/search

Performance & Scaling

  • FT.SEARCH for low‑latency lookups; JSON scans only as a compatibility fallback in dev
  • Stream consumer groups; DLQ handling for resilience
  • Shared client with reconnect strategies

Security & Ops

  • JWT cookies; recommend managed Redis with TLS endpoints
  • Monitor used_memory, ops/sec, key counts; alerts on connection spikes and fragmentation

Top comments (0)