Overview OpenClaw Folder Structure Tech Stack System Layers Data Flow Scale Phases Key Decisions
System Architecture
How TextOS Is Built

TextOS is OpenClaw productized for civilians. The infrastructure handles all the complexity — users just text. This document maps every layer, every file path, how OpenClaw works under the hood, and what changes at 1K, 10K, and 100K users.

01 User Interface SMS · Email · Telegram · Web The user never sees infrastructure. They type a message. That message arrives via Twilio (SMS), Telegram Bot API, or email. Email-first for launch — no app required.
02 Gateway / Router OpenClaw Gateway (Node.js) Receives all inbound messages. Identifies the user. Routes to the correct agent session. Returns the response to the correct channel. The single source of truth for all sessions.
03 Agent Brain OpenClaw Agent (Claude / Sonnet) Persistent memory. Intent understanding. Tool execution. Skills (SKILL.md). Each user gets their own session. The agent remembers context across sessions, manages cron jobs, and executes tools.
04 Content & Media Generation Claude API · Grok (xAI) · fal.ai Site copy, SEO metadata, blog posts, social content — Claude. Images, logos, social assets — fal.ai / Flux. Video (future) — Kling via fal.ai.
05 Site Publishing Astro + Cloudflare Pages Static site generation. Every publish is a file write + deploy trigger. Fast, SEO-ready, zero server cost per site. handle.textos.ai auto-provisioned via Cloudflare API.
06 Data Layer PostgreSQL (Supabase) · Redis Users, sessions, sites, billing, configs, analytics in Postgres. Redis for session cache, job queues, rate limiting. Supabase free tier handles V1. Redis added at 5K+ users.
07 Billing Stripe All tier management, webhooks, subscription lifecycle. Upgrade triggered by user text. Downgrade by text. Cancel by text. No dashboard required — ever.
08 External Integrations Buffer · Google OAuth · Plaid · Twilio Social publishing via Buffer. Gmail/Calendar pull via Google OAuth. Bank sync via Plaid. SMS inbound/outbound via Twilio. Each added incrementally as features unlock.
OpenClaw
The Agent Brain

OpenClaw is the open-source multi-channel gateway that powers TextOS. It runs on your machine (or a server), connects to chat channels (Telegram, SMS, WhatsApp, Discord, iMessage), and routes messages to AI agent sessions with persistent memory, tool use, and scheduling.

// How OpenClaw works — message lifecycle

1. INBOUND   User sends message via Telegram / SMS / email / web
2. GATEWAY   OpenClaw Gateway receives it
             Looks up user session (or creates one)
             Routes to the correct agent
3. AGENT     Agent reads session memory (MEMORY.md, daily files)
             Agent reads SOUL.md, AGENTS.md, TOOLS.md for context
             Understands intent via LLM (Claude Sonnet 4)
             Selects tools to execute (read, write, exec, web_search…)
4. SKILLS    If task matches a SKILL.md, loads and follows it
             Skills provide specialized instructions (textos-onboarding,
             textos-website-builder, textos-publisher, etc.)
5. TOOLS     Agent calls tools: file read/write, exec shell, FTP,
             web search, Stripe API, Buffer API, Google OAuth, etc.
6. MEMORY    Agent updates memory/YYYY-MM-DD.md with significant events
             Long-term MEMORY.md updated periodically
7. RESPONSE  Agent sends reply back through Gateway
             Gateway routes to original channel (Telegram, SMS, email)
8. CRON      Scheduled jobs run via Gateway cron system
             Daily concierge at 6:30am, weekly digest, reminders
TextOS = OpenClaw + Product Layer. The core engine (memory, routing, tool execution, cron) is OpenClaw. TextOS adds the user-facing product: handle provisioning, site publishing, billing, skills for each feature, and the email-first auth layer. OpenClaw handles the complexity so users just text.
File System
Folder Structure — Your Machine

Every path below is real and live on your WSL2 Ubuntu environment. This is the exact structure TextOS runs from today.

~/.openclaw/                             ← OpenClaw runtime root
├── openclaw.json                        ← main config (channels, model, gateway settings)
├── agents/                              ← agent session data
├── canvas/                              ← canvas/artifact storage
├── completions/                         ← completion logs
├── credentials/                         ← API keys, tokens (encrypted)
├── cron/                                ← cron job definitions (DayCycle 5:30am, etc.)
├── delivery-queue/                      ← outbound message queue
├── devices/                             ← paired devices (Android/iOS nodes)
├── identity/                            ← gateway identity / keypair
├── logs/                                ← gateway and agent logs
├── media/
│   └── inbound/                         ← all inbound images/files from Telegram
├── memory/                              ← session memory (separate from workspace)
├── subagents/                           ← isolated sub-agent runs
├── telegram/                            ← Telegram channel state
└── workspace/                           ← YOUR working directory (repo root)

