A multi-user platform that connects to GitLab, indexes repository code, and lets teams chat with AI that can cross-reference and pinpoint code across projects.
- Multi-user auth with admin/member roles (first launch creates admin)
- GitLab integration via Personal Access Token -- syncs and indexes projects from a group
- Multi-provider AI -- OpenRouter, OpenAI, Google, Ollama, Open WebUI
- Code-aware chat -- AI searches indexed files with full-text search (tsvector + pg_trgm) and cites
file:line - Streaming responses with Markdown and syntax-highlighted code blocks
Next.js 16, TypeScript, PostgreSQL 16, Prisma 7, Auth.js v5, Vercel AI SDK v6, Tailwind CSS v4, shadcn/ui v4, Docker
- Node.js 22+
- Docker (for PostgreSQL)
git clone <repo-url> && cd gitlab-ai
npm installcp .env.example .envGenerate the secrets and paste them into .env:
# NEXTAUTH_SECRET
openssl rand -base64 32
# ENCRYPTION_KEY
openssl rand -hex 32Your .env should look like:
DATABASE_URL="postgresql://gitlab_ai:changeme@localhost:5433/gitlab_ai"
POSTGRES_PASSWORD=changeme
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=<paste-base64-here>
ENCRYPTION_KEY=<paste-hex-here>
docker compose up db -dThis runs Postgres on port 5433 (to avoid conflicts with any local Postgres on 5432). Wait a few seconds for the healthcheck.
npx prisma migrate deploy
npx prisma generatenpm run devOpen http://localhost:3000. You'll be redirected to /setup to create the initial admin account.
To wipe the database and start over:
# Stop the app if running, then:
docker compose down -v # removes the DB container AND its data volume
docker compose up db -d # start a fresh DB
npx prisma migrate deploy # re-create all tables + indexes
npm run dev # app starts, redirects to /setupIf you also want to regenerate your secrets:
# New NEXTAUTH_SECRET -- all existing sessions will be invalidated
openssl rand -base64 32
# New ENCRYPTION_KEY -- any previously stored API keys / PATs become unreadable
openssl rand -hex 32Update .env with the new values before starting the app.
Run the entire platform (app + database) with a single command.
cp .env.example .envEdit .env and fill in NEXTAUTH_SECRET and ENCRYPTION_KEY (see commands above).
Note: When running fully in Docker, the app connects to the DB container internally, so DATABASE_URL is set automatically in docker-compose.yml. The one in .env is only used for local development.
docker compose up --build -dThe app will be available at http://localhost:3000.
docker compose down -v # stop everything, delete DB volume
docker compose up --build -d # rebuild and start freshThe app auto-runs prisma migrate deploy on startup (see Dockerfile CMD), so tables are created automatically.
- Create admin -- first visit redirects to
/setup - Configure AI -- Admin > Settings > pick provider, model, and API key
- Connect GitLab -- Admin > GitLab > enter URL, PAT (
read_apiscope), and Group ID - Index projects -- include the repos you want, click Index (runs in background)
- Chat -- select indexed repos from the dropdown and ask about your code
src/
app/
setup/ First-time admin setup
login/ Login page
(authenticated)/
chat/ Chat interface + conversations
admin/
users/ User management
gitlab/ GitLab connection + indexing
settings/ AI provider config
api/ All API routes
lib/
auth.ts / auth.config.ts Auth.js (split for Edge compatibility)
prisma.ts Prisma client singleton (PrismaPg adapter)
crypto.ts AES-256-GCM encrypt/decrypt
ai/
providers.ts AI provider factory
code-context.ts Three-tier code search (FTS + trigram + ILIKE)
system-prompt.ts System prompt builder with code context
gitlab/
client.ts GitLab API wrapper
indexer.ts Repository indexing pipeline
file-filter.ts File inclusion rules + language detection
components/
chat/ ChatInterface, MessageBubble, ProjectSelector
layout/ Sidebar
ui/ shadcn/ui components
prisma/
schema.prisma Database schema
migrations/ All migrations (including FTS indexes)