Skip to content

201Harsh/AI-CG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 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:
    {
      "email": "[email protected]",
      "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 = [email protected]
EMAIL_PASS = your_email_password_or_app_password

πŸ“ Project Structure

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
git clone https://github.com/201Harsh/End-AI-CG.git
cd Backend

Install Dependencies

npm install

Configure .env

Fill in the required values for MongoDB, JWT, and email.

Start the Server

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

git clone https://github.com/201Harsh/End-AI-CG.git
cd Frontend

πŸ”§ Install Dependencies

npm install 

πŸ”‘ Configure Environment Variables

Create a .env file in the root directory and add your Google Gemini API key:

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

npm run dev

πŸ—οΈ Build for Production

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


Made with ❀️ by Harsh


Releases

No releases published

Packages

No packages published

Languages