An open API service indexing awesome lists of open source software.

https://github.com/sabithulla-16/codeforge

CodeForge is a React-based AI-powered coding platform featuring a Monaco editor, live terminal execution, Google & Ollama AI integration, smart token management, and real-time usage analytics.
https://github.com/sabithulla-16/codeforge

ai-assistant ai-code-editor c code-execution cpp developer-tools google-ai javascript monaco-editor ollama online-compiler python react token-analysis web-ide

Last synced: 2 days ago
JSON representation

CodeForge is a React-based AI-powered coding platform featuring a Monaco editor, live terminal execution, Google & Ollama AI integration, smart token management, and real-time usage analytics.

Awesome Lists containing this project

README

          

![Version](https://img.shields.io/badge/version-1.0.0-blue)
![License](https://img.shields.io/badge/license-Apache%202.0-green)
![React](https://img.shields.io/badge/React-19.x-61DAFB?logo=react)
![Node](https://img.shields.io/badge/Node.js-Required-339933?logo=node.js)
![Status](https://img.shields.io/badge/status-Stable-success)
![AI](https://img.shields.io/badge/AI-Google%20%7C%20Ollama-purple)

# ⚡ CodeForge — AI-Powered Code Editor & Execution Platform

CodeForge is a **modern AI-powered coding platform** built with **React** that combines a real code editor, compiler/runtime, AI assistant, token-aware usage analytics, and smart safety controls — all in one place.

It is designed for **students, developers, and learners** who want clarity, control, and transparency while coding with AI.

---

## 📌 CodeForge & Its Functions

CodeForge provides:

- 🧠 **AI-assisted coding**
- Explain code
- Explain errors
- Optimize code
- Convert code between languages
- Custom AI prompts

- 🧑‍💻 **Multi-language editor**
- JavaScript
- Python
- C
- C++

- ▶️ **Real-time code execution**
- Compile + run flow for C/C++
- Direct execution for JS & Python
- Interactive input handling

- 📊 **AI token usage tracking**
- Google & Ollama usage meters
- Per-response token history
- Combined usage graphs

- 🔒 **AI safety controls**
- Token-based cooldowns
- Session-based Google lock
- Auto-switching between providers

---

## 🛠 Implementation

### Frontend
- Built using **React (Create React App)**
- Monaco Editor (VS Code engine)
- Custom Radeon-style dark UI
- Chart.js for visual analytics

### Backend
- Node.js server
- WebSocket-based code execution
- AI routing and token estimation logic

### AI Providers
- **Google AI (Cloud-based)**
- **Ollama (Local / Offline)**

---

## 📦 Resources Used

- React
- Monaco Editor
- Chart.js
- WebSockets
- Node.js
- Google AI API
- Ollama
- Custom CSS (no UI frameworks)

---

## ⚔️ How CodeForge Is Different From Other Editors

| Feature | CodeForge | Other Editors |
|------|---------|--------------|
| Token visibility | ✅ Yes | ❌ Hidden |
| AI usage graphs | ✅ Yes | ❌ No |
| Google AI auto-lock | ✅ Yes | ❌ No |
| Ollama fallback | ✅ Yes | ❌ Rare |
| Compile vs Run logic | ✅ Correct | ❌ Mixed |
| Session-based limits | ✅ Yes | ❌ No |
| Transparent AI cost | ✅ Yes | ❌ No |

---

## 📸 Screenshots

### 🧑‍💻 Code Editor & Terminal

**JavaScript**
![JavaScript Editor](screenshots/editor/javascript.png)

**Python**
![Python Editor](screenshots/editor/python.png)

**C**
![C Editor](screenshots/editor/c.png)

**C++**
![C++ Editor](screenshots/editor/cpp.png)

---

### 🤖 AI Assistant

**Google AI Provider**
![Google AI](screenshots/ai/google.png)

**Ollama (Local AI)**
![Ollama AI](screenshots/ai/ollama.png)

---

### 📊 Token Usage Analytics

**Per-Response Token Usage**
![Per Response Usage](screenshots/usage/per-response.png)

**Combined Token Usage Graph**
![Combined Usage](screenshots/usage/combined.png)
---

## 🚀 How to Use It

### Requirements
- Node.js ≥ 18
- npm ≥ 9
- Git

### Installation
```bash
git clone https://github.com/Sabithulla-16/CodeForge.git
cd CodeForge
npm install
```

### Run Frontend
```bash
npm start
```
Runs at:
http://localhost:3000

### Run Backend
```bash
cd backend
node server.js
```
Runs at:
http://localhost:5000
---

## 🧠 AI Providers Setup

### 🔹 Ollama (Local AI)

- Official Site: [https://ollama.com](https://ollama.com)
- Documentation: [https://ollama.com/docs](https://ollama.com/docs)
- GitHub: [https://github.com/ollama/ollama](https://github.com/ollama/ollama)

### Pull a Model

```bash
ollama pull qwen2.5-coder:0.5b
ollama serve
```

### 🔹 Google AI (Cloud)

- Google AI Studio: [https://aistudio.google.com](https://aistudio.google.com)
- Google Cloud Console: [https://console.cloud.google.com](https://console.cloud.google.com)
- Generative AI Docs: [https://ai.google.dev](https://ai.google.dev)

---

### Google API Key Generation

1. Open [Google Cloud Console](https://console.cloud.google.com/)
2. Create a new project
3. Enable **Generative AI API**
4. Go to **APIs & Services → Credentials**
5. Click **Create API Key**
6. Add key to backend .env
```bash
GOOGLE_API_KEY=your_api_key_here
```
---

### ✅ Advantages

- No hidden AI costs
- Clear compile/run behavior
- Offline AI support (Ollama)
- Beginner-friendly UI
- Visual understanding of AI usage
- Safe usage controls

---

### 🧠 Advancements Used

- Session-based AI governance
- Dynamic token estimation
- Cooldown-based AI throttling
- Auto AI provider switching
- Per-response analytics visualization
- Real-time WebSocket execution

---

### 🔬 New Logics Implemented

1. 🔢 Token Estimation Logic

- 1 token ≈ 4 characters
- Pre-request estimation
- Post-response reconciliation

2. 🔒 Google AI Lock Logic

- 4000 tokens → cooldown (120s)
- 10 high-usage responses → session lock
- Auto fallback to Ollama

3. 🔁 Smart AI Routing

- Payload size & token checks
- Google → Ollama auto-switch
- User transparency messages

4. 📊 Usage Analytics

- Per-response token logging
- Provider-separated graphs
- Combined usage visualization

---

### 🔮 Future Upgrades

- Authentication & profiles
- Persistent usage history
- Cost estimation ($)
- More languages (Java, Rust, Go)
- AI debugging mode
- Export usage reports
- Cloud deployment support

---

### 👨‍💻 Developer Info

- Project Name: CodeForge
- Developer: Sabithulla
- Role: Student / Full Stack Developer
- Purpose: Learning, transparency, and safe AI-assisted coding

---