Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/biome-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Biome Lint and Format Check

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
biome_check:
runs-on: ubuntu-latest

steps:
- name: ⬇️ Checkout Repository
uses: actions/checkout@v4

- name: ⚙️ Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: 📦 Install Dependencies
run: npm install

- name: 📝 Run Biome Lint Check
run: npm run biome:lint

- name: 📏 Run Biome Format Check
run: npm run biome:format
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2026 [Samuel Egbajie/CodePapi] <oshiesam@gmail.com>


Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
122 changes: 122 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
```markdown
# CodePapi AI ⚡

**CodePapi AI** is a professional, privacy-focused developer utility that brings the power of LLMs to your local workflow. Translate code from any language to another, migrate frameworks, reviews codes, and debug logic—all without your data ever leaving your machine.

![License](https://img.shields.io/badge/license-MIT-blue.svg)
![Ollama](https://img.shields.io/badge/AI-Ollama-orange.svg)
![React](https://img.shields.io/badge/Frontend-React-61DAFB.svg)
![NestJS](https://img.shields.io/badge/Backend-NestJS-E0234E.svg)
![Biome](https://img.shields.io/badge/Linter-Biome-60a5fa.svg)

---

## 📺 Demo

https://github.com/user-attachments/assets/00000000-0000-0000-0000-000000000000

---

## ✨ Features

- 🔄 **Smart Translation**: Seamlessly convert code between 10+ languages (Go, Rust, Python, TS, etc., flexible enough to support more languages).
- 🚀 **Migration Engine**: Expert-level presets for:
- React Class Components ➡️ Functional Components
- JavaScript ➡️ TypeScript
- CSS ➡️ Tailwind CSS
- React ➡️ Vue
- 🔍 **Deep Code Review**: AI-driven analysis of performance, security, and best practices.
- 🐞 **Interactive Bug Fixer**: Side-by-side **Diff View** highlighting exactly what the AI changed to fix your logic.
- 🔒 **Air-Gapped Privacy**: Powered by `phi3:mini` running locally via **Ollama**.

---

## 🚀 Quick Start

### 1. Prerequisites
- [Docker & Docker Compose](https://docs.docker.com/get-docker/)

### 2. Setup & Installation
```bash
# Clone the repository
git clone [https://github.com/yourusername/codepapi-ai.git](https://github.com/yourusername/codepapi-ai.git)
cd codepapi-ai

# Start the entire stack (AI + Backend + Frontend)
docker-compose up -d

```

### 3. Usage

* **Frontend**: Open [http://localhost](https://www.google.com/search?q=http://localhost)
* **API**: Accessible at [http://localhost:3000](https://www.google.com/search?q=http://localhost:3000)

*Note: The first startup pulls the Phi-3 Mini model (approx 2.3GB). Please ensure you have a stable internet connection.*

---

## 🛠 Tech Stack

| Component | Technology |
| --- | --- |
| **AI Engine** | [Ollama](https://ollama.ai/) (phi3:mini) |
| **Orchestration** | LangChain.js |
| **Backend** | NestJS (Node.js) |
| **Frontend** | React, TailwindCSS, Lucide |
| **Editor** | Monaco Editor (VS Code Engine) |
| **Tooling** | Biome (Linting & Formatting) |

---

## 🤝 Contributing

We use **Biome** for lightning-fast linting and formatting. Please run the following before submitting a Pull Request:

```bash
# Check and apply fixes
npx @biomejs/biome check --apply .

```

**Adding Languages:** To add new programming languages or migration presets used by the UI, see the frontend documentation: `frontend/README.md` (section "Adding More Languages"). Edit `frontend/src/constants/languages.ts` to add entries.

## 📜 License

Distributed under the MIT License. See `LICENSE` for more information.

---

Created with ❤️ by [Your Name]

```

---

### 🔧 Step 4: The Biome Configuration (`biome.json`)
Run `npx @biomejs/biome init` in your project root. It will create this file. Here is a solid configuration for your project:

```json
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"complexity": {
"noForeach": "off"
}
}
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 100
}
}

```
6 changes: 3 additions & 3 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "backend",
"name": "codepapi-ai-backend",
"description": "A backend for the CodePapi AI tool",
"author": "Samuel Egbajie",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions backend/src/converter/converter.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller, Post, Body } from '@nestjs/common';
import { Body, Controller, Post } from '@nestjs/common';
import { ConverterService } from './converter.service';

