Fable Technology and Infrastructure
Part of Fable. This is a proposed architecture for a small initial team, not an implemented or final stack decision. Data and generation details: Fable Data and AI Design.
Proposed stack
| Layer | Proposal |
|---|---|
| Website and server API | Next.js with TypeScript for the web UI, Go for the API and worker |
| UI | React, semantic HTML, and a small CSS component system |
| Database and accounts | PostgreSQL and authentication (provider open) |
| Text generation | A server-side model adapter, initially evaluating Deepseek API or free gemma models from google |
| Story level evaluation | TypeSafe AI Jev via a separate server-side adapter |
| Hosting | Self hosted in home server based on docker containers |
| Background work | Durable job records in queue plus a small worker service |
| Delivery | Git repository, automated CI, production deployment based on docker containers |
Runtime behavior
- Use idempotency keys for generation requests so reloads do not create duplicate billable jobs.
- Workers claim jobs atomically with leases, bounded retries, and a terminal failure state; reclaim expired leases after crashes.
- Generate a story and quiz as a versioned package.
- Store shared story packages and grammar wiki entries in PostgreSQL. Coalesce concurrent misses by lookup key. Each learner keeps a private reference and progress state.
- Require a server-verified admin role on every dashboard API. Keep credentials out of dashboard responses and routine logs. Record admin edits, approvals, and withdrawals with actor and time.
- Keep generation and Jev credentials server-side. Track jobs, retries, cache hits and misses, and Jev outcomes by operation.
- Apply per-account quotas and a global spend ceiling. Restrict custom prompt size and story length.
- Record latency, failure rate, token usage where available, and estimated cost by operation. Keep learner content out of routine logs.
Environments and operations
- Use separate local/development and production data and credentials. Preview builds use test data and restricted provider budgets.
- Store schema migrations in source control. Test migration application and rollback or forward-repair procedures before production changes.
- Enable database backups appropriate to the selected plan and verify restoration.
- Set job timeouts, rate limits, and alerts for failed jobs and spend thresholds.
- Provide account/content deletion and documented retention for private learner data, shared packages, and provider-bound content. Send providers only the content needed for the operation.
Verification before launch
- Run generate or reuse → read → ask → quiz on mobile and desktop. Check keyboard navigation, schema validation, duplicate requests, and failed-job recovery.
- With two learner accounts, verify that matching story and grammar requests reuse existing records without provider calls. Verify that different grammar questions and private story requests follow their own paths. Check that concurrent requests create only one reusable result.
- Verify that ordinary users cannot open admin endpoints or read another learner’s records. Confirm an admin can inspect stories and users, resolve a story difficulty review, and correct or withdraw a wiki entry.
- Verify Jev responses for match, mismatch, uncertainty, and provider failure. Confirm that the dashboard shows the story version, requested and estimated levels, and validation outcome.