Skip to content

Latest commit

Β 

History

History
101 lines (65 loc) Β· 1.65 KB

File metadata and controls

101 lines (65 loc) Β· 1.65 KB

πŸš€ GenCode Backend

This is the backend for GenCode, an AI-powered platform to generate and solve competitive programming questions from user-defined prompts.


πŸ› οΈ Getting Started

1. Clone the Repository

git clone https://github.com/karannfr/GenCode-Backend.git
cd GenCode-Backend

2. Install Dependencies

npm install

3. Configure Environment Variables

Copy the .env.example file and rename it to .env:

cp .env.example .env

Open .env and fill in your credentials:

PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
GEMINI_API_KEY=your_gemini_2_5_flash_key
JUDGE0_URL=https://judge0-ce.p.rapidapi.com
JUDGE0_KEY=your_rapidapi_judge0_key

⚠️ Keep your .env file private β€” never push it to GitHub.


4. Start the Server

npm start

The server will start on:

http://localhost:5000

🌐 CORS

This backend only accepts requests from:

https://gencode.karnx.dev

To allow other domains (for dev or testing), update the CORS whitelist in server.js.


πŸ“¦ Features

  • ✨ Generate coding problems using Gemini 2.5 Flash
  • 🧠 Execute code in real time with Judge0 API
  • πŸ” Secure user authentication via JWT
  • πŸ“Š Track user submissions and performance history
  • ⏱️ Rate-limiting to prevent abuse

πŸ§ͺ Testing

You can test endpoints using:

After exceeding the request threshold, the server will return:

{
  "error": "Too many requests"
}

(Status code: 429)