# PALACE.md - The Palace ## What Palace Is Palace is Junwon's personal operating system — everything he needs to live and work, built as one self-hosted system on his Mac. No third-party SaaS for core functions. Mail, code, files, notes, chat, monitoring, market reports, task management — all under one roof at palacering.com, accessible only over Tailscale. ## The Ring The ring (`palacering/`) is the shell that holds everything together. It's the web app Junwon opens every day — a single Astro site that serves every tool as a page. Mail at `/mail`, code at `/code`, notebook at `/notebook`, files at `/files`. Each page either lives directly in the ring or embeds a micro-app from `apps/`. The ring owns the shared experience: layout, navigation, theming (three modes: default, night, paper), the Butler (Ace's chat overlay), and view transitions between pages. Individual pages add only what's unique to them. **After building, the ring must be restarted** (`launchctl stop/start com.manglasabang.palacering`). The node process serves from `dist/` — a build alone doesn't make changes live. ## Apps Apps in `apps/` are specialized tools that plug into the ring. They're separate codebases but appear as pages within palacering.com. **palacecode** is the most mature — a full IDE dashboard for managing Claude Code sessions, threads, and AI interactions. It has its own component architecture (Dashboard, ThreadCard, DetailPanel, ChatReply) and is the reference implementation for UI patterns. When solving a UI problem, check how palacecode does it first. **palacemail** as a standalone app is a placeholder. The real mail client lives in `palacering/src/pages/mail.astro` — a vanilla JS page (no framework) with IMAP/SMTP via ImapFlow and nodemailer, supporting 6 email accounts across 3 domains. Other apps (notebook, files, monitor) are simpler and still growing. ## The Platform `palaceplatform/` is the invisible backbone — services that run continuously without a UI. **Channels** connect Palace to the outside world: email processing, Slack bot, Linear issue sync, voice transcription. Each channel is a long-running daemon managed by launchd. **Heartbeats** are scheduled jobs that keep Palace alive and informed: morning briefings, market reports, trademark monitoring, trend radar, system self-healing. They run on cron-like schedules and email results to Junwon. **Infrastructure** is Caddy (reverse proxy with auto-TLS) and Redis (caching and queues). The **SDK** (`@palace/sdk`) provides shared capabilities like speech recognition that multiple apps use. ## The Palace (Data) `palaces/manglasabang/` is a git submodule containing everything personal — the data that makes this Junwon's palace and not a generic tool. The **secretariat** is the heart: credentials in `keychain/`, persistent memory in `memory/`, tasks synced from Linear, device records, reports. The memory system has temporal layers — daily notes compact into weekly, weekly into monthly, monthly into yearly — so context survives indefinitely without growing unbounded. Business records (`junwoncompany/`), personal records (`junwonhome/`), and fund data (`palacefund/`) live alongside. ## Design Philosophy - **Self-hosted, not SaaS.** Own the data, own the system. - **One ring, many tools.** Everything accessible from one URL, one nav, one identity. - **Consistency across apps.** When one app solves a problem well, the others should follow the same pattern — not reinvent. - **No lazy shortcuts.** If something shouldn't exist in the DOM, don't render it. If something needs fixing, fix it properly. Check existing code before writing new code.