Case study ·
lokalhost.io — Product Case Study
A developer ecosystem I designed and built solo: a CLI-installable component registry, a React Native + Flutter mobile kit, templates, and a Pro tier billed through Razorpay.

lokalhost.io is a developer ecosystem I designed and built solo: a shadcn-compatible component registry installable from the CLI, a React Native + Flutter mobile kit, web templates and design kits, and a paid Pro tier billed through Razorpay.
- Role
- Solo founder, designer and full-stack engineer
- Timeline
- Jun 2026 – Nov 2026 (first commit 29 Jun 2026; billing shipped 13 Nov 2026)
- Web stack
- Next.js 15 (App Router), React 19, TypeScript, Tailwind CSS v4, Framer Motion, Radix UI
- Docs
- Fumadocs (MDX), Shiki syntax highlighting
- Backend
- Supabase (Postgres, Auth, Row-Level Security), MongoDB / Mongoose for catalog content
- Payments
- Razorpay (orders, subscriptions, webhooks) behind a provider-agnostic billing layer
- Distribution
- shadcn registry JSON at
/r/*.json, installed withnpx shadcn add - Mobile
- 26 React Native (Expo) items and 26 Flutter items
Problem and goals
Developers building AI-era products rebuild the same UI pieces for every project, and most libraries stop at copy-paste snippets for one platform.
- Component libraries are usually web-only; mobile teams in React Native or Flutter start from zero.
- Copy-paste code drifts: dependencies, the
cnhelper and imports are easy to miss. - Templates and design kits live in separate products with separate logins and payments.
Goals I set for the product
- 1One command installs any component, with its dependencies, into the user's own project.
- 2Every component has a live preview, source view, props table and manual install path.
- 3The same catalog covers web (React / Next.js) and mobile (React Native, Flutter).
- 4A Pro tier that charges Indian customers in INR, monthly or yearly, without ever granting access twice or losing a paid user.
- 5Previews stay public so visitors can try before they buy; only account pages require sign-in.
Product walkthrough
The product has seven surfaces.
1. Landing page
Bento grids for components, templates and designs, a social dock, an iPhone device preview and CTA sections, including a CLI section that shows the install flow right on the home page.

2. Component docs
Fumadocs-powered pages with a custom shell, sidebar and table of contents. Each component page has a live preview, a code tab with Shiki highlighting, a CLI tab with npm / pnpm / yarn / bun switching, a manual install tab and a props table.



3. Component catalog
Current web components: Download Button, Code Block, Code Preview Block, Install Command, Copy Page Markdown, Model Picker, Models Selector and Composer Actions (micro AI components).

4. Mobile kit
A separate docs shell for React Native and Flutter: components (button, card, bottom sheet, tabs, toast, skeleton), blocks (stats grid, story rail, pricing plans) and full screens (onboarding, sign-in, chat, feed, cart, product, profile, settings). Each item renders inside a phone frame with a framework toggle.




5. Templates and designs
Filtered galleries with sorting, detail pages per template and premium badges.


6. Auth
Email + password, OAuth and email confirmation through Supabase. After login the user returns to where they started, including an open checkout.


7. Pricing, checkout and billing
Monthly (₹999 / month, auto-renews) or yearly (₹7,999 one-time, “Save 33%”). Razorpay Checkout opens in a modal; the billing page shows status, renewal date and cancel.

Architecture
One Next.js 15 app serves the marketing site, the docs, the static registry JSON and the billing API. Supabase holds users and money; MongoDB holds catalog content.
Tech stack
| Layer | Choice | Why |
|---|---|---|
| Framework | Next.js 15 App Router, React 19 | Server components, route groups, API routes and middleware in one deploy |
| Styling | Tailwind CSS v4, Radix UI, Framer Motion | Same primitives the shadcn ecosystem expects, so installed components just work |
| Docs | Fumadocs MDX, Shiki | Typed MDX collections (docs, mobile, authdocs, backgrounds) with frontmatter validated by Zod |
| Registry | Custom build script (tsx) emitting shadcn registry-item JSON | No extra infra: JSON is served from /r with a one-year immutable cache header |
| Auth | Supabase Auth via @supabase/ssr | Cookie sessions that work in middleware, server actions and route handlers |
| Billing data | Supabase Postgres with RLS and security-definer functions | Atomic, idempotent grants inside the database |
| Payments | Razorpay (Stripe kept behind the same interface) | INR, UPI and Indian cards; monthly subscriptions and one-time orders |
| Content | MongoDB + Mongoose | Templates, designs, enquiries, feedback |
| Resend, Nodemailer | Contact and transactional mail | |
| Data fetching | TanStack Query with persisted cache | Fast template galleries |
| Hosting | Vercel (+ Analytics, Blob, next-video) | Zero-config deploys from GitHub |
Folder structure
lokalhost_io/
├── app/
│ ├── (auth)/ login, sign-up
│ ├── (main)/ site, docs, templates, designs, pricing, checkout, account
│ │ ├── api/billing/ checkout, verify, status, cancel
│ │ ├── api/webhooks/razorpay/
│ │ ├── docs/[[...slug]]/ Fumadocs pages
│ │ └── preview/[[...slug]]/ isolated component previews
│ └── (mobile)/mobile/ React Native + Flutter docs shell
├── components/
│ ├── lokalhost_io/ the components shipped through the registry
│ ├── mdx/ preview, code view, install tabs, props table
│ ├── docs/ mobile/ docs shells, sidebars, phone frame
│ ├── billing/ checkout dialog, billing UI
│ └── landing/ ui/ magicui/ ...
├── content/
│ ├── docs/ component MDX pages
│ └── mobile/ installation, CLI, theming, changelog
├── registry/
│ ├── schema.ts Zod schema for registry entries
│ ├── registry-components.ts, registry-lib.ts, index.ts
│ └── mobile/react-native/ mobile/flutter/ 26 + 26 items
├── public/r/ generated registry JSON (download-button.json, ...)
├── scripts/
│ ├── build-registry.ts npm run build:registry
│ └── razorpay-setup.ts npm run billing:check
├── lib/
│ ├── billing/ provider interface, razorpay, entitlements, logging
│ ├── supabase/ browser, server, admin, middleware clients
│ ├── mobile/ catalog, install commands, nav
│ ├── models/ Mongoose models
│ └── registry.ts safe-redirect.ts plans.ts env.ts
├── supabase/migrations/ billing schema, RLS, grant functions
├── middleware.ts session refresh, route protection, OAuth fallback
└── source.config.ts Fumadocs collectionsDeep dives
A. Component registry and CLI distribution
Instead of publishing my own npm package, I made lokalhost.io a shadcn-compatible registry: users run the shadcn CLI they already have, pointed at my JSON.
- 1Each component is declared once in
registry/registry-components.ts(name, type, dependencies, registryDependencies, file paths), validated by a Zod schema inregistry/schema.ts. - 2
npm run build:registryrunsscripts/build-registry.ts, which reads every source file, inlines its content and writespublic/r/<name>.jsonwith the official$schema. - 3Next.js serves
/r/*withCache-Control: public, max-age=31536000, immutable. - 4The docs build the install command per package manager from
lib/registry.ts, so every page shows the right command for npm, pnpm, yarn or bun.
npx shadcn@latest add https://lokalhost.io/r/download-button.jsonFor mobile, React Native items use a namespaced registry (@lokalhost/<slug>, set once in components.json), and Flutter items install through npx lokalhost@latest add <slug> --flutter, which writes into lib/widgets and runs flutter pub add.

npx shadcn@latest add @lokalhost/onboardingB. Payments and subscriptions with Razorpay
- Plans.
pro_monthly(₹999, recurring Razorpay subscription) andpro_yearly(₹7,999 one-time order, 365 days). Prices are read from theplanstable on the server; the client copy inlib/plans.tsis display-only. - Checkout.
POST /api/billing/checkoutcreates an order or subscription and returns the public key and ids to open Razorpay Checkout. - Verify.
POST /api/billing/verifychecks the HMAC-SHA256 signature with a timing-safe comparison, fetches the payment from Razorpay and grants access. - Webhook.
/api/webhooks/razorpayverifies the signature on the raw body, records the event inwebhook_eventsand processes it once. A failure returns 500 so Razorpay retries. - Entitlements. Three Postgres functions (
grant_for_order,grant_for_subscription_charge,revoke_for_payment) are the only code that grants or removes access. They run as security definer and only the service role may call them. - Stacking. Buying a year while on monthly adds the year after the current access ends and schedules the monthly plan to cancel at cycle end.
- Self-service.
/account/billingshows status and lets the user cancel; they keep access until the paid period ends. - Provider-agnostic.
lib/billing/provider.tsdefines aBillingProviderinterface, so Stripe can be added without touching routes or SQL.
C. Authentication and safe redirects
Supabase Auth handles email / password and OAuth; middleware.ts refreshes the session on every request and protects only /account. A buyer who clicks “Buy” while logged out goes to /login?next=/pricing&plan=pro_yearly and comes back with checkout opening automatically. lib/safe-redirect.ts rejects absolute URLs, //evil.com, backslashes and control characters, which closes open-redirect holes.
D. Docs and preview system
Reusable MDX components (Preview, CodeView, InstallationTabs, ManualInstallation, PropsTable) render every component page from the same parts. /preview/[[...slug]] renders a component alone for iframe previews, and /mobile generates its pages from lib/mobile/catalog.ts instead of one MDX file per item.
Challenges and how I solved them
The two hardest problems were shipping a registry that the shadcn CLI accepts on every machine, and taking real money without ever granting access twice or losing a paying user.
1. Building a component registry with CLI install
Problem. I wanted npx shadcn add <url> to install my components, but the CLI is strict about the JSON it accepts and failed in ways that were hard to trace (2–5 Jul 2026).
- Unsafe file path errors. File paths with a leading
/made the CLI abort with “unsafe file path”, because it treats them as absolute. Fix: atoRelative()step in the build script so every path and target is relative. - Builds that lied. Early versions caught write errors and still printed “done”, so a broken registry reached production. Fix: no silent catches; any missing source file or duplicate name throws, and the script exits with code 1 so the Vercel build fails.
- Wrong URLs in install commands.
NEXT_PUBLIC_BASE_URLwas set with a protocol in one environment and without in another. Fix:lib/registry.tsnormalises the base URL once and every command is built from it. - Source files missing in production. The code view reads component source at runtime, but Vercel's file tracing dropped those files. Fix:
outputFileTracingIncludesforcomponents/lokalhost_io/**. - Flutter is not a shadcn target. The shadcn CLI only installs JS/TS. Fix: React Native uses a namespaced shadcn registry, and Flutter gets its own
lokalhostCLI command plus a Manual tab as a fallback. - Keeping docs and registry in sync. Fix: one registry entry drives the JSON, the CLI command, the manual dependency list and the docs page.
2. Payment integration with Razorpay
Problem. Payments arrive through two paths at once (the browser's verify call and Razorpay's webhook). Events can arrive late, twice or out of order, and any mistake either gives free access or takes money without giving access. It took four iterations (pull requests 12–15, 13 Nov 2026).
- Race between verify and webhook. Both could grant the same payment. Fix: all grants go through Postgres functions that take a per-user advisory lock and use
ON CONFLICT (provider_payment_id) DO NOTHING, so repeat calls are harmless. - Duplicate and out-of-order webhooks. Fix: a
webhook_eventstable keyed by Razorpay's event id (or a SHA-256 of the body) withprocessed_atandattempts; a finished subscription is never revived by a late event, and “authenticated” never downgrades an “active” subscription. - Signature checks failing. Parsing JSON before verifying changes the bytes. Fix: read the raw body first, verify HMAC-SHA256 with
timingSafeEqual, then parse. - Price tampering. Fix: the amount is always read from the
planstable on the server, and the SQL rejects any payment whose amount or currency does not match. - Payments refunded automatically. If auto-capture is off, Razorpay refunds authorized payments. Fix: a capture fallback that captures through the API when the amount matches.
- Double clicks creating two orders. Fix: an unpaid order or subscription created in the last 30 minutes is reused.
- Subscription activation lag. Right after payment the subscription is often not “active” yet. Fix: verify polls up to 3 times, 1.2 s apart, and the webhook grants it if that window passes.
- Monthly and yearly overlap. Fix: monthly is blocked while any access is live; yearly stacks after current access and schedules the monthly plan to cancel at cycle end.
- Test vs live mode confusion. Fix:
npm run billing:checkreports which mode the keys are in and can create the ₹999 plan in that mode. - Payment-gateway approval. Fix: added Terms, Privacy, Refund and Shipping policy pages.
3. Auth redirects that silently broke
Problem. After OAuth, users sometimes landed on the home page instead of the checkout they started. Supabase matches redirect URLs exactly, so adding ?next= made the allowed callback URL stop matching and Supabase fell back to the Site URL.
Fix. The return path travels in an httpOnly cookie (lk_next, 30 minutes) instead of the URL, middleware forwards any stray /?code= to /auth/callback, and the callback origin comes from the request so localhost and production both work.
4. Two mobile frameworks, one catalog
Problem. Keeping 26 React Native items and 26 Flutter items consistent, with docs, previews and install steps, is double the work.
Fix. A single typed catalog (lib/mobile/catalog.ts) generates every component, block and screen page; one phone-frame preview and a framework toggle render both. Old /mobile/* URLs keep working through redirects in next.config.ts.
5. Scope and momentum as a solo builder
Problem. The product spans components, templates, designs, mobile, auth and billing, built alone, with a four-month gap between July and November 2026.
Fix. I shipped in vertical slices behind feature branches and pull requests (registry first, then docs, then mobile, then billing), and wrote explanatory comments in the code so I could pick the work back up quickly.
Results, learnings and next steps
In about five months I took lokalhost.io from first commit to a live product with CLI-installable components, a two-framework mobile kit and working INR billing.
What shipped
- 6 registry items published at
/r(5 components + the utils helper), each installable with one command in npm, pnpm, yarn or bun. - 52 mobile items (26 React Native, 26 Flutter) with phone-frame previews.
- Full billing: monthly subscription, yearly one-time plan, verify route, webhook, cancel flow, billing page, and an 11-table Supabase schema with RLS.
- Auth with email, OAuth and safe post-login redirects back into checkout.
What I learned
- 1Build on standards people already use. Shipping a shadcn registry meant zero new tooling for users.
- 2Make builds fail loudly. A script that prints “done” after an error costs more than one that crashes.
- 3Treat payments as a distributed system. Webhooks repeat and reorder; idempotency keys and database-level locks are the real safety net.
- 4Never trust the client with money. Price, plan and access are decided on the server and in SQL.
- 5Read the provider's exact rules. The Supabase redirect bug came from one query string.
Next steps
- Publish the mobile registry endpoints and the lokalhost Flutter CLI.
- Clean up registry names (one duplicated entry is rejected by the build guard).
- Add Stripe behind the existing
BillingProviderinterface for international buyers. - Gate Pro components and templates with
has_active_accessand API tokens. - Billing emails (renewal, failed payment) through Resend.
- Automated tests for the billing functions and the registry build.