diff --git a/.env.development b/.env.development index 972339ae2..be926669b 100644 --- a/.env.development +++ b/.env.development @@ -3,3 +3,6 @@ VITE_WORKOS_REDIRECT_URI=http://127.0.0.1:5173 VITE_WORKOS_API_HOSTNAME=apiauth.convex.dev DISABLE_USAGE_REPORTING=1 DISABLE_BEDROCK=1 +GITHUB_CLIENT_ID=your_github_client_id +GITHUB_CLIENT_SECRET=your_github_client_secret +VITE_APP_URL=http://127.0.0.1:5173 diff --git a/README.md b/README.md index 7775e0ac9..3299dc7d1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +# ๐Ÿณ Chef - AI-Powered Full-Stack App Builder +

@@ -5,109 +7,511 @@

-[Chef](https://chef.convex.dev) is the only AI app builder that knows backend. It builds full-stack web apps with a built-in database, zero config auth, file uploads, -real-time UIs, and background workflows. If you want to check out the secret sauce that powers Chef, you can view or download the system prompt [here](https://github.com/get-convex/chef/releases/latest). +

+ The only AI app builder that truly knows backend development +

+ +

+ Features โ€ข + Quick Start โ€ข + New Features โ€ข + Setup Guide โ€ข + Architecture โ€ข + Contributing +

+ +--- + +## ๐Ÿš€ What is Chef? + +[Chef](https://chef.convex.dev) is a revolutionary AI-powered application builder that creates **complete full-stack web applications** with: + +- ๐Ÿ—„๏ธ **Built-in Database** - Powered by Convex reactive database +- ๐Ÿ” **Zero-Config Authentication** - User management out of the box +- ๐Ÿ“ **File Upload System** - Handle media and documents seamlessly +- โšก **Real-time UIs** - Live updates across all connected clients +- ๐Ÿ”„ **Background Workflows** - Automated tasks and processes +- ๐Ÿค– **AI Code Generation** - Smart, context-aware code creation + +### ๐ŸŽฏ Why Chef is Different + +Unlike other AI code generators that only create frontend mockups, Chef understands and builds **complete backend systems**. It leverages [Convex](https://convex.dev)'s powerful APIs to create production-ready applications with real databases, authentication, and server-side logic. + +--- + +## โœจ Features + +### ๐ŸŽจ **Frontend Capabilities** +- **React/TypeScript** - Modern, type-safe frontend development +- **Responsive Design** - Mobile-first, adaptive layouts +- **Component Library** - Reusable UI components with Tailwind CSS +- **Real-time Updates** - Live data synchronization +- **File Management** - Drag-and-drop file uploads + +### ๐Ÿ”ง **Backend Power** +- **Convex Database** - Reactive, real-time database +- **Authentication** - Secure user management with OAuth +- **API Functions** - Serverless backend functions +- **File Storage** - Secure file upload and management +- **Background Jobs** - Scheduled tasks and workflows + +### ๐Ÿค– **AI Integration** +- **Multi-Provider Support** - OpenAI, Anthropic, Google, xAI +- **Context-Aware Generation** - Understands your entire codebase +- **Incremental Development** - Build and iterate on existing projects +- **Smart Debugging** - AI-powered error detection and fixes -Chef's capabilities are enabled by being built on top of [Convex](https://convex.dev), the open-source reactive database designed to make life easy for web app developers. The "magic" in Chef is just the fact that it's using Convex's APIs, which are an ideal fit for codegen. +--- -Development of the Chef is led by the Convex team. We -[welcome bug fixes](./CONTRIBUTING.md) and -[love receiving feedback](https://discord.gg/convex). +## ๐Ÿ†• New Features (Latest Update) -This project is a fork of the `stable` branch of [bolt.diy](https://github.com/stackblitz-labs/bolt.diy). +This fork includes three major enhancements: -## Getting Started +### 1. ๐Ÿ”‘ **Enhanced API Key Management** +- **Visual Interface** - Manage all API keys through a clean UI +- **Multiple Providers** - Support for Anthropic, Google, OpenAI, and xAI +- **Secure Storage** - Encrypted key storage in Convex database +- **Validation** - Real-time API key validation +- **No Environment Setup** - Add keys directly through settings page -Visit our [documentation](https://docs.convex.dev/chef) to learn more about Chef and check out our prompting [guide](https://stack.convex.dev/chef-cookbook-tips-working-with-ai-app-builders). +### 2. ๐Ÿ™ **GitHub Integration** +- **OAuth Authentication** - Secure GitHub account connection +- **Repository Browser** - View and select existing repositories +- **Project Import** - Continue work on existing GitHub projects +- **Seamless Workflow** - Import, modify, and deploy GitHub repos -The easiest way to build with Chef is through our hosted [webapp](https://chef.convex.dev), which includes a generous free tier. If you want to -run Chef locally, you can follow the guide below. +### 3. ๐Ÿ”— **Unified Architecture** +- **Single URL Access** - Frontend and backend served from one endpoint +- **Simplified Deployment** - No separate backend deployment needed +- **Development Efficiency** - Streamlined local development setup -### Running Locally +--- -Note: This will use the hosted Convex control plane to provision Convex projects. However, Chef tokens used in this enviroment will not count towards usage in your Convex account. +## ๐Ÿš€ Quick Start -**1. Clone the project** +### Prerequisites +- **Node.js 20+** - [Download here](https://nodejs.org/) +- **pnpm** - Fast, disk space efficient package manager +- **Git** - Version control -Clone the GitHub respository and `cd` into the directory by running the following commands: +### 1-Minute Setup ```bash -git clone https://github.com/get-convex/chef.git +# Clone the repository +git clone https://github.com/somdipto/chef.git cd chef + +# Install dependencies +npm install -g pnpm +pnpm install + +# Set up environment +echo 'VITE_CONVEX_URL=placeholder' > .env.local + +# Start development +pnpm dev ``` -**2. Set up local environment** +๐ŸŽ‰ **That's it!** Chef will start without requiring any API keys upfront. Add them through the UI at `http://127.0.0.1:5173/settings`. + +--- -Run the following commands in your terminal: +## ๐Ÿ“‹ Detailed Setup + +### Step 1: Environment Setup ```bash +# Install Node Version Manager (if not installed) +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash + +# Use the correct Node version nvm install nvm use + +# Install pnpm globally npm install -g pnpm -pnpm i -echo 'VITE_CONVEX_URL=placeholder' >> .env.local -npx convex dev --once # follow the steps to create a Convex project in your team -``` -Note: `nvm` only works on Mac and Linux. If you are using Windows, you may have to find an alternative. +# Install project dependencies +pnpm install +``` -**3. Set up Chef OAuth application** +### Step 2: Convex Database Setup -Go to the Convex [dashboard](https://dashboard.convex.dev/team/settings/applications/oauth-apps) and create an OAuth application. The team you use to create the application will be the only team you can sign-in with on local Chef. Redirect URIs will not matter, but you can set one to http://127.0.0.1:5173 (or whatever port youโ€™ll run the Chef UI on) so that the form can be submitted. +```bash +# Initialize Convex (follow interactive prompts) +npx convex dev --once + +# This will: +# 1. Create a Convex account (or login) +# 2. Set up a new project +# 3. Generate your CONVEX_URL +# 4. Update .env.local automatically +``` -**4. Set up Convex deployment** +### Step 3: Configure Environment Variables -Use `npx convex dashboard` to open the Convex [dashboard](https://dashboard.convex.dev) and go to Settings โ†’ Environment Variables. Then, set the following environment variables: +Create or update `.env.local`: ```env -BIG_BRAIN_HOST=https://api.convex.dev -CONVEX_OAUTH_CLIENT_ID= -CONVEX_OAUTH_CLIENT_SECRET= -WORKOS_CLIENT_ID= +# Convex (auto-generated by convex dev) +VITE_CONVEX_URL=https://your-deployment.convex.cloud + +# GitHub Integration (optional) +GITHUB_CLIENT_ID=your_github_oauth_app_id +GITHUB_CLIENT_SECRET=your_github_oauth_app_secret +VITE_APP_URL=http://127.0.0.1:5173 + +# API Keys (optional - can be added via UI) +ANTHROPIC_API_KEY=your_anthropic_key +GOOGLE_API_KEY=your_google_key +OPENAI_API_KEY=your_openai_key +XAI_API_KEY=your_xai_key ``` -**5. Add API keys for model providers** +### Step 4: GitHub Integration Setup (Optional) -Add any of the following API keys in your `.env.local` to enable code generation: +1. **Create GitHub OAuth App**: + - Go to GitHub Settings โ†’ Developer settings โ†’ OAuth Apps + - Click "New OAuth App" + - **Application name**: `Chef Local Development` + - **Homepage URL**: `http://127.0.0.1:5173` + - **Authorization callback URL**: `http://127.0.0.1:5173/settings` -```env -ANTHROPIC_API_KEY= -GOOGLE_API_KEY= -OPENAI_API_KEY= -XAI_API_KEY= +2. **Add credentials to `.env.local`**: + ```env + GITHUB_CLIENT_ID=your_client_id_here + GITHUB_CLIENT_SECRET=your_client_secret_here + ``` + +### Step 5: Start Development + +```bash +# Terminal 1: Start Convex backend +npx convex dev + +# Terminal 2: Start frontend (in new terminal) +pnpm dev +``` + +๐ŸŒ **Access your app**: http://127.0.0.1:5173 + +--- + +## ๐Ÿ—๏ธ Architecture + +### Frontend Stack +``` +React 18 + TypeScript +โ”œโ”€โ”€ Remix (Full-stack framework) +โ”œโ”€โ”€ Tailwind CSS (Styling) +โ”œโ”€โ”€ Radix UI (Component primitives) +โ”œโ”€โ”€ Convex React (Real-time data) +โ””โ”€โ”€ AI SDK (LLM integration) +``` + +### Backend Stack +``` +Convex Platform +โ”œโ”€โ”€ Reactive Database +โ”œโ”€โ”€ Authentication (OAuth) +โ”œโ”€โ”€ File Storage +โ”œโ”€โ”€ Serverless Functions +โ””โ”€โ”€ Real-time Subscriptions +``` + +### AI Integration +``` +Multi-Provider Support +โ”œโ”€โ”€ OpenAI (GPT-4, GPT-3.5) +โ”œโ”€โ”€ Anthropic (Claude 3.5 Sonnet) +โ”œโ”€โ”€ Google (Gemini Pro) +โ””โ”€โ”€ xAI (Grok) +``` + +--- + +## ๐Ÿ“ Project Structure + +``` +chef/ +โ”œโ”€โ”€ ๐Ÿ“ app/ # Frontend application +โ”‚ โ”œโ”€โ”€ ๐Ÿ“ components/ # React components +โ”‚ โ”‚ โ”œโ”€โ”€ ๐Ÿ“ settings/ # Settings page components +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ ApiKeyCard.tsx # API key management +โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ GitHubCard.tsx # GitHub integration +โ”‚ โ”‚ โ””โ”€โ”€ ๐Ÿ“ ui/ # Reusable UI components +โ”‚ โ”œโ”€โ”€ ๐Ÿ“ lib/ # Client-side utilities +โ”‚ โ”œโ”€โ”€ ๐Ÿ“ routes/ # Remix routes +โ”‚ โ”‚ โ”œโ”€โ”€ settings.tsx # Settings page +โ”‚ โ”‚ โ””โ”€โ”€ api.github.oauth.ts # GitHub OAuth handler +โ”‚ โ””โ”€โ”€ ๐Ÿ“ styles/ # CSS and styling +โ”‚ +โ”œโ”€โ”€ ๐Ÿ“ convex/ # Backend functions & schema +โ”‚ โ”œโ”€โ”€ schema.ts # Database schema +โ”‚ โ”œโ”€โ”€ apiKeys.ts # API key management +โ”‚ โ”œโ”€โ”€ github.ts # GitHub integration +โ”‚ โ”œโ”€โ”€ messages.ts # Chat functionality +โ”‚ โ””โ”€โ”€ auth.config.ts # Authentication config +โ”‚ +โ”œโ”€โ”€ ๐Ÿ“ chef-agent/ # AI agent logic +โ”‚ โ”œโ”€โ”€ ๐Ÿ“ prompts/ # System prompts +โ”‚ โ””โ”€โ”€ ๐Ÿ“ tools/ # AI tools and functions +โ”‚ +โ”œโ”€โ”€ ๐Ÿ“ template/ # Project templates +โ”œโ”€โ”€ ๐Ÿ“ public/ # Static assets +โ””โ”€โ”€ ๐Ÿ“„ SETUP_FEATURES.md # Feature setup guide +``` + +--- + +## ๐ŸŽฎ Usage Guide + +### Adding API Keys + +1. **Navigate to Settings**: http://127.0.0.1:5173/settings +2. **Choose Provider**: Click "Add [Provider] API Key" +3. **Enter Key**: Paste your API key +4. **Validate**: Chef automatically validates the key +5. **Save**: Keys are encrypted and stored securely + +### GitHub Integration + +1. **Connect Account**: Click "Connect GitHub" in settings +2. **Authorize**: Complete OAuth flow +3. **Browse Repos**: View your repositories +4. **Import Project**: Select a repo to continue working on it + +### Creating Applications + +1. **Start Chat**: Begin describing your application +2. **Iterate**: Refine requirements through conversation +3. **Deploy**: Chef generates complete full-stack code +4. **Customize**: Continue development with AI assistance + +--- + +## ๐Ÿ”ง Configuration Options + +### API Key Preferences + +```typescript +// Set in UI: Settings โ†’ API Keys +{ + preference: "always" | "quotaExhausted", // When to use your keys + anthropic: "sk-ant-...", // Claude models + openai: "sk-...", // GPT models + google: "AIza...", // Gemini models + xai: "xai-..." // Grok models +} +``` + +### GitHub Integration + +```typescript +// Stored securely in Convex +{ + accessToken: "ghp_...", // GitHub access token + username: "your-username", // GitHub username + avatarUrl: "https://..." // Profile picture +} ``` -Note: You can also add your own API keys through the Chef settings page. +--- -**6. Run Chef backend and frontend** +## ๐Ÿš€ Deployment -Run the following commands in your terminal: +### Vercel Deployment ```bash -pnpm run dev +# Install Vercel CLI +npm i -g vercel -## in another terminal -npx convex dev +# Deploy +vercel + +# Set environment variables in Vercel dashboard +# - VITE_CONVEX_URL +# - GITHUB_CLIENT_ID +# - GITHUB_CLIENT_SECRET +# - API keys (optional) +``` + +### Netlify Deployment + +```bash +# Build for production +pnpm build + +# Deploy build/ directory to Netlify +# Configure environment variables in Netlify dashboard +``` + +### Docker Deployment + +```dockerfile +FROM node:20-alpine +WORKDIR /app +COPY package*.json ./ +RUN npm install -g pnpm && pnpm install +COPY . . +RUN pnpm build +EXPOSE 3000 +CMD ["pnpm", "start"] +``` + +--- + +## ๐Ÿงช Development + +### Running Tests + +```bash +# Run all tests +pnpm test + +# Run tests in watch mode +pnpm test:watch + +# Run specific test file +pnpm test messages.test.ts ``` -Congratulations, you now have Chef running locally! You can log in to Chef with your existing Convex account. +### Linting & Formatting -Note: Chef is accessible at http://127.0.0.1:{port}/ and will not work properly on http://localhost:{port}/. +```bash +# Lint code +pnpm lint -## Repository Layout +# Fix linting issues +pnpm lint:fix -- `app/` contains all of the client side code and some serverless APIs. +# Format code +prettier --write . +``` - - `components/` defines the UI components - - `lib/` contains client-side logic for syncing local state with the server - - `routes/` defines some client and server routes +### Database Migrations -- `chef-agent/` handles the agentic loop by injecting system prompts, defining tools, and calling out to model providers. +```bash +# Create migration +npx convex migration new add_github_integration -- `chefshot/` defines a CLI interface for interacting with the Chef webapp. +# Run migrations +npx convex migration run +``` -- `convex/` contains the database that stores chats and user metadata. +--- -- `template/` contains the template that we use to start all Chef projects. +## ๐Ÿ” Troubleshooting + +### Common Issues + +**Port 5173 already in use** +```bash +# Kill existing process +lsof -ti:5173 | xargs kill -9 +pnpm dev +``` + +**Convex authentication errors** +```bash +# Re-authenticate +npx convex auth +npx convex dev --once +``` + +**API key validation fails** +- Check key format and permissions +- Ensure sufficient credits/quota +- Verify network connectivity + +**GitHub OAuth not working** +- Verify callback URL matches exactly +- Check client ID and secret +- Ensure OAuth app is active + +### Debug Mode + +```bash +# Enable debug logging +DEBUG=chef:* pnpm dev -- `test-kitchen/` contains a test harness for the Chef agent loop. +# Convex debug mode +npx convex dev --debug +``` + +--- + +## ๐Ÿค Contributing + +We welcome contributions! Here's how to get started: + +### Development Setup + +```bash +# Fork and clone the repository +git clone https://github.com/your-username/chef.git +cd chef + +# Create feature branch +git checkout -b feature/amazing-feature + +# Make changes and test +pnpm dev +pnpm test + +# Commit and push +git commit -m "Add amazing feature" +git push origin feature/amazing-feature + +# Create Pull Request +``` + +### Contribution Guidelines + +- **Code Style**: Follow existing patterns and use Prettier +- **Testing**: Add tests for new features +- **Documentation**: Update README and inline docs +- **Commits**: Use conventional commit messages +- **Issues**: Check existing issues before creating new ones + +### Areas for Contribution + +- ๐Ÿ› **Bug Fixes** - Help improve stability +- โœจ **New Features** - Add AI providers, integrations +- ๐Ÿ“š **Documentation** - Improve guides and examples +- ๐Ÿงช **Testing** - Increase test coverage +- ๐ŸŽจ **UI/UX** - Enhance user experience + +--- + +## ๐Ÿ“„ License + +This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details. + +--- + +## ๐Ÿ™ Acknowledgments + +- **Convex Team** - For the amazing reactive database platform +- **Bolt.diy** - Original inspiration and foundation +- **AI Providers** - OpenAI, Anthropic, Google, xAI for powerful models +- **Open Source Community** - For continuous improvements and feedback + +--- + +## ๐Ÿ“ž Support & Community + +- ๐Ÿ› **Bug Reports**: [GitHub Issues](https://github.com/somdipto/chef/issues) +- ๐Ÿ’ฌ **Discussions**: [GitHub Discussions](https://github.com/somdipto/chef/discussions) +- ๐Ÿ“ง **Email**: [Contact maintainer](mailto:your-email@example.com) +- ๐Ÿฆ **Twitter**: [@your-handle](https://twitter.com/your-handle) + +--- + +

+ Built with โค๏ธ by developers, for developers +

+ +

+ โฌ†๏ธ Back to Top +

diff --git a/SETUP_FEATURES.md b/SETUP_FEATURES.md new file mode 100644 index 000000000..baebcdcdc --- /dev/null +++ b/SETUP_FEATURES.md @@ -0,0 +1,63 @@ +# Chef Features Setup Guide + +This guide covers the setup for the three new features added to Chef: + +## 1. API Key Management via UI โœ… + +**Already implemented** - The settings page now shows all supported providers: +- Anthropic (Claude) +- Google (Gemini) +- OpenAI (GPT) +- xAI (Grok) + +Users can add, view, and remove API keys through the UI at `/settings`. + +## 2. GitHub Integration ๐Ÿ”ง + +**Setup required:** + +1. Create a GitHub OAuth App: + - Go to GitHub Settings โ†’ Developer settings โ†’ OAuth Apps + - Click "New OAuth App" + - Set Authorization callback URL to: `http://127.0.0.1:5173/settings` + +2. Update environment variables in `.env.local`: + ``` + GITHUB_CLIENT_ID=your_github_client_id + GITHUB_CLIENT_SECRET=your_github_client_secret + VITE_APP_URL=http://127.0.0.1:5173 + ``` + +3. Deploy Convex functions: + ```bash + npx convex dev + ``` + +## 3. Unified Backend/Frontend โœ… + +**Already implemented** - The app serves both frontend and backend from a single URL: +- Frontend: React/Remix app +- Backend: Convex functions for API keys and GitHub integration +- All accessible from `http://127.0.0.1:5173` + +## Usage + +1. Start the development server: + ```bash + pnpm run dev + npx convex dev # in another terminal + ``` + +2. Visit `http://127.0.0.1:5173/settings` to: + - Manage API keys for all supported providers + - Connect GitHub account and browse repositories + - Configure other settings + +## Files Modified/Created + +- `convex/schema.ts` - Added GitHub integration schema +- `convex/github.ts` - GitHub integration backend functions +- `app/routes/api.github.oauth.ts` - GitHub OAuth handler +- `app/components/settings/GitHubCard.tsx` - GitHub UI component +- `app/components/SettingsContent.client.tsx` - Updated settings page +- `app/components/settings/ApiKeyCard.tsx` - Enhanced API key management diff --git a/app/components/ModernHomepage.client.tsx b/app/components/ModernHomepage.client.tsx new file mode 100644 index 000000000..5e547426d --- /dev/null +++ b/app/components/ModernHomepage.client.tsx @@ -0,0 +1,231 @@ +import { useState } from 'react'; +import { ModernLayout, ModernContainer, ModernCard } from './ui/ModernLayout'; +import { ModernHeader } from './header/ModernHeader'; +import { ModernHero } from './landing/ModernHero'; +import { ModernChatInterface } from './chat/ModernChatInterface'; +import { ModernWorkbench } from './workbench/ModernWorkbench'; +import { cn } from '~/utils/classNames'; + +type ViewMode = 'landing' | 'chat' | 'workbench'; + +export function ModernHomepage() { + const [viewMode, setViewMode] = useState('landing'); + const [isGenerating, setIsGenerating] = useState(false); + + const handleStartBuilding = () => { + setIsGenerating(true); + setTimeout(() => { + setViewMode('chat'); + setIsGenerating(false); + }, 1500); + }; + + const handleOpenWorkbench = () => { + setViewMode('workbench'); + }; + + if (viewMode === 'workbench') { + return ( + + +
+ {/* Workbench Header */} +
+
+ +
+

My Chat App

+
+
+ +
+
+ +
+
+ ); + } + + if (viewMode === 'chat') { + return ( + + +
+ {/* Sidebar */} +
+
+ +

Recent Chats

+
+
+ +

Chat App with Real-time

+

2 hours ago

+
+ +

E-commerce Dashboard

+

1 day ago

+
+ +

Task Management App

+

3 days ago

+
+
+
+ + {/* Main Chat Area */} +
+ {/* Chat Header */} +
+
+

Building Your App

+

Chat with Chef to create your full-stack application

+
+ +
+ + +
+
+
+ ); + } + + return ( + + + + + {/* Features Section */} +
+ +
+

+ Everything You Need to Build Modern Apps +

+

+ Chef combines the power of AI with a complete backend platform to help you build production-ready applications in minutes. +

+
+ +
+
+
+
+ ๐Ÿค– +
+
+

AI-Powered Development

+

Describe your app in natural language and watch Chef build it for you with intelligent code generation.

+
+
+ +
+
+ โšก +
+
+

Real-time Everything

+

Built on Convex for instant updates, reactive queries, and seamless real-time collaboration.

+
+
+ +
+
+ ๐Ÿš€ +
+
+

Deploy Instantly

+

One-click deployment to production with automatic scaling and global CDN distribution.

+
+
+
+ + +
+
+
+
+
+
+
+
$ chef create my-app
+
๐Ÿณ Cooking up your app...
+
โœ… Database schema generated
+
โœ… Authentication configured
+
โœ… Real-time features added
+
โœ… Frontend components created
+
๐ŸŽ‰ Your app is ready!
+
+
+
+
+
+
+ + {/* CTA Section */} +
+ +
+

+ Ready to Cook Something Amazing? +

+

+ Join thousands of developers building the future with AI-powered full-stack development. +

+ +
+
+
+
+ ); +} diff --git a/app/components/SettingsContent.client.tsx b/app/components/SettingsContent.client.tsx index fbcd388f6..a90d6869f 100644 --- a/app/components/SettingsContent.client.tsx +++ b/app/components/SettingsContent.client.tsx @@ -1,5 +1,6 @@ import { ArrowLeftIcon } from '@radix-ui/react-icons'; import { ApiKeyCard } from '~/components/settings/ApiKeyCard'; +import { GitHubCard } from '~/components/settings/GitHubCard'; import { ThemeCard } from '~/components/settings/ThemeCard'; import { ProfileCard } from '~/components/settings/ProfileCard'; import { UsageCard } from '~/components/settings/UsageCard'; @@ -22,6 +23,7 @@ export function SettingsContent() { + diff --git a/app/components/chat/ModernChatInterface.tsx b/app/components/chat/ModernChatInterface.tsx new file mode 100644 index 000000000..725fb29b0 --- /dev/null +++ b/app/components/chat/ModernChatInterface.tsx @@ -0,0 +1,167 @@ +import { useState, useRef, useEffect } from 'react'; +import { ModernCard } from '../ui/ModernLayout'; +import { cn } from '~/utils/classNames'; + +interface Message { + id: string; + role: 'user' | 'assistant'; + content: string; + timestamp: Date; +} + +interface ModernChatInterfaceProps { + className?: string; +} + +export function ModernChatInterface({ className }: ModernChatInterfaceProps) { + const [messages, setMessages] = useState([ + { + id: '1', + role: 'assistant', + content: "Hi! I'm Chef, your AI coding assistant. Describe the app you'd like to build and I'll help you create it with a full backend, database, and real-time features.", + timestamp: new Date() + } + ]); + const [input, setInput] = useState(''); + const [isTyping, setIsTyping] = useState(false); + const messagesEndRef = useRef(null); + + const scrollToBottom = () => { + messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' }); + }; + + useEffect(() => { + scrollToBottom(); + }, [messages]); + + const handleSend = () => { + if (!input.trim()) return; + + const userMessage: Message = { + id: Date.now().toString(), + role: 'user', + content: input, + timestamp: new Date() + }; + + setMessages(prev => [...prev, userMessage]); + setInput(''); + setIsTyping(true); + + // Simulate AI response + setTimeout(() => { + const assistantMessage: Message = { + id: (Date.now() + 1).toString(), + role: 'assistant', + content: "I'll help you build that! Let me start by creating the project structure and setting up the necessary components...", + timestamp: new Date() + }; + setMessages(prev => [...prev, assistantMessage]); + setIsTyping(false); + }, 1500); + }; + + const handleKeyPress = (e: React.KeyboardEvent) => { + if (e.key === 'Enter' && !e.shiftKey) { + e.preventDefault(); + handleSend(); + } + }; + + return ( +
+ {/* Chat Header */} +
+
+
+ ๐Ÿณ +
+
+

Chef AI

+

Full-stack AI assistant

+
+
+
+
+ Online +
+
+ + {/* Messages */} +
+ {messages.map((message) => ( +
+
+

{message.content}

+

+ {message.timestamp.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })} +

+
+
+ ))} + + {isTyping && ( +
+
+
+
+
+
+
+
+ Chef is typing... +
+
+
+ )} +
+
+ + {/* Input */} +
+
+
+