Libra AI

Open-source AI-powered platform that generates and deploys full-stack web applications from natural language prompts, built natively for Cloudflare Workers.

1.6Kstars
267forks
GNU AGPLv3
TypeScript

Libra AI is an open-source alternative to V0 and Lovable that enables developers to generate production-ready web applications from a single natural language sentence. Built exclusively on the Cloudflare ecosystem — Workers, D1, KV, R2, Durable Objects, and AI Gateway — it covers the complete lifecycle from prototyping to deployment without leaving a single platform.

The platform integrates a cloud IDE with syntax highlighting and real-time HMR preview, multi-model AI code generation (Claude, OpenAI, Gemini, DeepSeek, xAI), built-in OAuth 2.0 authentication via better-auth, Stripe subscription management, GitHub auto-commit, and one-click custom domain deployment. Every layer is TypeScript-first, organized as a Turborepo monorepo with strict Biome linting and a shared design system built on shadcn/ui and Tailwind CSS v4.

Libra is built for indie hackers, startups, and developer teams who want to ship products at AI speed without managing complex infrastructure. Because it runs entirely on Cloudflare’s edge network, generated apps benefit from global low-latency distribution, elastic scaling, automatic TLS/SSL, and pay-per-use serverless economics out of the box.

With full self-hosting support and an AGPL-3.0 license, teams can run their own Libra instance with complete control over code, data, and the AI models powering generation — or use the managed cloud service at libra.dev for an instant, zero-configuration start.

What You Get

  • Multi-Model AI Code Generation - Generates production-grade React 19, TypeScript, and Tailwind CSS code from natural language prompts using a configurable provider layer that supports Claude, OpenAI (via Azure), Gemini, DeepSeek, xAI, and OpenRouter — with plan-gated model access enforced server-side.
  • Cloud IDE with Live Preview - Provides a full in-browser development environment using Shiki-powered syntax highlighting, smart indentation, an interactive file tree, git diff view, and Hot Module Replacement preview powered by sandboxed Vite builds running on E2B or Daytona compute.
  • Edge Deployment on Cloudflare Workers - Deploys generated apps natively to Cloudflare’s global edge network with serverless Workers for Platforms tenant isolation, Durable Objects for state persistence, Cloudflare Queues for async build pipelines, R2 for artifact storage, and automatic TLS/SSL — no infrastructure to manage.
  • Built-in Authentication and Stripe Payments - Ships pre-configured OAuth 2.0 authentication via a custom Cloudflare adapter for better-auth, along with a dedicated better-auth-stripe package that handles subscription tiers, quota enforcement, annual refresh, and webhook processing.
  • GitHub Auto-Commit and Version Control - Syncs generated code to GitHub repositories automatically with one-way push, preserving full Git history and enabling rollback, collaboration, and external CI/CD integration.
  • Custom Domain Binding with SSL - Lets users attach their own domains to deployed apps via Cloudflare for SaaS, with automated SSL certificate provisioning and DNS management handled by the platform.
  • Unified Sandbox Abstraction - Provides a provider-agnostic sandbox layer (ISandbox/ISandboxProvider interfaces) that switches between E2B and Daytona compute backends using a factory pattern, making the code generation execution environment swappable without touching application logic.
  • Internationalization via Paraglide - Embeds i18n directly into compiled output using Paraglide JS, compiling message catalogs at build time so localized strings are statically typed and tree-shaken — no runtime JSON loading.

Common Use Cases

  • Launching a SaaS MVP in a weekend - A solo founder describes their product in plain English; Libra generates a full Next.js app with auth, subscription billing, and a custom domain deployed to Cloudflare Workers — ready to share with early users before writing any code manually.
  • Running a white-label AI builder for your team - A development agency self-hosts Libra on their own Cloudflare account, configures their preferred AI models and subscription tiers, and offers clients an internal tool for generating branded web apps without granting access to their production codebase.
  • Rapid UI prototyping with AI iteration - A product designer prompts Libra to scaffold multiple UI variants, uses the live HMR preview to compare them in real time, selects a direction, and deploys the winner to a staging domain — without involving a frontend developer.
  • Teaching full-stack development - An instructor uses Libra in a bootcamp to demonstrate how a complete application with routing, data access, authentication, and deployment fits together, generating real apps from prompts and walking through the produced TypeScript source code.
  • Migrating from Vercel-locked tooling - A team already using Next.js migrates their AI code generation workflow from V0 to Libra to escape Vercel pricing and gain full ownership of generated output, deploying identical apps to Cloudflare Workers using OpenNext.
  • Building internal tools with enterprise control - A company uses Libra’s self-hosted mode with their Azure OpenAI endpoint routed through Cloudflare AI Gateway, keeping all prompts and generated code within their own infrastructure for compliance.

Under The Hood

Architecture Libra is organized as a Turborepo monorepo with a clear three-layer topology: applications that expose user-facing interfaces and API surfaces, packages that encapsulate shared business logic and infrastructure adapters, and tooling that enforces consistency across the workspace. The main Next.js 15 application delegates AI generation, authentication, quota enforcement, and project management to discrete packages — each with its own schema, types, and test suite — rather than embedding that logic in route handlers. Cloudflare-specific concerns are isolated behind typed adapter interfaces: a custom better-auth-cloudflare package wraps the Workers environment, a sandbox abstraction layer (ISandbox/ISandboxProvider) hides the difference between E2B and Daytona compute, and the deploy app uses Cloudflare Queues so build pipelines never block the request lifecycle. Data flows from prompt to deployed app through a well-defined sequence: tRPC fetches project state, the AI module assembles XML-structured file context, Vercel AI SDK streams generated code back, the builder Vite Worker compiles and hot-reloads it in a sandboxed preview, and the deploy pipeline pushes artifacts to Workers for Platforms tenant slots with R2-backed storage.

