Skip to content
karunya666Public

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

6 Commits

Folders and files

Repository files navigation

πŸ€– Codex

AI-Powered Coding Assistant β€” Think, Plan, Execute

Python FastAPI Docker LangGraph

Codex is an intelligent agentic coding assistant that understands your codebase, plans multi-step actions, runs tools safely, and helps you ship software faster β€” powered by the LLM of your choice.

πŸ“– Docs Β· ⚑ Quick Start Β· πŸ› Report Bug


✨ Features

Feature Description
🧠 Agentic Reasoning LangGraph-powered agent loop that thinks step-by-step before acting (Plan $\to$ Act $\to$ Observe)
πŸ” Codebase Understanding Full AST symbol indexing (Tree-sitter) & semantic retrieval using pgvector embeddings
πŸ› οΈ Autonomous Tools File reading, deterministic patch editing (apply_patch), regex grep, and linting
πŸ§ͺ Self-Testing Automatically executes test suites and self-heals code if tests fail
πŸ”„ Multi-Model Support Works with Google Gemini, OpenAI GPT-4, and Anthropic Claude via LiteLLM
🎯 Smart Model Routing Automatically assigns the right model tier for planning, coding, or summarization
βœ… Approval Workflows Critical operations require human confirmation before execution
🌐 Interactive Web UI Modern browser chat interface with live workspace switching

πŸ₯Š How Codex Differs From Other AI Tools

Unlike passive chat interfaces that only process copy-pasted text, Codex is an autonomous software engineering agent that operates directly on your local workspace:

Capability Standard AI Chatbots (ChatGPT / Claude Web) Basic Copilot Plugins πŸ€– Codex Agent
Codebase Awareness ❌ Manual copy-pasting (1–2 files at a time) ⚠️ Limited to active editor tab βœ… Full Codebase Indexing (AST Tree-sitter & pgvector semantic search)
Autonomous Tool Execution ❌ None (Text-only output) ❌ Cannot execute external tools βœ… Multi-Tool Agent Loop (File read, patch writing, grep, linting)
Automated Code Editing ❌ User must manually copy & paste code ⚠️ Inline autocomplete only βœ… Deterministic Multi-File Patching (apply_patch directly modifies files)
Self-Verification & Testing ❌ Cannot verify if code works ❌ Cannot run tests βœ… Automated Test Execution & Self-Healing (Runs pytest & auto-fixes errors)
Model Flexibility & Routing ❌ Locked to one provider ❌ Locked to vendor model βœ… Smart Multi-Model Routing (Routes tasks dynamically between Gemini, GPT-4, Claude)
Security & Human-in-the-Loop ❌ No safety controls ❌ No approval gating βœ… Configurable Approval Workflows for critical write operations
Privacy & Self-Hosting ❌ Cloud-only proprietary SaaS ❌ Proprietary SaaS βœ… 100% Self-Hosted & Open Source (Your code stays on your machine)

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚               User (Browser Web UI / CLI)           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚  HTTP / SSE
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              FastAPI Control Plane API               β”‚
β”‚         /v1/runs  /v1/tools  /health  /metrics      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚                            β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   LangGraph Agent   β”‚    β”‚    PostgreSQL + pgvector  β”‚
β”‚  (Plan β†’ Act β†’ Obs) β”‚    β”‚   (Run history + index)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   LiteLLM Router    β”‚    β”‚         Redis            β”‚
β”‚  Gemini / GPT-4 /   β”‚    β”‚   (Session cache &       β”‚
β”‚      Claude         β”‚    β”‚    in-memory fallback)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Tool Sandbox      β”‚
β”‚  (Docker / Local)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

⚑ Step-by-Step Local Setup Guide

Follow this guide to run Codex locally on your computer and connect it to any project on your machine.

πŸ“‹ Prerequisites

  • Python 3.12+ installed on your system (Download Python)
  • Astral uv (Recommended for ultra-fast setup):
    • Windows: powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
    • Mac/Linux: curl -LsSf https://astral.sh/uv/install.sh | sh
  • PostgreSQL Database (Local via Docker OR a free cloud database from Render / Neon / Supabase)
  • An LLM API Key (e.g. Free Google Gemini API Key or OpenAI/Anthropic key)

Step 1: Download / Clone the Repository

Option A: Using Git (Recommended)

git clone https://github.com/karunya666/Codexa.git
cd Codex

Option B: Download ZIP

  1. Click the green Code button at the top of the GitHub repository.
  2. Select Download ZIP.
  3. Extract the ZIP folder on your computer and open terminal in the Codex folder:
    cd Codex

Step 2: Install Dependencies

Using uv (Recommended):

uv pip install -e ".[dev]"

