Prerequisites
Before starting, ensure you have:- Python 3.13+: Check with
python --version - uv: Python package installer (installation guide)
- Bun 1.3.7+: JavaScript runtime and package manager (installation guide)
- Git: For cloning the repository
Quick Start
The simplest way to run Codex-LB locally is usinguvx:
- Install Codex-LB in an isolated environment
- Start the server on port 2455
- Store data in
~/.codex-lb/
Development Setup
For active development with hot reload:1. Clone the Repository
2. Install Dependencies
3. Configure Environment
Create a.env.local file in the project root:
.env.local to customize settings. Key options:
4. Run Development Servers
Open two terminal windows: Terminal 1 - Backend (FastAPI):In development mode, the frontend at
:5173 proxies API requests to the backend at :2455.5. Access the Dashboard
Open http://localhost:5173 in your browser for the development build with hot reload. For production-like testing, open http://localhost:2455 after building the frontend.Using Docker Compose for Development
For a containerized development environment with hot reload:- Backend changes in
./appsync to the container - Frontend changes in
./frontendsync to the container - Dependency changes (
pyproject.toml,package.json) trigger rebuilds
- Frontend dev server: http://localhost:5173
- Backend API: http://localhost:2455
Data Directory
Local development stores data in:Database Management
Running Migrations
Manually run database migrations:Creating Migrations
When you modify database models:Migration filenames use the format
YYYYMMDD_HHMMSS_slug.py to reduce merge conflicts.Validating Migrations
Before committing migrations, validate them:- Single migration head (no branches)
- Correct revision naming format
- No schema drift between models and migrations
Using PostgreSQL Locally
To test with PostgreSQL:Building the Frontend
To build the frontend for production:app/static/, which the FastAPI backend serves at the root path.
Test the production build:
Port Configuration
Backend (FastAPI)
Default: 2455 Change with:Frontend (Vite Dev Server)
Default: 5173 Change infrontend/vite.config.ts:
OAuth Callback
Default: 1455 (cannot be changed) This port is required by OpenAI’s OAuth implementation.Testing API Endpoints
Interactive API Docs
FastAPI provides interactive documentation:- Swagger UI: http://localhost:2455/docs
- ReDoc: http://localhost:2455/redoc
Using curl
Testing OAuth Flow
- Start the backend with OAuth settings configured
- Open the dashboard at http://localhost:5173
- Navigate to Accounts → Add Account
- Click Login with OpenAI
- Complete OAuth flow (redirects to port 1455)
Common Development Tasks
Adding a New Endpoint
- Create/edit a route in
app/modules/*/api.py - Define schemas in
app/modules/*/schemas.py - Implement business logic in
app/modules/*/service.py - Register the router in
app/main.pyif new - Test at http://localhost:2455/docs
Modifying the Database
- Update models in
app/modules/*/models.py - Generate migration:
uv run alembic revision --autogenerate -m "description" - Review and edit migration in
app/db/migrations/versions/ - Apply:
uv run python -m app.db.migrate upgrade - Validate:
uv run codex-lb-db check
Adding Frontend Features
- Edit React components in
frontend/src/ - Changes hot-reload automatically at http://localhost:5173
- Use Tanstack Query for API calls (see existing queries)
- Build for production:
cd frontend && bun run build
Code Style and Linting
Python
The project uses Ruff for linting and formatting:Frontend
The frontend uses ESLint and Prettier:Debugging
Backend
Add breakpoints in your IDE or usebreakpoint() in the code:
Frontend
Use browser DevTools:- Open http://localhost:5173
- Press F12 to open DevTools
- Use Console, Network, and Sources tabs for debugging
Database Queries
Enable SQL query logging in.env.local:
Troubleshooting
Port Already in Use
Module Not Found
Frontend Build Fails
Database Locked
OAuth Redirect Fails
.env.local:
Next Steps
- Docker Deployment - Package for deployment
- Production Deployment - Deploy to production
- Configuration - Explore all configuration options
- Contributing - Contribute to Codex-LB