Tech Stack The frontend is Next.js 15 with React 19 and the React Compiler, deployed to Cloudflare Workers via OpenNext.js, with Tailwind CSS v4 and a shared shadcn/ui design system under packages/ui. The backend API layer uses tRPC for end-to-end type safety between server components and client hooks, with Drizzle ORM over PostgreSQL (via Hyperdrive connection pooling) as the primary database and Cloudflare D1 for auth-session storage. AI code generation runs through the Vercel AI SDK v5 with a custom provider registry that routes requests to Anthropic, Azure OpenAI, Google Gemini, xAI Grok, and OpenRouter — all optionally proxied through Cloudflare AI Gateway for observability. Sandbox execution uses E2B or Daytona behind the unified ISandbox interface, running Vite-based project templates isolated per user. Build orchestration relies on Turborepo for task graph execution, Bun as the package manager and script runner, and Biome for monorepo-wide linting and auto-formatting with TypeScript strict mode throughout.

Code Quality The codebase has meaningful test coverage across critical paths: Vitest suites exist for auth utilities including nonce generation and subscription limit enforcement, AI generation logic, CDN rate limiting, file validation, and React component exports. Error handling follows a structured tryCatch utility pattern from @libra/common that returns typed [result, error] tuples, eliminating uncaught promise rejections and making error paths explicit throughout the AI module, auth adapters, and API routes. TypeScript strict mode is enforced workspace-wide via a shared tooling/typescript-config base, with Biome handling linting and formatting consistently across all packages. The test files that exist are well-structured with describe/it blocks and clear assertions, though coverage is concentrated in the packages and auth utilities rather than distributed across all application routes. Every source file carries an AGPL-3.0 SPDX header, and the codebase follows consistent naming conventions and import organization via Biome’s assist actions.

What Makes It Unique The most architecturally distinctive feature is the Cloudflare-first deployment model using Workers for Platforms, which gives each generated user project genuine tenant isolation — custom domains, isolated Worker bindings, and scoped R2/KV namespaces — rather than routing through a shared application. The dual sandbox provider abstraction (E2B and Daytona) behind a common ISandbox interface means the live preview and code execution environment is pluggable without touching generation logic, which is unusual for tools in this space. The Paraglide JS i18n integration compiles message catalogs into statically typed, tree-shaken modules at build time rather than loading JSON at runtime, eliminating i18n bundle bloat. The AI model access layer enforces subscription-tier gating server-side through a plan-to-model mapping, making it straightforward to add new models and gate them to specific plans without changing generation code. Finally, the better-auth-stripe integration handles annual quota refresh, mid-cycle plan changes, and Stripe webhook reconciliation in a dedicated package rather than coupling billing logic to application routes.

Self-Hosting

Libra AI is released under the GNU Affero General Public License v3.0 (AGPL-3.0). In plain terms, this means you can use, modify, and self-host Libra freely — including for commercial purposes — but if you distribute modified versions or run a modified version as a network service, you must release your modifications under the same AGPL-3.0 terms. For most teams self-hosting Libra as an internal tool without distributing it externally, the copyleft obligations are unlikely to create friction. However, if you intend to offer Libra’s functionality as a commercial SaaS product with your own modifications, you would either need to release those modifications publicly or negotiate a separate commercial license with Nextify Limited, which the README indicates is available.

Running Libra yourself requires a meaningful Cloudflare account setup: Workers for Platforms (a paid Cloudflare offering that enables per-user tenant isolation), D1 for auth storage, R2 for build artifacts, KV for configuration caching, Hyperdrive for PostgreSQL connection pooling, and optionally Cloudflare AI Gateway for AI request observability. Beyond Cloudflare, you need a PostgreSQL database, a Stripe account for subscription management, at least one AI provider API key (Anthropic, Azure OpenAI, Google, or others), and an E2B or Daytona account for sandbox compute. The setup is well-documented with step-by-step local development instructions, but it is genuinely multi-service infrastructure: plan for environment variable management across a dozen-plus services, database migration workflows via Drizzle Kit, and Wrangler-based Cloudflare deployments. Operational burden is moderate-to-high — you own uptime, database backups, Worker binding updates, and keeping pace with dependency upgrades across a large TypeScript monorepo.

The managed cloud service at libra.dev handles all infrastructure provisioning, AI provider key management, Stripe integration, and platform updates automatically. It includes a support tier absent from the self-hosted path, and the hosted version may receive features — such as enterprise authentication connectors or advanced AI model access — ahead of or exclusive to the commercial license tier. Self-hosters give up the convenience of zero-configuration setup and may lag behind the hosted platform in new feature availability. For teams that want Libra’s capabilities without the infrastructure overhead, the hosted service is the lower-risk option; for teams with data residency requirements, budget sensitivity at scale, or a need to deeply customize the AI generation pipeline, self-hosting provides the necessary control.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack

No spam. Unsubscribe anytime.

Join 750+ subscribers
No spam. Unsubscribe anytime.

Search