Skip to main content
LangBot is divided into frontend and backend. The frontend is developed using Vite + React Router + shadcn, and the backend is developed using Quart (an asynchronous version of Flask).

Backend

The code is located in the pkg directory and is started by the main.py file in the root directory. Install dependencies, we use uv to manage dependencies.
Start the backend
At this point, the configuration file will be automatically generated in the data/config.yaml file.

Frontend

The code is located in the web directory and requires Node.js and pnpm. Copy .env.example to .env and fill in the values.
  • Usage in Linux and other environments
  • Usage in Windows environments
Install dependencies and start the frontend
Then according to the output information, visit http://127.0.0.1:3000 to view the standalone frontend page.
In production environments, the frontend will be precompiled into static files and provided by the backend, and the frontend will automatically access the backend address on the same domain.

Code Formatting

The repository contains lint and format check workflows, and your code will be automatically checked when you push it. Please configure pre-commit to check your code locally before submitting.

API Documentation

We will write API documentation in APIFox before developing each interface. Please refer to API Documentation(Chinese).

Database Migrations

LangBot uses Alembic to manage database migrations, supporting both SQLite and PostgreSQL seamlessly without database-specific branching.

Migration File Location

Creating a New Migration

The recommended way is to use autogenerate, which compares ORM models against the database schema and generates a migration script:
The generated file will appear in src/langbot/pkg/persistence/alembic/versions/. Review and edit the generated script to confirm the changes are correct before committing.
Autogenerate can automatically detect column additions/removals, table changes, type changes, etc. However, for data migrations (e.g., modifying JSON field content), you need to manually add code to the generated script.
You can also create migration files manually, following the naming convention NNNN_description.py:

Migration Patterns

env.py sets render_as_batch=True, which makes Alembic automatically handle SQLite’s ALTER TABLE limitations (via temporary table rebuild). No need to branch on database type.

How It Works

Migrations run automatically when LangBot starts — no manual commands needed:
  1. On first startup, the baseline version is automatically stamped (marking the existing database)
  2. On subsequent startups, all pending migrations are applied (alembic upgrade head)

CI Testing

The repository includes a test-migrations.yml workflow that automatically tests migration scripts on both SQLite and PostgreSQL when persistence/ related files change.

CLI Tool