~/.openclaw/workspace/                   ← workspace (git repo: robertkgaudet/inkthorn-dashboard)
├── AGENTS.md                            ← agent startup instructions
├── SOUL.md                              ← agent persona + values
├── MEMORY.md                            ← long-term curated memory
├── TOOLS.md                             ← FTP creds, API keys, tool notes
├── IDENTITY.md                          ← Rob's profile (for personalization)
├── USER.md                              ← who the agent is helping
├── HEARTBEAT.md                         ← periodic check tasks
├── memory/
│   ├── 2026-04-28.md                     ← today's session log
│   ├── 2026-04-27.md                     ← yesterday
│   ├── MEMORY.md (long-term)
│   ├── family-profile.json              ← Camille, kids, preferences (DayCycle private layer)
│   └── heartbeat-state.json             ← last check timestamps
├── skills/                              ← custom TextOS skills
│   ├── textos-onboarding/SKILL.md        ← first message → handle → live site in 5 exchanges
│   ├── textos-identity/SKILL.md          ← handle claims, profile.json, bio/links
│   ├── textos-website-builder/SKILL.md   ← description → full HTML site at handle.textos.ai
│   ├── textos-publisher/SKILL.md         ← push to X, LinkedIn, Facebook, Instagram via Buffer
│   ├── grok-imagine/SKILL.md            ← AI image/video/voiceover generation
│   └── social-poster/SKILL.md           ← Buffer API social posting
├── scripts/
│   ├── build_today_cycle.py             ← generates DayCycle JSON (runs 5:30am via cron)
│   ├── daily_cycle_push.sh             ← runs build + FTPs today-cycle.json to trustlight.ai
│   ├── build_journal_entry.py
│   ├── fetch_community_events.py       ← WWOZ scraper for live music events
│   └── update_activity_log.py
├── inkthorn-dashboard/                  ← GitHub Pages repo (inkthorn.ai)
│   ├── dashboard.html                   ← Rob's personal command center (TrustLight)
│   ├── textos.html                      ← TextOS product vision / public overview
│   ├── textos-investor.html             ← investor data room
│   └── skills/                          ← (system skills, auto-loaded by OpenClaw)
├── stability/
│   └── google/
│       ├── credentials.json             ← Google OAuth desktop client
│       └── token.json                   ← saved auth token (Drive, Gmail, Calendar)
├── etsy/                                ← NolaCultureCo Etsy publisher
│   ├── auth.js                          ← PKCE OAuth flow (port 3003)
│   └── pdfs/                            ← digital products (6 PDFs ready)
├── textos-concierge.html               ← DayCycle UI prototype (live: textos.ai)
├── textos-prd.html                      ← Product PRD (live: textos.ai)
├── textos-architecture.html            ← this page
└── today-cycle.json                     ← today's DayCycle data (rebuilt daily 5:30am CDT)

~/.npm-global/lib/node_modules/openclaw/ ← OpenClaw system installation
├── docs/                                ← full OpenClaw documentation
└── skills/                              ← system skills (healthcheck, tmux, whisper, etc.)

Host OS paths (WSL2):
  WSL distro:  Ubuntu on Windows 11
  Home:        /home/ink_thorn/
  Node:        v22.22.1
  OS:          Linux 6.6.87.2-microsoft-standard-WSL2 (x64)
  Shell:       bash
Technology
Full Tech Stack

Every layer chosen for speed, cost-efficiency, and scale. AI writes Node, Python, and Astro better than anything else right now — so that's the stack.

