How tjing9430/cc-companion-app works
CC Companion is a self-hosted mobile AI companion: users chat privately or in groups, receive streamed agent responses, and manage memory, documents, settings, and console activity through a web app. The HTTP server routes requests into domain modules, which use shared state and local JSON/SQLite storage; chat can use OpenAI-compatible services, Claude Code Bridge, or DSH. The README documents additional attachment, search, file-editing, theme, and PWA capabilities. Several domain links are documented rather than visible in sampled handlers; those are marked dashed.
Main entry points: app.js Web app shell · server.js HTTP server · chat.js Chat orchestration · state.js Application state
Components 30
Web client
- Web app shell
public/app.js - Chat views
public/js/chat-view.js - Memory views
public/js/memory-view.js - Home views
public/js/home-view.js - Console views
public/js/console-view.js - Settings views
public/js/settings-view.js - More views
public/js/more-view.js - Workflow views
public/js/workflow-view.js - PWA service worker
public/sw.js
HTTP and domains
- HTTP server
server.js - Chat orchestration
lib/chat.js - Message operations
lib/messages.js - Memory domain
lib/memory.js - Documents
lib/docs.js - Console events
lib/console.js - Config library
lib/config-library.js
State and persistence
- Application state
lib/state.js - SQLite backend
lib/store-sqlite.js - JSON data files
Agent integrations
- OpenAI-compatible API
- OpenAI adapter
adapters/openai-compatible.template.js - Claude Code Bridge
bridge/index.js - DSH integration
lib/dsh.js - DSH worker
adapters/dsh-worker.py
Companion capabilities
- Heartbeat
lib/heartbeat.js - Session forge
lib/forge.js - Session rotation
lib/session-rotation.js - Embedding service
lib/embedding.js - Event streaming
lib/sse.js
Other components
- Companion user
Connections 42
- Companion user → Web app shell: uses
README.md - Web app shell → Chat views: renders
public/app.js - Web app shell → Memory views: renders
public/app.js - Web app shell → Home views: renders
public/app.js - Web app shell → Console views: renders
public/app.js - Web app shell → Settings views: renders
public/app.js - Web app shell → More views: loads
public/app.js - Web app shell → Workflow views: renders
- Web app shell → HTTP server: requests APIs
- Web app shell → PWA service worker: registers
- HTTP server → Chat orchestration: routes chat
server.js - HTTP server → Message operations: routes messages
server.js - HTTP server → Memory domain: routes memory
server.js - HTTP server → Documents: routes documents
server.js - HTTP server → Console events: records events
server.js - HTTP server → Config library: routes config
server.js - HTTP server → Heartbeat: triggers
server.js - HTTP server → Session rotation: runs rotation
server.js - HTTP server → Event streaming: broadcasts
server.js - Chat orchestration → Application state: reads and writes
lib/chat.js - Chat orchestration → Message operations: uses
lib/chat.js - Chat orchestration → Memory domain: retrieves context
lib/chat.js - Chat orchestration → Documents: retrieves documents
lib/chat.js - Chat orchestration → DSH integration: dispatches
lib/chat.js - Chat orchestration → Event streaming: streams
lib/chat.js - Memory domain → Application state: reads and writes
lib/memory.js - Memory domain → Embedding service: embeds and searches
lib/memory.js - Memory domain → Event streaming: broadcasts updates
lib/memory.js - Documents → Application state: reads and writes
lib/docs.js - Documents → Embedding service: uses vectors
lib/docs.js - Documents → Event streaming: broadcasts updates
lib/docs.js - Console events → Application state: persists events
lib/console.js - Console events → Event streaming: broadcasts events
lib/console.js - Session rotation → Session forge: rotates session
lib/session-rotation.js - Session rotation → Console events: records rotation
lib/session-rotation.js - Application state → SQLite backend: opens backend
lib/state.js - Application state → JSON data files: loads and saves
- Chat orchestration → OpenAI-compatible API: calls model
- OpenAI adapter → OpenAI-compatible API: implements protocol
README.md - Chat orchestration → Claude Code Bridge: uses compatible endpoint
- Chat orchestration → DSH worker: runs worker
- DSH integration → DSH worker: delegates