kindle-clone
PublicOpen-source Kindle / Apple Books clone: book store, e-reader and an AI writing studio. MIT.
Harakumo1 commitUpdated 2 downloads
Open-source Kindle / Apple Books clone: book store, e-reader and an AI writing studio. MIT.
curl -L https://nucleus.harakumo.com/api/repos/17/archive -o kindle-clone.zipAnyone can download a public repo. Secret files are never in the download for people who cannot read them.
A book platform in the spirit of Apple Books, plus an AI writing studio. One Next.js codebase serves the website and the API, and installs on phones, tablets and desktops as a progressive web app (PWA).
set_book, write_chapter, edit_chapter, delete_chapter, read_chapter, generate_cover, edit_cover, generate_chapter_image) write real chapters and artwork into your book while you watch it grow in a live preview. Publish to the store with one click.| Layer | Choice |
|---|---|
| Web + API | Next.js 16 (App Router), React 19, Tailwind v4 |
| Text data | MongoDB via Mongoose (users, books, chapters, libraryentries, conversations, messages, …) |
| Media | Any S3-compatible bucket, presigned direct uploads (/api/upload) |
| AI | Anthropic API, streaming + tool use (BOOK_MODEL, default Haiku 4.5); optional xAI image generation for covers and chapter art |
| Narration | Optional external text-to-speech service (Chanova Audio API, see lib/audiobook.ts) |
| Payments | Stripe Checkout, subscriptions and Connect (optional) |
| Harakumo Mail for team alerts (optional) | |
| Auth | bcrypt + JWT (jose) in an httpOnly cookie |
| App | Installable PWA (app/manifest.ts, public/sw.js) — iPhone, Android, Mac, Windows |
| Covers | Generated SVG-style covers (12 palettes × 4 layouts, deterministic per title/genre) — no image assets needed; custom covers can be uploaded to the bucket |
Requires Node.js 20.9 or later and a MongoDB database.
npm installcp .env.example .env.local # fill in MONGODB_URI, AUTH_SECRET, ANTHROPIC_API_KEY (the rest is optional)npm run generate:catalog # optional: AI-writes the store catalog (real full books, byline "Lectoire Originals")npm run dev
Open http://localhost:3000, create an account, and try the Studio.
For production: npm run build, then npm start (or node .next/standalone/server.js, which is what the Dockerfile runs). Set NEXT_PUBLIC_ORIGIN to your public URL before building.
To make yourself an admin, set role: "admin" on your user in the users collection; admins can then promote others from /admin/users.
Lectoire is a PWA. /install walks through the steps per device,
app/manifest.ts declares it, public/sw.js is a caching-free service worker
(books and progress are live data — a stale shell would be worse than none),
and components/InstallButton.tsx drives the browser's own install prompt.
POST /api/studio/chat streams SSE. Each request:
action event (the feed in the chat) and a book snapshot event (the live preview panel).Events: meta, delta, status, action, book, title, error, done.
/api/mcp is a stateless Streamable-HTTP MCP server with 12 tools (list, create, get, update, publish, unpublish, browse and delete books; read, write, edit and delete chapters). Users manage their library by chatting in Claude Code, Claude Desktop or claude.ai — inference runs on their Claude subscription, not this app's key.
/connections, then
claude mcp add --transport http lectoire <origin>/api/mcp -H "Authorization: Bearer emb_…".<origin>/api/mcp as a custom connector; it signs in through the built-in OAuth flow (/oauth/authorize, discovery under /.well-known/). Connected apps are listed, and can be disconnected, on /connections.Narrations, chapter drawings and creator payouts that a restart interrupts are picked up by a
housekeeping sweep (lib/housekeeping.ts). A production server runs it every 15 minutes on its
own (HOUSEKEEPING_INTERVAL_MINUTES, 0 turns it off). To drive it from an external scheduler
instead, call POST /api/cron/narration with Authorization: Bearer $CRON_SECRET. Every step is
safe to repeat.
Lectoire is open source (MIT) and is published on Nucleus,
Harakumo's code home. Its team alerts already go through Harakumo Mail (lib/harakumo.ts, one
HARAKUMO_API_KEY).
Lectoire is a Node server (Next.js standalone output, long-running streamed AI responses, PDF and EPUB rendering), so on Harakumo it runs as a server app (Pro plan and up), not a static site.
Create a project at harakumo.com/dashboard → Projects → New project.
Create an API key (Settings → API keys) and add it to the project's environment as
HARAKUMO_API_KEY if you want email alerts (contact form, paid orders, disputes); set
ADMIN_EMAIL or CONTACT_EMAIL to say where they go.
Add the rest of the environment (Project → Environment), from .env.example:
MONGODB_URI — a MongoDB database (include the database name in the path). MongoDB is
required for now.AUTH_SECRET — a long random string (openssl rand -base64 32).ANTHROPIC_API_KEY — for the Studio.NEXT_PUBLIC_ORIGIN — your app's public URL (used in invite links, the connector URL and
payment return URLs).STORAGE_* values (bucket, keys, endpoint, public URL).
Uploads must go to object storage in production: a server app's disk is not kept between deploys.XAI_API_KEY (cover and chapter art), STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET
(Plus, book sales, print orders, payouts), CHANOVA_AUDIO_URL + CHANOVA_AUDIO_KEY (narration),
CRON_SECRET, CONTACT_EMAIL.Deploy from a folder with the CLI, or ask your AI assistant with the Harakumo connector:
npm i -g @harakumo/cliharakumo login --key <your API key>harakumo deploy <project id> .
Every deploy is saved as a commit in the project's private Nucleus repo.
Notes:
<origin>/api/stripe/webhook with the events
checkout.session.completed, charge.refunded, charge.dispute.created, account.updated,
customer.subscription.updated and customer.subscription.deleted.npm run generate:catalog uses the Anthropic API to design and write complete books (outline → chapters with continuity), published under Lectoire Originals — no fake human authors. Re-running replaces only catalog books (ownerId: null), never user books. Edit the SPECS list in scripts/generate-catalog.mjs to change genres/premises/count.BOOK_MODEL=claude-sonnet-5 in .env.local upgrades prose quality at higher cost.lib/models.ts.MIT © 2026 Charan Raj Kandula. Built by Harakumo.