LayerTechnologyPurpose & Notes
Inbound SMS Twilio Receives texts from any US phone number. One dedicated number per user, provisioned at signup. ~$1/mo per number — bundled into Pro tier.
Email Inbound SendGrid / Mailgun Email-first auth layer. Magic links via email. Inbound replies from users route back to the agent. Every email sent has an auto-login link embedded.
Telegram Telegram Bot API Optional $4.99/mo add-on. Real-time two-way messaging. OpenClaw handles routing. One bot token per user (or shared bot with routing by chat ID).
Agent Brain OpenClaw (open source) Persistent memory, intent understanding, tool execution, skills, scheduling. Each user gets their own session. Self-hosted on Railway (Node.js server). TextOS is OpenClaw productized.
AI Model Claude (Anthropic) claude-sonnet-4-6 as default. Haiku for lightweight tasks (cost control). claude-opus for deep business analysis. Model tier affects per-request cost — managed per feature.
Image Generation Grok (xAI) + fal.ai Logos, hero images, social assets, Dream Board. ~$0.003/image on fal.ai. Grok for creative generation. Included in Pro tier with usage cap.
Site Publishing Astro + Cloudflare Pages Static site generation. Fast, SEO-friendly, zero server cost per site. Every text-based edit is a file write + Cloudflare Pages deploy trigger (< 30 seconds to live).
DNS & Subdomains Cloudflare API Auto-provisions handle.textos.ai on signup. CNAME + SSL handled invisibly. Custom domain upgrade (Pro) — user texts their domain, agent handles DNS config end-to-end.
Database PostgreSQL via Supabase Users, handles, sites, sessions, billing, configs, analytics. Free tier covers 0–5K users. Upgrade to Pro plan ($25/mo) at scale. Row-level security for multi-tenancy.
Session Cache / Queue Redis (Upstash) Session cache, job queues, rate limiting, pub/sub for real-time updates. Upstash serverless Redis — pay per request. Added at 5K+ users when Supabase alone isn't enough.
Billing Stripe All subscription tiers, webhooks, trial logic, upgrade/downgrade. Stripe Checkout for initial payment. Billing portal for self-service. Webhooks update user tier in Supabase instantly.
Backend API Node.js on Railway Thin webhook handler. Twilio inbound → OpenClaw agent → response. Stripe webhooks → Supabase updates. Scales via Railway's auto-deploy. $5–20/mo at launch.
Social Publishing Buffer API Queue and publish to X, LinkedIn, Instagram, Facebook, TikTok. User connects once. Agent publishes on approval. Rate limits managed per platform.
Google Integration Google OAuth (Desktop) Gmail read, Calendar read/write, Drive sync. OAuth credentials: ~/.openclaw/workspace/stability/google/credentials.json. Incremental scope requests — only asked when feature is used.
Bank Sync Plaid Personal finance feature. Read-only bank connection. Transaction log, IRS set-aside calc, budget tracking. $0.30/connected account/month. Added as Personal Website premium add-on.
SEO + GEO Built into every publish Schema.org markup, OpenGraph tags, semantic HTML, llms.txt on every site. AI-search-ready by default. Not an add-on — baked into the site generation skill.
DayCycle Data Python cron + FTP scripts/build_today_cycle.py runs at 5:30am CDT via OpenClaw cron. Generates today-cycle.json and pushes to FTP. Weather, local events (WWOZ), personal priorities all merged.
Why not C# / SQL Server / Azure? Licensing kills margin on a $9.99/month SaaS. Supabase is free until serious scale. AI writes Node, Python, and Astro faster and better right now. Cloudflare Pages is faster and cheaper than any IIS/VM setup. Serverless + edge is where modern web publishing lives. No ops overhead until 50K+ users.
Request Lifecycle
Data Flow — End to End

What happens between "user sends a text" and "site goes live." Every hop mapped.

// V1 — Email auth + site publish flow

USER         →  types "build me a site about my bakery"
EMAIL/SMS    →  message arrives at SendGrid/Twilio webhook
BACKEND      →  Node.js on Railway receives POST
                 looks up user by email/phone in Supabase
                 if new: provisions handle, creates Supabase row
OPENCLAW     →  Gateway routes to user's agent session
AGENT        →  loads MEMORY.md + today's memory file
                 loads textos-website-builder/SKILL.md
                 calls web_search to research the bakery
CLAUDE       →  generates site HTML (hero, about, menu, contact)
                 generates SEO meta, schema.org, OG tags
FAL.AI       →  generates hero image + logo (3 options)
CLOUDFLARE   →  new DNS CNAME: mybakery.textos.ai → Pages deploy
SITE LIVE    →  mybakery.textos.ai publishes in < 60 seconds
EMAIL BACK   →  "Your site is live at mybakery.textos.ai
                  Here's what I built: [summary]
                  Reply to change anything."
STRIPE       →  if on free plan: paywall prompt for next action
                 if Pro: execute immediately, no prompt

// Update flow (returning user)

USER         →  "change my headline to 'Best Baguettes in NOLA'"
OPENCLAW     →  fetches current site HTML
CLAUDE       →  makes targeted edit (not full regeneration)
CLOUDFLARE   →  incremental deploy → live in < 15 seconds
EMAIL BACK   →  "Done. mybakery.textos.ai updated."
Growth Infrastructure
Scale Phases: 1K → 10K → 100K

The stack changes as users grow. Phase 1 is designed to get to 1,000 paying users with almost no infrastructure cost. Each phase introduces new systems when the previous ones start to strain.

01
Launch — 0 to 1,000 users
~$300–800/mo infra cost
  • Railway Node.js API — $5–20/mo
  • Supabase free tier — $0
  • Cloudflare Pages — free
  • Twilio — ~$1/number/mo
  • Anthropic — pay per token
  • fal.ai — pay per image (~$0.003)
  • Stripe — 2.9% + 30¢ per transaction
  • Single OpenClaw instance (your WSL2 machine for dev, Railway for prod)
  • No Redis needed — Supabase handles all state
  • Email-first auth (magic links via SendGrid)
  • Manual monitoring — you watch the logs
  • Risk: Claude API costs at scale — watch per-user token spend
  • Risk: Single Railway instance — no HA yet
