Agent Reference File
Project: fogserv.cloud
Last Updated: April 22, 2026
Purpose: Comprehensive reference for AI agents operating on this codebase
π― Mission Context
You are working on fogserv.cloud, an implementation of "The AI-Managed Server" that treats infrastructure as a living entity that learns and evolves. This project embodies the TELOS philosophy: "Helping People Help Themselves" through democratic technology, knowledge as freedom, and agentic autonomy.
Read First: /kb/TELOS.md - The North Star guiding all decisions
π Project Structure & Key Files
Root Directory
/
βββ src/
β βββ main.tsx # All page components + full route tree
β βββ index.css # Global Tailwind imports
β βββ vite-env.d.ts # Typed ImportMetaEnv (email provider vars)
β βββ services/
β β βββ emailService.ts # Typed email abstraction (console/api modes)
β βββ routes/ # Scaffold only β main.tsx is canonical
βββ scripts/
β βββ import-ghost.ts # Ghost JSON export β Prisma import script
βββ kb/ # Knowledge Base (CRITICAL β update after every session)
β βββ TELOS.md # Mission & philosophy β READ THIS FIRST
β βββ README.md # KB navigation
β βββ agent.md # This file
β βββ tasks.md # Project task tracking
β βββ lessons-learned.md # Session insights
β βββ problems-solved.md # Technical issues & solutions
β βββ implementations.md # Architecture decisions
β βββ wireframes.md # MVP UX and wireframe specs
β βββ workflows.md # Unified workflow runbook
β βββ frontend/
β β βββ website-rebuild.md
β βββ sysadmin/
β β βββ dotenvx.md
β βββ agentic/
β β βββ agentic-workflows.md
β βββ migrations/
β βββ ghost-content-migration-map.md
β βββ ghost-redirect-manifest.json # Auto-generated by import script
βββ prisma/
β βββ schema.prisma # Full CRM/CMS schema
β βββ migrations/ # Prisma migration history
βββ .forgejo/workflows/ci.yml # Forgejo Actions CI pipeline
βββ .env # Local secrets (NEVER COMMIT)
βββ .env.example # Template (safe to commit)
βββ package.json # Dependencies & scripts
βββ vite.config.ts # Vite config + ALL backend API middleware
βββ tsconfig.json # TypeScript configuration
βββ index.html # HTML shell
βββ SECRETS_MANAGEMENT.md # Root-level secrets guide
π§ Technology Stack
Core Technologies
- Runtime: Bun (Node.js replacement)
- Framework: React 19 + Vite
- Router: TanStack Router (browser history)
- Styling: Tailwind CSS v4 + PostCSS
- Database: PostgreSQL + Prisma ORM + Prisma Accelerate
- Secrets: dotenvx for environment management
- Language: TypeScript with strict mode
Package Manager Commands
bun install # Install dependencies
bun run dev # Start dev server (with dotenvx)
bun run build # Build for production
bun run preview # Preview production build
bun run db:push # Sync database schema
bun run db:generate # Generate Prisma client
bun run db:migrate # Create migration
bun run db:studio # Open Prisma Studio
bun run type-check # TypeScript validation
bun run lint # ESLint
bun run secrets:get KEY # Get secret value
bun run import:ghost <ghost-export.json> [--dry-run] # Import Ghost content
ποΈ Database & Environment
Environment Variables
Located in: .env (local), .env.production (encrypted or CI/CD)
Current Variables (see .env.example for full list):
DATABASE_URL="file:./dev.db" # SQLite for local dev
PRISMA_ORM=prisma+postgres://... # Prisma Accelerate (production)
PRISMA_ANY=postgres://... # Direct PostgreSQL
MAILGUN_API_KEY=... # Mailgun API key
MAILGUN_DOMAIN=mg.fogserv.cloud # Sending domain
MAILGUN_FROM_EMAIL=noreply@fogserv.cloud
MAILGUN_WEBHOOK_SIGNING_KEY=... # Webhook HMAC verification
APP_BASE_URL=http://localhost:5173 # For verification email links
VITE_EMAIL_PROVIDER=api # 'api' (real) or 'console' (dev)
VITE_EMAIL_API_BASE_URL=/api
Planned:
JWT_SECRET=... # For user auth tokens
Database Schema
Current Models (all in prisma/schema.prisma):
User+Sessionβ authentication, roles (OWNER/ADMIN/EDITOR/AUTHOR/CONTRIBUTOR/SUBSCRIBER)Postβ Ghost-like CMS with slug, status, SEO fields, type (POST/PAGE/SNIPPET/GUIDE)Tag,Categoryβ taxonomy with PostTag/PostCategory join tablesCommentβ threaded comments with guest support and moderationSubscriberβ newsletter subscribers with double opt-in, engagement metricsSubscriberList,SubscriberTagβ segmentationEmailCampaign+CampaignRecipientβ bulk send with per-recipient trackingAnalyticsβ page view and action tracking
Operations:
# After schema changes
bun run db:generate # Regenerate client
bun run db:push # Sync to database
# OR for production
bun run db:migrate # Create migration file
π¨ Frontend Architecture
Current Pages
- Home (
/) β Hero, core pillars, mission - About (
/about) β TELOS mission, goals, how it works - Changelog (
/changelog) β Update list - Knowledge Base (
/kb) β KB document browser withreact-markdown+remark-gfm+rehype-slug - Admin (
/admin) β Dashboard with KPI cards, content queue, quick actions, Email Sandbox
Backend API routes (Vite middleware in vite.config.ts):
POST /api/email/sendβ Mailgun sendPOST /api/email/verification/requestβ Upsert Subscriber + send verification emailPOST /api/email/verification/confirmβ Confirm token β set ACTIVEPOST /api/email/webhooks/mailgunβ Ingest Mailgun events, update subscriber state
Component Structure
In src/main.tsx:
Navigation()- Header with routing linksFooter()- Footer with resourcesRootLayout()- Wrapper with nav + outlet + footerHomePage()- Homepage contentAboutPage()- About page contentChangelogPage()- Changelog listingKnowledgeBasePage()- KB browserCard()- Reusable card componentUpdatePreview()- Changelog preview cardKBCard()- KB document card
Styling Patterns
- Container:
max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 - Section padding:
py-20 - Cards:
bg-slate-800/50 border border-purple-500/20 rounded-lg p-6 - Hover:
hover:border-purple-500/50 transition-colors
π Core Pillars (TELOS)
1. GitOps is Law
- Every change flows through Git
- Repository is source of truth
- Forgejo Actions trigger deployments
- No direct server modifications
2. Ticketing is Truth
- No work without an issue
- Commit messages reference tickets:
Fixes #123 - Pull requests link to issues
- Issues become institutional memory
3. Documentation is Memory
- Update
/kb/after every session - Document reasoning, not just what
- Cross-reference related files
- Never delete historyβmark deprecated
4. Proactive Polish
- Fix bugs + refactor surrounding code
- Update docs in same commit
- Leave codebase better than found
- Opportunistic improvements
π€ Agent Operations
Before Starting Work
Read Context
- Read
/kb/TELOS.mdfor mission alignment - Read
/kb/tasks.mdfor current priorities - Check related KB files for domain knowledge
- Read
Check Issues
- Is there a ticket for this work?
- If not, should one be created?
- Reference ticket number in commits
Understand Environment
- Are secrets configured in
.env? - Is database schema current?
- Are dependencies installed?
- Are secrets configured in
During Work
Follow Patterns
- Match existing code style
- Use established component patterns
- Follow naming conventions (see
/kb/implementations.md)
Document Decisions
- Why did you choose this approach?
- What alternatives were considered?
- Update
/kb/implementations.mdfor architecture changes
Test as You Go
- Run dev server to verify changes
- Check browser console for errors
- Test responsive design
After Completing Work
Update Knowledge Base
- Add to
/kb/lessons-learned.mdif you learned something - Add to
/kb/problems-solved.mdif you fixed an issue - Update
/kb/tasks.mdto mark tasks complete - Update relevant KB files with new information
- Add to
Commit Properly
git add [files] git commit -m "feat: Add email signup form Implements newsletter subscription with Mailgun integration. Includes double opt-in flow and welcome email. Fixes #42"Update Documentation
- Update
CHANGELOG.mdwith changes - Update
README.mdif setup changed - Ensure all new features are documented
- Update
π¨ Common Issues & Solutions
React Hydration Errors
Problem: <html> cannot be child of <div>
Solution: Keep HTML structure in index.html, React mounts inside #root
Reference: /kb/problems-solved.md#problem-1
PostCSS Module Error
Problem: module is not defined in ES module scope
Solution: Use export default in postcss.config.js
Reference: /kb/problems-solved.md#problem-2
Tailwind Plugin Error
Problem: Tailwind v4 PostCSS plugin missing
Solution: bun add -d @tailwindcss/postcss and update config
Reference: /kb/problems-solved.md#problem-3
Environment Variables Not Loading
Problem: Variables undefined in application
Solution: Ensure scripts use dotenvx run -- wrapper
Reference: /kb/dotenvx.md
π Key Workflows
Adding a New Page
Add route in
src/main.tsx:const newRoute = createRoute({ getParentRoute: () => rootRoute, path: '/new-page', component: NewPage, })Add to route tree:
const routeTree = rootRoute.addChildren([..., newRoute])Add navigation link in
Navigation()componentDocument in
/kb/implementations.md
Adding Database Model
Edit
prisma/schema.prisma:model NewModel { id Int @id @default(autoincrement()) name String }Generate client:
bun run db:generatePush to database:
bun run db:pushDocument in
/kb/implementations.md
Adding Secret
Add to
.env:NEW_SECRET=value_hereAdd to
.env.example(without value):NEW_SECRET=your_secret_hereUse in code:
const secret = process.env.NEW_SECRETDocument in
/kb/dotenvx.mdandSECRETS_MANAGEMENT.md
π― Current Priorities (from tasks.md)
Phase 1-2 β COMPLETE
Phase 3: CRM/CMS Architecture π IN PROGRESS
- Full Prisma schema (User, Post, Tag, Category, Subscriber, Campaign, Analytics)
- Prisma migration
20260422064615_phase3_cms_crm_foundation - Admin dashboard (
/adminroute) - Rich text editor integration (TipTap)
- Draft/publish workflow
- User registration/authentication
Phase 4: Email & Mailgun π IN PROGRESS
- Email service abstraction layer (
src/services/emailService.ts) - Transactional email templates (verification, welcome, newsletter)
- Email verification flow (request + confirm endpoints)
- Mailgun webhook ingestion with signature verification
- Newsletter signup form + double opt-in UI
- Newsletter composition interface and bulk send
Phase 5: Ghost Migration π IN PROGRESS
- Ghost-to-Prisma field mapping (
kb/migrations/ghost-content-migration-map.md) - Ghost import script (
scripts/import-ghost.ts) - Run actual import from Ghost export
- Migrate images to CDN
- Redirect old URLs
Phase 6: CI/CD
- Forgejo Actions CI baseline
- Staging deployment, rollback, agentic workflows
π External Resources
Documentation
- React: https://react.dev
- TanStack Router: https://tanstack.com/router
- Prisma: https://prisma.io/docs
- Tailwind CSS: https://tailwindcss.com/docs
- dotenvx: https://dotenvx.com
- Bun: https://bun.sh
Git Repository
- Primary: https://git.shire.one/fogserv/website
- Branch: main
- CI/CD: Forgejo Actions (to be configured)
Production Site
- Current (Ghost): https://fogserv.cloud
- New (React): In development
β οΈ Critical Rules
NEVER
- β Commit
.envfile - β Commit secrets in code
- β Delete KB history (mark deprecated instead)
- β Make changes without updating KB
- β Skip commit message body
- β Work without a ticket for significant changes
ALWAYS
- β
Update
/kb/after sessions - β Reference ticket numbers in commits
- β Test changes before committing
- β Follow TELOS principles
- β Document architectural decisions
- β Leave code better than found
π Questions & Clarifications
If you encounter ambiguity:
- Check KB First: Answer is probably in
/kb/ - Check TELOS: Does it align with mission?
- Check implementations.md: Is there a pattern?
- Ask User: If still unclear, ask for clarification
- Document Answer: Add to appropriate KB file
π Session Checklist
At the end of every session, ensure:
- All code changes committed with proper messages
-
/kb/tasks.mdupdated with progress - Relevant KB files updated with learnings
- New decisions documented in
/kb/implementations.md - Problems documented in
/kb/problems-solved.md -
CHANGELOG.mdupdated with changes - Dev server tested and working
- No secrets in committed code
This file is your command center. Refer to it often. Keep it updated.
Last Updated: April 22, 2026
Next Update: After every significant session
Agent dashboard design (Phase 8) β KPI cards, real-time polling, deployment tracking β see kb/artifacts/phase8/agent-dashboard-search-community.md