ARCHITECTURE
Surfaces
Claude Code>_
Telegram💬
Cowork🤝
CLIgolems *
Any Agent🤖
Golem Plugins
🤖
ClaudeGolem
orchestrator
👔Recruiter
outreach & practice
💰Teller
finance & tax
🗓️Coach
calendar & plans
🔍Job
scraping & matching
✍️Content
LinkedIn & writing
SkillsMCP ToolsRulesContext
Infrastructure
ServicesRailway cloud
EmailJobsBriefing
SupabasePostgres + RLS
BrainLayer284K+ chunks
7 agents36 skills8 MCP servers284K+ chunks

Many ways in. Same powerful golems underneath.

Golems Architecture — Data flow between local Mac and Railway cloud

7 Golems + Infrastructure, 3 Environments

Golems is a Bun workspace monorepo with 11 packages — 7 golems (1 orchestrator + 6 domain experts) plus shared infrastructure. Work splits between your local Mac (cognitive tasks), Railway cloud (data collection), and Vercel (web dashboard).

PackageRole
@golems/sharedFoundation — Supabase, LLM, email, state, notifications
@golems/claudeOrchestrator — Telegram bot, command routing
@golems/recruiterOutreach, contacts, interview practice (Elo)
@golems/tellerFinance, tax categorization, spending reports
@golems/jobsJob scraping, matching, MCP tools
@golems/contentVisual content factory (Remotion, ComfyUI, dataviz) + text publishing
@golems/coachWhoop biometrics, Huberman protocols, daily planning
@golems/servicesNight Shift, Briefing, Cloud Worker, Wizard, Doctor
docsiteNext.js web dashboard (brain view, ops, backlog, content, tokens)
golems-tuiReact Ink terminal dashboard
tax-helperSchedule C transaction categorization (Sophtron MCP)

Mac = Brain, Railway = Body

Loading diagram...

Cloud Worker Schedule

The Railway cloud worker runs these jobs on a timer:

JobIntervalWhatModel
Email PollerHourly (6am-7pm, skip noon, +10pm)Fetch Gmail, route to GolemsGemini Flash-Lite
Job Scraper6am, 9am, 1pm Sun-ThuFind relevant jobs, scoreGemini Flash-Lite
Whoop Sync5x daily (7am, 10am, 2pm, 5pm, 8pm)Sync biometrics to Supabase
Briefing8:00 AMDaily Telegram summaryGemini Flash-Lite

Cloud jobs use Gemini 2.5 Flash-Lite (free tier) for cost efficiency. Each job publishes events to Supabase that trigger Mac-side Golems.

Local Services (Mac)

Your Mac runs these always-on services:

ServiceWhatTech
Telegram BotReceive commands, send notificationsgrammy.js
Night ShiftScan repos for improvements, auto-commitClaude + Ralph
Notification ServerQueue and send Telegram messagesHTTP server
BrainLayer Memory284K+ chunks, 12 MCP tools, semantic search + brain_digestFastAPI + sqlite-vec + BrainBar daemon
Render ServiceRemotion video rendering microserviceBun + Remotion
EnrichmentProcess BrainLayer chunks (tags, summaries)GLM-4.7-Flash via Ollama

The local services have direct compute access — they run local GLM-4.7-Flash (via Ollama) or cloud models when needed.

Event Flow

When an email arrives:

Loading diagram...

Environment Variables (Dual Mode)

Golems supports dual mode — run cloud or local via three env vars:

# LLM Backend: where LLM calls happen
export LLM_BACKEND=gemini     # Cloud: Gemini Flash-Lite (free, default)
export LLM_BACKEND=ollama     # Local: Ollama on Mac (for testing)
export LLM_BACKEND=haiku      # Cloud: Haiku (paid fallback, optional)
 
# State Storage: where data lives
export STATE_BACKEND=supabase # Cloud: Supabase database
export STATE_BACKEND=file     # Local: ~/.brainlayer/
 
# Notifications: where Telegram messages go
export TELEGRAM_MODE=direct   # Cloud worker sends directly
export TELEGRAM_MODE=local    # Mac notifier (HTTP) sends

Switching Modes

Full Cloud Mode (Production)

export LLM_BACKEND=gemini
export STATE_BACKEND=supabase
export TELEGRAM_MODE=direct
# Deploy to Railway, monitor /api/usage for token counts

Full Local Mode (Testing)

export LLM_BACKEND=ollama    # Run: ollama pull mistral
export STATE_BACKEND=file
export TELEGRAM_MODE=local
# Run Mac services: bun src/telegram-bot.ts

Hybrid Mode (Development)

export LLM_BACKEND=gemini     # Use cloud LLM (free Gemini Flash-Lite)
export STATE_BACKEND=file     # Store locally for iteration
export TELEGRAM_MODE=local    # Debug Telegram messages
# Perfect for testing new features before cloud deploy

Rollback

If something breaks in cloud, roll back in under 1 minute:

# Switch back to local-only (everything still works)
export LLM_BACKEND=ollama
export STATE_BACKEND=file
export TELEGRAM_MODE=local
 
# Restart Mac services
golems latest
 
# Check status
golems status

No data loss, no disruption. The state in Supabase is still there for when you re-enable cloud.

API Cost Tracking

All LLM calls are logged to a JSONL file:

# Location (Mac):
cat ~/.brainlayer/api_costs.jsonl
 
# Location (Cloud):
curl https://your-service.up.railway.app/usage

Format:

{"timestamp": "2026-02-06T10:30:45Z", "model": "claude-haiku-4-5-20251001", "source": "email-poller", "input_tokens": 1240, "output_tokens": 340, "cost_usd": 0.002352}

Model Pricing:

  • Gemini Flash-Lite: Free tier (current cloud default)
  • GLM-4.7-Flash: Free (local via Ollama)
  • Haiku 4.5: $0.80 / $4.00 per 1M tokens (paid fallback)

Database Schema

Supabase Tables (Cloud Backend)

TablePurpose
emailsRouted emails, drafts, follow-ups
email_sendersSender profiles with category and action
subscriptionsEmail subscription tracking
paymentsPayment/transaction tracking
golem_stateState storage for golems
golem_eventsAudit log of all system events
golem_jobsJob listings from scraper
scrape_activityScraping run logs
outreach_contactsRecruiter targets, score, last contacted
outreach_messagesGenerated outreach messages
linkedin_connectionsLinkedIn network data
practice_sessionsInterview practice recordings
practice_questionsInterview practice questions
backlog_itemsKanban board items
pipeline_runsContent pipeline execution logs
llm_usageToken usage and cost tracking
service_heartbeatsService health pings
service_runsCron job execution logs

Local File Storage (~/.brainlayer/)

FilePurpose
state.jsonCurrent Night Shift target, system state
event-log.jsonLocal copy of recent events
api_costs.jsonlCost tracking (append-only)
job-golem/seen-jobs.jsonJob scraper seen jobs tracking
style/semantic-style-data.jsonYour writing style profile

Note: embeddings.db belongs to the BrainLayer package, not autonomous.

Deployment Architecture

Loading diagram...

Security

  • 1Password for secrets — never hardcode API keys
  • Supabase RLS — row-level security on all tables
  • Separate API keys per project — different keys for Golems vs SongScript
  • State sync over HTTPS — encrypted Mac ↔ Railway communication
  • Event audit log — all actions logged to golem_events table

Next Steps

  1. Read Railway Deployment to set up Supabase and Railway
  2. Check Golems to understand each domain expert
  3. Review Environment Variables for env var reference