02
Scale — 1K to 10K users
~$2,000–6,000/mo infra cost
  • Redis (Upstash) — session cache + job queue
  • Supabase Pro ($25/mo) — row limits hit
  • Railway auto-scaling — multiple workers
  • Background job workers (site publish queue)
  • Dedicated Twilio account per region
  • OpenClaw cluster — multiple gateway instances
  • Stripe billing webhooks → Supabase real-time
  • Per-user token budgets enforced in middleware
  • Monitoring: Datadog or Grafana Cloud
  • Error tracking: Sentry
  • Redis required — session state can't stay in Postgres
  • Agent response time SLA needed (< 10 sec target)
  • Model cost is #1 concern — Haiku for cheap ops, Sonnet for rich tasks
03
Enterprise — 10K to 100K users
~$15,000–50,000/mo infra cost
  • Postgres read replicas (Supabase Pro + pgbouncer)
  • CDN for all published sites (Cloudflare R2)
  • Dedicated Claude volume contract (Anthropic)
  • Multi-region Railway deploy (US East + West)
  • Message queue (BullMQ or SQS) for publish jobs
  • Vector DB (Pinecone or pgvector) for semantic memory
  • Dedicated Twilio short codes (high-volume SMS)
  • Agent memory sharding — users bucketed by region
  • Content delivery edge nodes for sub-100ms site loads
  • Full observability stack (traces, metrics, logs)
  • Compliance: SOC 2 Type I audit begins
  • OpenClaw architecture needs sharding — single gateway won't hold
  • Plaid + bank sync compliance (PCI DSS scope)
  • Model costs dominate budget — aggressive caching + summarization required
  • Team required: 2 backend, 1 infra, 1 AI/ML, 1 product
Path to 1,000 signups: Rob's personal post to 500K followers + 7 days of content + $300 in targeted ads. One personal post from Rob historically drives thousands of signups.

Path to 10,000: Creator/influencer amplification on the "no passwords" angle. TextOS as the anti-app-fatigue platform. Viral mechanic: every site published at handle.textos.ai is a walking ad.

Path to 100,000: International expansion (TextOS in Spanish, French, Portuguese — same product, translated skills). B2B tier for agencies managing multiple client sites. Telegram's global reach (~900M users) becomes the distribution channel.
Architecture Decisions
Key Decisions & Why
// Decisions locked as of April 2026

EMAIL FIRST      not Telegram-first
  Telegram requires app download. Email reaches 100% of internet users.
  Telegram becomes a $4.99/mo add-on, not a requirement.
  Every outbound email contains a magic login link — inbox is the session manager.

GOOGLE SIGN-IN   as primary auth path
  One click. No form. Returns email + name + photo automatically.
  Unlocks Gmail/Calendar pull via incremental OAuth scopes.
  Highest conversion rate of any auth method on the web.

STATIC SITES     Astro + Cloudflare Pages (not WordPress, not Webflow)
  Zero hosting cost per site. Sub-second load times globally.
  Every publish is a file write + deploy — no CMS, no database per site.
  Scales to 10M sites with no infrastructure change.

PAYWALL MODEL    blur paywall (not hard gate)
  User sees the value before paying. Blur creates desire.
  Current card visible for free — enough to hook the habit.
  Conversion happens at the moment of maximum desire (right now, on the page).

OPENCLAW         self-hosted agent brain (not OpenAI Assistants, not LangChain)
  Full control over memory, routing, tool execution.
  Open source — no vendor lock-in on the agent layer.
  Rob runs it today. TextOS productizes it for everyone.

SUPABASE         over PlanetScale or Neon
  Free tier generous enough for 0–5K users.
  Built-in auth, real-time subscriptions, row-level security.
  Postgres — standard, portable, no proprietary lock-in.

BUSINESS BUILDER FIRST  acquisition hook, not DayCycle
  Diffusion of innovation: early adopters want financial upside, not comfort.
  "AI finds your business idea, builds your site, runs your work" converts.
  DayCycle is the retention layer — builds the morning habit after signup.
  Build order: Auth → Business Builder → Personal Website → DayCycle → Notes
  Marketing lead: Business Builder. Retention engine: DayCycle.

MODULAR PRICING  feature add-ons, not one big bundle
  Users pay for what they use. Lower entry point ($9.99 vs $49).
  Each feature can be independently priced, trialed, and cancelled.
  Reduces refund risk. Increases ARPU over time as users add features.

NO FREE TIER     for DayCycle (blur paywall instead)
  Free forever on Notes, Journal, Blog, Activity — these drive habit.
  DayCycle, Telegram, Timeline — small recurring charges on sticky features.
  Business Builder — high-value one-shot charge with 3-day trial.