The Problem
Generating a small, working app from a single natural-language prompt is the core value of Claude Artifacts, but that product is closed and proprietary. This repo is an open-source reimplementation: point an LLM at a prompt, get back a runnable React app rendered in a sandbox, with chat history, sharing, and code execution. The pain point it solves is giving teams an artifact-style workflow without being locked into a vendor.
What This Does
app/(main)/page.tsx is the prompt entry point. The flow is: user submits a prompt → app/api/create-chat/route.ts creates a chat record via Prisma → the LLM streams a response through app/api/get-next-completion-stream-promise/route.ts → generated code is rendered in a Sandpack sandbox via components/code-runner.tsx and friends. Chat UI lives under app/(main)/chats/[id]/ with chat-box.tsx, chat-log.tsx, and code-viewer.tsx. Sharing is handled by app/share/[id]/page.tsx and app/share/v2/[messageId]/page.tsx. The lib/shadcn.ts file (2,751 lines) is the UI component library, and prisma/ holds the schema for chat persistence, backed by Neon/PostgreSQL.
How It Is Wired
Execution starts at app/(main)/page.tsx, which routes into app/(main)/chats/[id]/page.tsx and its client counterpart page.client.tsx. The traced path reaches external services in few hops: prompt → create-chat/route.ts → Prisma write to Postgres; prompt → streaming route → Together AI inference API; generated code → Sandpack (CodeSandbox) for execution. The lib/shadcn-docs/index.ts module is the most unstable hub (instability 0.9, 9 imports out, 1 in) — a change there ripples widely.
A circular import cycle spans page.tsx, chat-box.tsx, chat-log.tsx, and code-viewer.tsx. Anyone modifying the chat UI must trace mutually reachable modules before touching a file. The dependency graph is shallow (24 edges across 77 modules), so most files are leaves; the blast radius concentrates in lib/shadcn.ts and the chat page cluster.
How To Use It
git clone https://github.com/moses-y/llamacoder
cd llamacoder
pnpm install
cp .example.env .env
pnpm dev
Required environment variables (per README and .example.env): TOGETHER_API_KEY for LLM inference, CSB_API_KEY for the CodeSandbox sandbox, and DATABASE_URL — a Neon Postgres connection string consumed by Prisma. Run pnpm prisma migrate dev before first start to create tables. The README documents npm install/npm run dev; the repo ships a pnpm-lock.yaml, so pnpm is the consistent choice.
Real-World Use
A support team wants internal tools — a CSV validator, a JSON formatter — generated on demand without a developer. A user types "build a tool that validates CSV columns against a schema" into the prompt box. Llama 3.1 405B streams back a React component, Sandpack executes it live, and the user can iterate in chat until it works. The result is shareable via the share routes, so a colleague gets a working URL instead of a screenshot.
Code Health & Issues
Static analysis (measured, not opinion) found 11 findings: 8 high, 3 medium. Key items:
- High — Import cycle:
app/(main)/chats/[id]/page.tsx,chat-box.tsx,chat-log.tsxparticipate in a circular import; extract shared types or defer an import. - High — Duplicated code: 230 repeated 6-line blocks across 24 files; extract shared helpers.
- High — Deep nesting: max indentation depth 8 in
app/(main)/page.tsx,code-viewer.tsx,page.client.tsx. - High — Oversized file:
lib/shadcn.tsat 2,751 lines. - High — Vulnerable dependency:
next@16.1.6carries CVE-2026-44575 (high) plus 27 more advisories; upgrade and commit the lockfile. - High — No tests: 77 source files, zero test files.
- High — No CI: no build/test workflow exists.
- Medium — No Dependabot/Renovate: advisories sit unpatched.
- Medium — Thin README: 1,420 bytes doesn't cover setup adequately.
- Medium —
postinstallscript inpackage.json: an install-time execution vector; disable scripts in CI.
The Bottom Line
Functionally solid demo of the artifact pattern with a real LLM backend, but it's a fork of a popular project that inherits both its strengths and its debt. Before production use: upgrade Next.js, add tests and CI, and break the chat-page import cycle. Right for teams wanting to self-host an artifact-style generator; not yet a hardened deployable.