Or using standard pip:

pip install -e ".[dev]"

Step 3: Configure Environment Variables (.env)

Create your .env file by copying the example:

# Windows PowerShell:
Copy-Item .env.example .env

# Mac / Linux:
cp .env.example .env

Open .env in your code editor and configure:

# 1. Database Connection (Use local Postgres OR free cloud Postgres like Render/Neon/Supabase)
DATABASE_URL=postgresql+asyncpg://user:password@hostname:5432/dbname

# 2. LLM API Key (Add your API Key)
GEMINI_API_KEY=AIzaSy...
# Or for OpenAI:
# OPENAI_API_KEY=sk-...

# 3. Model Configuration (Default is Gemini)
ROUTING_CONFIG_PATH=routing.config.gemini.json
ROUTING_DEFAULT_MODEL=gemini/gemini-3.1-flash-lite

# 4. Sandbox Backend (Set to 'local' for running without Docker)
SANDBOX_BACKEND=local

Step 4: Start the Codex Server

Run the server command:

uv run coding-assistant serve

(or python -m coding_assistant serve)

You will see the startup confirmation:

πŸš€ Starting Codex server at http://127.0.0.1:8000
πŸ“– API documentation at http://127.0.0.1:8000/docs
INFO: Application startup complete.

Step 5: Open Web UI & Point to Any Project

  1. Open your browser and go to: πŸ‘‰ http://localhost:8000

  2. In the left sidebar under WORKSPACE, enter the full folder path of the project you want the AI to work on:

    • Windows Example: C:\Users\username\Projects\MyAwesomeApp
    • Mac/Linux Example: /home/username/projects/MyAwesomeApp
  3. Click the Set Workspace button.


🎯 Usage & Example Prompts

Once your workspace is connected, you can ask Codex anything about your project:

1. πŸ” Codebase Exploration & Architecture

"Explain this repo, its file structure, and its main entry points." "List all API routes and authentication middleware in this project."

2. πŸ› Bug Finding & Security Audit

"Scan this project for potential memory leaks, unhandled exceptions, and security vulnerabilities." "Why is the user login session expiring prematurely in auth.py?"

3. ✍️ Autonomous Code Implementation

"Add a new payment webhook handler in routes/payments.py to process Stripe events." "Refactor the database queries in services/user_service.py to use async SQLAlchemy."

4. πŸ§ͺ Automated Testing & Fixing

"Generate comprehensive pytest unit tests for the functions in utils/parser.py."


πŸ’» Terminal CLI Chat (Alternative)

You can also use Codex directly from your terminal:

uv run coding-assistant chat --workspace "C:\path\to\your\project"

Available slash commands in CLI:

  • /workspace <path> β€” Switch project folder on the fly
  • /status β€” View active models, tokens, and database status
  • /help β€” List all commands
  • /exit β€” Exit CLI

πŸ”‘ LLM Provider Options

Provider Environment Variable Model Example Get Key
Google Gemini GEMINI_API_KEY gemini/gemini-3.1-flash-lite, gemini/gemini-2.0-flash Google AI Studio
OpenAI OPENAI_API_KEY gpt-4o, gpt-4o-mini OpenAI Console
Anthropic ANTHROPIC_API_KEY claude-3-5-sonnet Anthropic Console

πŸ“ Project Structure

Codex/
β”œβ”€β”€ src/coding_assistant/
β”‚   β”œβ”€β”€ api/            # FastAPI REST & SSE endpoints
β”‚   β”œβ”€β”€ intelligence/   # LangGraph agent orchestration & planning
β”‚   β”œβ”€β”€ tools/          # Autonomous tool handlers (grep, AST search, patch)
β”‚   β”œβ”€β”€ sandbox/        # Sandbox execution engine (Docker & Local)
β”‚   β”œβ”€β”€ routing/        # LiteLLM capability-aware model router
β”‚   β”œβ”€β”€ db/             # SQLAlchemy asyncpg models & session management
β”‚   β”œβ”€β”€ services/       # In-memory & Redis cache, run worker
β”‚   └── observability/  # OpenTelemetry tracing & Prometheus metrics
β”œβ”€β”€ web/                # Clean browser chat interface (HTML/CSS/JS)
β”œβ”€β”€ docs/               # Complete phase documentation
β”œβ”€β”€ tests/              # Pytest test suite (64+ tests)
β”œβ”€β”€ Dockerfile          # Production container image
└── pyproject.toml      # Project manifest & dependencies

πŸ“„ License

This project is open source under the MIT License. See LICENSE for details.

Built with ❀️ using FastAPI, LangGraph, and LiteLLM

⭐ Star on GitHub: karunya666/Codexa

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages