CodeGen is an AI-powered component generator that creates UI components based on natural language descriptions. Built with React, Vite, and Google's Gemini AI.
- AI-powered component generation using Google Gemini
- Support for multiple frameworks (React, Vue, HTML, CSS, etc.)
- Real-time preview of generated components
- Chat-based interface similar to ChatGPT
- Component history and management
- Node.js (v14 or higher)
- A Google Gemini API key (get it from Google AI Studio)
-
Install frontend dependencies:
npm install
-
Start the development server:
npm run dev
-
Build for production:
npm run build
-
Navigate to the server directory:
cd server -
Install backend dependencies:
npm install
-
Create a
.envfile with your Gemini API key:cp .env.example .env # Edit .env and add your API key -
Start the backend server:
npm run dev
The backend can be deployed to several platforms. See server/README.md for detailed instructions.
- Fork this repository to your GitHub account
- Go to Render and create an account
- Click "New Web Service"
- Connect your GitHub repository
- Configure the service:
- Name:
codegen-backend - Environment:
Node - Build command:
npm install - Start command:
npm start - Plan:
Free
- Name:
- Add environment variables:
GEMINI_API_KEY: Your actual Gemini API key
- Click "Create Web Service"
The frontend can be deployed to any static hosting service like Vercel, Netlify, or GitHub Pages.
-
Build the frontend:
npm run build
-
The built files will be in the
dist/directory -
Deploy the
dist/directory to Vercel
-
Build the frontend:
npm run build
-
Deploy the
dist/directory to Netlify
Create a .env file in the root directory:
VITE_API_URL=https://your-backend-url.com
VITE_SUPABASE_URL=your-supabase-url
VITE_SUPABASE_ANON_KEY=your-supabase-anon-key
VITE_MEM0_API_KEY=your-mem0-api-keyCreate a .env file in the server/ directory:
GEMINI_API_KEY=your-gemini-api-key
PORT=5000src/- Frontend React componentsserver/- Backend Node.js/Express serverpublic/- Static assetsdist/- Built frontend files
POST /generate- Generate code based on a promptGET /preview/:id- Get preview HTML for a generated componentGET /history- Get generation historyGET /languages- Get supported languagesGET /health- Health check endpoint
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a pull request
This project is licensed under the MIT License.