@Controller('converter')
Expand All @@ -19,4 +19,4 @@ export class ConverterController {
async fix(@Body() data: { code: string; lang: string }) {
return this.converterService.fixBugs(data.code, data.lang);
}
}
}
4 changes: 2 additions & 2 deletions backend/src/converter/converter.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Module } from '@nestjs/common';
import { ConverterService } from './converter.service';
import { ConverterController } from './converter.controller';
import { ConverterService } from './converter.service';

@Module({
providers: [ConverterService],
controllers: [ConverterController]
controllers: [ConverterController],
})
export class ConverterModule {}
32 changes: 18 additions & 14 deletions backend/src/converter/converter.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable, InternalServerErrorException } from '@nestjs/common';
import { ChatOllama } from '@langchain/ollama';
import { Injectable, InternalServerErrorException } from '@nestjs/common';

@Injectable()
export class ConverterService {
Expand All @@ -8,25 +8,29 @@ export class ConverterService {
constructor() {
this.model = new ChatOllama({
baseUrl: process.env.OLLAMA_URL || 'http://localhost:11434',
model: 'qwen2.5-coder:1.5b',
model: 'phi3:mini',
});
}

// --- 1. CODE TRANSLATION ---
async convertCode(code: string, from: string, to: string) {
// Check if "to" is a migration preset
const isMigration = to.includes('-') || from.includes('-');
const prompt = `
async convertCode(code: string, from: string, to: string) {
// Check if "to" is a migration preset
const isMigration = to.includes('-') || from.includes('-');

const prompt = `
You are an expert software architect specializing in ${isMigration ? 'code migration' : 'code translation'}.
Task: Convert the input from ${from} to ${to}.

${isMigration ? `
${
isMigration
? `
SPECIFIC INSTRUCTIONS FOR MIGRATION:
- If moving from Class to Functional components, use React Hooks (useState, useEffect).
- If moving to TypeScript, add proper interfaces and types.
- If moving between frameworks (e.g., React to Vue), map lifecycle methods and state management accurately.
` : ''}
`
: ''
}

RULES:
- Return ONLY raw code.
Expand Down Expand Up @@ -72,13 +76,13 @@ async convertCode(code: string, from: string, to: string) {
private async executeInvoke(prompt: string, key: string) {
try {
const response = await this.model.invoke(prompt);
return {
success: true,
[key]: response.content
return {
success: true,
[key]: response.content,
};
} catch (error) {
console.error(`AI Service Error:`, error);
console.error('AI Service Error:', error);
throw new InternalServerErrorException('Failed to connect to AI engine');
}
}
}
}
2 changes: 1 addition & 1 deletion backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AppModule } from './app.module';

async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors();
app.enableCors();
await app.listen(process.env.PORT ?? 3000);
}
bootstrap();
2 changes: 1 addition & 1 deletion backend/test/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import * as request from 'supertest';
import { App } from 'supertest/types';
import { AppModule } from './../src/app.module';
Expand Down
51 changes: 51 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": { "enabled": false, "clientKind": "git", "useIgnoreFile": false },
"files": {
"include": ["src", "test"],
"ignoreUnknown": false,
"ignore": ["**/node_modules", "dist/**", "frontend/src/main.tsx"]
},
"formatter": {
"enabled": true,
"useEditorconfig": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 80,
"attributePosition": "auto",
"bracketSpacing": true
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"style": {
"useImportType": "off"
},
"complexity": {
"noStaticOnlyClass": "off"
}
}
},
"javascript": {
"parser": {
"unsafeParameterDecoratorsEnabled": true
},
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "all",
"semicolons": "always",
"arrowParentheses": "always",
"bracketSameLine": false,
"quoteStyle": "single",
"attributePosition": "auto",
"bracketSpacing": true
}
}
}
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
volumes:
- ollama_data:/root/.ollama
entrypoint: /bin/sh
command: -c "ollama serve & sleep 5 && ollama pull qwen2.5-coder:1.5b && wait"
command: -c "ollama serve & sleep 5 && ollama pull phi3:mini && wait"

# 2. NestJS Backend
backend:
Expand All @@ -34,7 +34,7 @@ services:
ports:
- "80:80"
depends_on:
- backend
- backend

volumes:
ollama_data:
Loading