https://github.com/201harsh/ai-cg
End AI-CG
https://github.com/201harsh/ai-cg
Last synced: about 1 year ago
JSON representation
End AI-CG
- Host: GitHub
- URL: https://github.com/201harsh/ai-cg
- Owner: 201Harsh
- Created: 2025-04-18T19:39:02.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-02T20:04:02.000Z (about 1 year ago)
- Last Synced: 2025-05-18T06:08:47.707Z (about 1 year ago)
- Language: JavaScript
- Homepage: https://endaicodegen.onrender.com/
- Size: 88.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# π§ EndAI Code Generator
**EndAI** is an intelligent and responsive web application that empowers developers to generate complete coding projects β including boilerplate code and detailed project descriptions β with a single prompt. It uses **Google Gemini AI** to generate production-ready code and markdown-based explanations, making it an ideal tool for developers, learners, and creators looking to kickstart new ideas quickly.
---
## π Key Features
- βοΈ **AI-Powered Generation**
Instantly generate project code and accompanying markdown descriptions using the Google Gemini API.
- π **Project Management System**
Seamlessly create, save, and switch between multiple projects in a user-friendly sidebar layout.
- π **Typing Animation Effect**
Realistic typewriter animation enhances the experience when displaying newly generated content.
- π§ **Smart Memory Handling**
Previously saved projects load instantly without the typing animation, making the UX feel more efficient.
- π‘ **Live Syntax Highlighting**
Use of Prism.js ensures beautifully highlighted code blocks for better readability.
- π **Markdown Description Rendering**
Descriptions are rendered using React Markdown for rich-text formatting and readability.
- π± **Mobile Responsive**
Fully responsive UI ensures smooth experience on both desktop and mobile devices.
- π **One-Click Copy Buttons**
Instantly copy the code or description with a click for faster integration into your workflow.
---
## π§° Tech Stack
| Category | Technologies Used |
|---------------------|--------------------------------------------|
| **Frontend** | React.js, Vite, Tailwind CSS |
| **AI Integration** | Google Gemini API (free-tier support) |
| **Animations** | Framer Motion |
| **Code Highlighting** | Prism.js |
| **Markdown Renderer** | React Markdown |
| **State Management** | React Context API & Hooks |
---
## π Project Folder Structure
---
# π How Authentication Works Backend
This is the backend authentication system for the **EndAI Code Generator** app. It handles user registration, email OTP verification, secure login/logout, and token-based authentication using JWT. Built with **Node.js**, **Express**, and **MongoDB**, it ensures a smooth and secure authentication flow for developers.
---
## βοΈ Features
- π **User Registration** with email and password
- π§ **OTP Verification** via email before account activation
- π **Secure Login** using JWT
- πͺ **Logout** with token/session invalidation
- π§ **Password Hashing** with bcrypt
- π‘οΈ **Protected Routes** using auth middleware
- π **Email Sending** using Nodemailer
- β±οΈ **OTP Expiry Handling**
---
## π οΈ Tech Stack
| Technology | Description |
|----------------|--------------------------------|
| Node.js + Express | Web server and routing |
| MongoDB + Mongoose | Database and data modeling |
| bcryptjs | Password hashing |
| jsonwebtoken | JWT-based token auth |
| dotenv | Manage environment variables |
| Nodemailer | Email delivery for OTP |
---
## π§ Authentication Flow
### 1. π Register User
- **Endpoint**: `POST /api/auth/register`
- **Payload**:
```json
{
"email": "harsh@example.com",
"password": "yourpassword"
}
```
## β
Verify OTP
**Endpoint: POST /api/auth/verify-otp**
## π Login
**Endpoint: POST /api/auth/login**
## πͺ Logout
**Endpoint: POST /api/auth/logout (optional)**
Process:
Clears HTTP-only cookie (if using cookies)
Or removes token client-side
## π Environment Variables
Create a .env file in the root and add:
```
.env
PORT=4000
MONGO_URI = your_mongodb_connection_string
JWT_SECRET = your_jwt_secret_key
EMAIL_USER = your_email@example.com
EMAIL_PASS = your_email_password_or_app_password
```
## π Project Structure
```bash
endai-auth-backend/
βββ controllers/
β βββ authController.js # Handles register, verify, login, logout
βββ models/
β βββ User.js # Mongoose user schema
βββ routes/
β βββ authRoutes.js # Express routes for auth
βββ middleware/
β βββ authMiddleware.js # JWT token verification
βββ utils/
β βββ sendOTP.js # Nodemailer utility
βββ .env # Environment variables
βββ server.js # App entry point
βββ package.json # Project metadata
```
## βΆοΈ Running the Server
1. Clone the Repo
```bash
git clone https://github.com/201Harsh/End-AI-CG.git
cd Backend
```
## Install Dependencies
```bash
npm install
```
## Configure .env
```
Fill in the required values for MongoDB, JWT, and email.
```
## Start the Server
```bash
npx nodemon or node server.js
Server runs on http://localhost:4000
```
## π Securing Your API
- Hash passwords with bcrypt (already implemented)
- JWT tokens expire after 1h (customizable)
- OTP expires after 5β10 minutes (can be extended)
- Optional: Add rate limiting for OTP requests
## π¬ Sending Emails (OTP)
- Uses Nodemailer
- Compatible with Gmail (use an App Password)
- Can be swapped out for Mailgun, SendGrid, etc.
## π§ Future Improvements
- β
Add "Resend OTP" with cooldown
- π Add password reset via email
- π Add user analytics and dashboard
- π Host on Render/Heroku/Vercel backend
---
## π§ How It Works On Frontend
### 1. π Creating a Project
- Click the `+` button or "Create New Project".
- Type a prompt describing the type of project/code you want.
- Hit βGenerateβ.
- The AI processes the request and generates:
- A syntax-highlighted code block.
- A markdown description.
- Both are displayed with a typing animation.
### 2. π Navigating Projects
- Each generated project is listed in a collapsible sidebar.
- Click any saved project to quickly reload it (typing effect skipped for saved items).
### 3. π Copying Content
- Buttons are provided to copy the code and markdown description to your clipboard instantly.
---
## π‘ Why Choose EndAI?
- β‘ Skip boilerplate and get straight to building.
- π Perfect for learning and exploring new coding patterns.
- π¨ Clean and minimal UI focused on productivity.
- π Save and revisit your generated projects anytime.
---
## π§ Getting Started (Local Development)
Follow these steps to set up the project locally:
### 1. π¦ Clone the Repository
```bash
git clone https://github.com/201Harsh/End-AI-CG.git
cd Frontend
```
## π§ Install Dependencies
``` bash
npm install
```
## π Configure Environment Variables
Create a .env file in the root directory and add your Google Gemini API key:
```bash
VITE_GEMINI_API_KEY=your_google_gemini_api_key
```
Don't have one? You can get a free API key from the Google AI Studio.
## π Run the Development Server
``` bash
npm run dev
```
- The app will be running at http://localhost:5173 (or whatever port Vite assigns).
## ποΈ Build for Production
```bash
npm run build
```
## πΌοΈ Screenshots
**No screen shot Available**
## π¦ Main Dependencies
- React β Core UI framework
- Tailwind CSS β Utility-first styling
- Framer Motion β Smooth animations
- Prism.js β Code syntax highlighting
- React Markdown β Description rendering
- Google Gemini API β AI generation engine
## π Environment Variables
- Variable Description
VITE_GEMINI_API_KEY Your Google Gemini API key
## π€ Contributing
Contributions are welcome! Whether it's improving the UI, fixing bugs, or adding new features:
- Fork the repository.
- Create a new branch (git checkout -b feature-name).
- Commit your changes (git commit -m 'add feature').
- Push to the branch (git push origin feature-name).
- Open a pull request.
## π License
**This project is licensed under the MIT License.Β© 2025 Harsh**
## π Live Demo
- π Live Preview on
- https://endaicodegen.onrender.com/
---
**Made with β€οΈ by Harsh**
---