Team Ai
Apppublic

wardamalik883/ai-code-explainer

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
App README

๐Ÿง  AI Code Explainer

Full Stack Project | Node.js + PostgreSQL + Gemini AI


๐Ÿ“ Project Structure

ai-code-explainer/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ server.js              โ† Main Express server
โ”‚   โ”œโ”€โ”€ db/
โ”‚   โ”‚   โ”œโ”€โ”€ index.js           โ† PostgreSQL connection
โ”‚   โ”‚   โ””โ”€โ”€ schema.sql         โ† Database tables
โ”‚   โ”œโ”€โ”€ middleware/
โ”‚   โ”‚   โ””โ”€โ”€ auth.js            โ† JWT verification
โ”‚   โ””โ”€โ”€ routes/
โ”‚       โ”œโ”€โ”€ auth.js            โ† Register & Login
โ”‚       โ””โ”€โ”€ explain.js         โ† AI explain + History
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ index.html             โ† Main app page
โ”‚   โ”œโ”€โ”€ login.html             โ† Login page
โ”‚   โ”œโ”€โ”€ register.html          โ† Register page
โ”‚   โ”œโ”€โ”€ css/
โ”‚   โ”‚   โ”œโ”€โ”€ style.css          โ† Shared styles
โ”‚   โ”‚   โ”œโ”€โ”€ app.css            โ† Main app styles
โ”‚   โ”‚   โ””โ”€โ”€ auth.css           โ† Login/Register styles
โ”‚   โ””โ”€โ”€ js/
โ”‚       โ”œโ”€โ”€ app.js             โ† Main app logic
โ”‚       โ””โ”€โ”€ auth.js            โ† Login/Register logic
โ”œโ”€โ”€ .env                       โ† Environment variables
โ”œโ”€โ”€ package.json
โ””โ”€โ”€ README.md

โš™๏ธ Setup โ€” Step by Step

Step 1: Install Node.js

Download from: https://nodejs.org

Step 2: Install PostgreSQL

Download from: https://www.postgresql.org/download/

Step 3: Get Free Gemini API Key

  1. 1.Go to: https://aistudio.google.com
  2. 2.Click "Get API Key"
  3. 3.Copy the key

Step 4: Setup Database

Open pgAdmin or psql and run:

sql
CREATE DATABASE code_explainer_db;

Then connect to it and run the schema.sql file.

Step 5: Configure .env

Open .env file and fill in:

DB_PASSWORD=your_postgres_password
GEMINI_API_KEY=your_gemini_api_key_here

Step 6: Install Dependencies

Open terminal in project folder:

bash
npm install

Step 7: Run the Server

bash
npm start

Step 8: Open in Browser

Go to: http://localhost:3000


๐Ÿ”‘ API Endpoints

MethodEndpointDescription
POST/api/auth/registerRegister new user
POST/api/auth/loginLogin user
POST/api/explainExplain code (protected)
GET/api/explain/historyGet user history
DELETE/api/explain/history/:idDelete history item

๐Ÿ› ๏ธ Tech Stack

LayerTechnology
FrontendHTML5, CSS3, JS
BackendNode.js + Express
DatabasePostgreSQL
AIGoogle Gemini API
AuthJWT + bcryptjs

Made with โค๏ธ for Aptech Assignment