# letta-code **Repository Path**: veuns/letta-code ## Basic Information - **Project Name**: letta-code - **Description**: Letta Code 面向开发者与团队的 AI 代码生成工作台 Letta Code 是一个类 bolt.new / v0.dev 的 AI 代码生成平台,支持通过自然语言对话快速生成、编辑、运行和管理完整代码项目。它集成了 AI 对话、代码编辑器、文件管理、实时预览、终端运行、模型配置和管理后台,让用户可以在一个工作台中完成从想法到可运行项目的完整流程。 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 4 - **Forks**: 2 - **Created**: 2026-05-18 - **Last Updated**: 2026-05-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Letta Code A bolt.new / v0.dev style AI code generation platform powered by OpenAI-compatible APIs. ## Features ### User Application (Port 3000) - Chat-based code generation using AI - Real-time streaming responses - Monaco code editor with syntax highlighting - File tree navigation - Live preview with WebContainer (basic HTML preview available) - Multi-model support (OpenAI, Anthropic, DeepSeek, local models, etc.) ### Admin Dashboard (Port 3001) - API Key management for multiple providers - Custom base URL support for any OpenAI-compatible API - Model configuration (enable/disable models) - Usage analytics and statistics - System settings ## Tech Stack - **Framework**: Next.js 15 (App Router) - **Styling**: Tailwind CSS + shadcn/ui - **AI Backend**: OpenAI-compatible APIs - **Code Editor**: Monaco Editor - **Preview**: WebContainer API - **State Management**: Zustand - **Database**: SQLite with Drizzle ORM for users/projects/messages - **File Store**: Shared JSON-backed store for admin-managed API keys and model configuration - **Monorepo**: pnpm + Turborepo ## Supported Providers The application supports any OpenAI-compatible API: | Provider | Base URL | Notes | | ------------ | ---------------------------------------- | ----------------------------- | | OpenAI | `https://api.openai.com/v1` | Default | | Azure OpenAI | `https://your-resource.openai.azure.com` | Set custom base URL | | Anthropic | Via proxy | Use OpenAI-to-Anthropic proxy | | DeepSeek | `https://api.deepseek.com/v1` | Set custom base URL | | Moonshot | `https://api.moonshot.cn/v1` | Kimi AI | | Zhipu AI | `https://open.bigmodel.cn/api/paas/v4` | GLM models | | Ollama | `http://localhost:11434/v1` | Local models | | LM Studio | `http://localhost:1234/v1` | Local models | | OpenRouter | `https://openrouter.ai/api/v1` | Multi-provider gateway | ## Project Structure ``` letta-code/ ├── apps/ │ ├── web/ # User-facing application │ └── admin/ # Admin dashboard ├── packages/ │ ├── shared/ # Shared code (OpenAI client, DB, file store, types) │ └── ui/ # Shared UI components └── package.json # Monorepo root ``` ## Getting Started ### Prerequisites - Node.js 18+ - pnpm 9+ - OpenAI API key (or any compatible API key) ### Installation ```bash # Install dependencies pnpm install # Copy environment file cp .env.example .env # Add your API key to .env or configure it in the admin panel ``` ### Configuration Edit `.env` file: ```env # Optional: Your API key. The admin panel can also store provider keys. OPENAI_API_KEY=sk-xxx # Optional: Custom base URL for other providers OPENAI_BASE_URL=https://api.openai.com/v1 # Optional: Proxy settings PROXY_ENABLED=false PROXY_URL= ``` ### Development ```bash # Run all apps pnpm dev # Run only web app pnpm dev:web # Run only admin app pnpm dev:admin ``` ### Database Setup ```bash # Generate database schema pnpm db:generate # Push schema to database pnpm db:push # Open Drizzle Studio (database viewer) pnpm db:studio ``` ## Usage 1. Open http://localhost:3000 for the main application 2. Open http://localhost:3001 for the admin dashboard 3. Add your API key in the admin panel (or via environment variable) 4. Select a model and start chatting! ## API Endpoints ### Web App - `POST /api/chat` - Send message to AI (streaming) - `GET /api/models` - Get available models ### Admin App - `GET/POST/DELETE /api/api-keys` - Manage API keys - `GET/PATCH /api/models` - Model configuration - `GET /api/dashboard` - Dashboard summary - `GET /api/analytics` - Usage analytics - `GET/PATCH /api/settings` - System settings ## Quality Gates ```bash # Run unit tests pnpm test # Run ESLint across apps pnpm lint # Run production build pnpm build ``` ## Custom Models You can add custom models directly in the UI: 1. Click on the model selector in the header 2. Click "Add custom model..." 3. Enter the model identifier (e.g., `llama3.1:70b` for Ollama) ## Migration from Letta If you were using the previous Letta-based version: 1. Update your `.env` file: - Replace `LETTA_API_KEY` with `OPENAI_API_KEY` - Add `OPENAI_BASE_URL` if using a custom provider 2. Run database migration: ```bash pnpm db:generate pnpm db:push ``` 3. Re-add your API keys in the admin panel ## License MIT