API voor het aanmaken en beheren van AI-bots
  • TypeScript 98.6%
  • Dockerfile 1.4%
Find a file
cdenbrok 7ae0b07e6e feat: incrementele indexering via content_hash + opruimen verwijderde sources
- POST /v1/bots accepteert nu content_hash per source; voor PDFs met signed URLs
  wordt deze gebruikt als checksum zodat een ongewijzigde PDF niet opnieuw wordt
  geïndexeerd ondanks een roterende signed URL
- Pipeline ruimt na elke deployment sources op die niet meer in de payload zitten
  (chunks worden via CASCADE verwijderd)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-20 09:05:44 +00:00
node_modules chore: remove unused openai.ts (replaced by groq.ts + embeddings.ts) 2026-06-19 15:34:27 +00:00
src feat: incrementele indexering via content_hash + opruimen verwijderde sources 2026-06-20 09:05:44 +00:00
tests feat: full TypeScript Bot Server API (Fastify + pgvector + BullMQ) 2026-06-19 15:22:51 +00:00
.env feat: switch to Groq (chat) + local ONNX embeddings (all-MiniLM-L6-v2 384d) 2026-06-19 15:32:22 +00:00
.env.example feat: switch to Groq (chat) + local ONNX embeddings (all-MiniLM-L6-v2 384d) 2026-06-19 15:32:22 +00:00
.gitignore chore: add .gitignore, remove node_modules from tracking 2026-06-19 15:35:27 +00:00
docker-compose.yml feat: switch to Groq (chat) + local ONNX embeddings (all-MiniLM-L6-v2 384d) 2026-06-19 15:32:22 +00:00
Dockerfile feat: switch to Groq (chat) + local ONNX embeddings (all-MiniLM-L6-v2 384d) 2026-06-19 15:32:22 +00:00
drizzle.config.ts feat: full TypeScript Bot Server API (Fastify + pgvector + BullMQ) 2026-06-19 15:22:51 +00:00
openapi.yaml feat: full TypeScript Bot Server API (Fastify + pgvector + BullMQ) 2026-06-19 15:22:51 +00:00
package-lock.json chore: add package-lock.json 2026-06-19 15:33:32 +00:00
package.json feat: switch to Groq (chat) + local ONNX embeddings (all-MiniLM-L6-v2 384d) 2026-06-19 15:32:22 +00:00
README.md feat: full TypeScript Bot Server API (Fastify + pgvector + BullMQ) 2026-06-19 15:22:51 +00:00
tsconfig.build.json feat: full TypeScript Bot Server API (Fastify + pgvector + BullMQ) 2026-06-19 15:22:51 +00:00
tsconfig.json feat: full TypeScript Bot Server API (Fastify + pgvector + BullMQ) 2026-06-19 15:22:51 +00:00
vitest.config.ts feat: full TypeScript Bot Server API (Fastify + pgvector + BullMQ) 2026-06-19 15:22:51 +00:00

API.Bot — Bot Server API

Production-ready Bot Server API in TypeScript (Fastify + pgvector + BullMQ + OpenAI).

Stack

Layer Tech
HTTP Fastify 4, ESM, TypeScript strict
Queue BullMQ + Redis
Database PostgreSQL 16 + pgvector (HNSW index)
ORM Drizzle ORM
LLM OpenAI (pluggable)
Logging pino (structured JSON)
Docs Scalar UI at /docs

Quick start (local)

cp .env.example .env
# Fill in BOT_SERVER_KEY and OPENAI_API_KEY
docker compose up --build

Server: http://localhost:8000
Swagger UI: http://localhost:8000/docs
Health: http://localhost:8000/healthz

Ontwikkelen zonder Docker

npm install
# Start postgres + redis via docker compose voor dependencies:
docker compose up postgres redis -d
cp .env.example .env  # pas DATABASE_URL + REDIS_URL aan naar localhost
npm run dev

Scripts

Script Actie
npm run dev Development server (tsx watch)
npm run build TypeScript → dist/
npm start Production start
npm test Vitest unit tests
npm run check typecheck + test

Deploy op Dokploy

  1. GitHub / Forgejo repo (code.pocfactory.nl/tenderadmin/api.bot) koppelen als Compose Stack.
  2. In Dokploy → Services → New → Docker Compose → kies de repo.
  3. Voeg environment variables toe via de Dokploy UI (zie .env.example).
  4. Stel een custom domain in met auto-TLS (Traefik).
  5. Deploy — Dokploy bouwt de image en start docker compose up.

Alternatief: dokploy deploy --compose docker-compose.yml

Environment variabelen

Var Beschrijving Verplicht
PORT HTTP poort (default 8000) Nee
BOT_SERVER_KEY Secret voor Bearer-auth (min 32 tekens) Ja
DATABASE_URL PostgreSQL connection string Ja
REDIS_URL Redis URL Ja
OPENAI_API_KEY OpenAI API sleutel Ja
EMBEDDING_MODEL Embedding model (default: text-embedding-3-small) Nee
CHAT_MODEL Chat model (default: gpt-4o-mini) Nee
CHAT_RATE_LIMIT Max chat requests/minuut per bot (default: 60) Nee
LOG_LEVEL pino log level (default: info) Nee

Een andere LLM-provider pluggen

  1. Maak src/services/llm/myprovider.ts met functies createEmbedding en createEmbeddingsBatch.
  2. Wissel de imports in src/services/ingest/pipeline.ts en src/services/rag/chat.ts naar jouw provider.
  3. Pas src/services/rag/chat.tsragChat / ragChatStream aan voor de nieuwe chat API.

De structuur is bewust simpel gehouden — er is geen abstractie-laag, zodat je direct de juiste calls kan plaatsen.

API overzicht

Method Path Beschrijving
POST /v1/bots Publiceer/update bot (async ingest)
GET /v1/bots/:id Status + source stats
GET /v1/bots/:id/deployments/:dep_id Deployment details + steps
GET /v1/bots/:id/deployments/:dep_id/logs Logs (JSON of SSE)
POST /v1/bots/:id/chat Chat (RAG, optioneel SSE stream)
POST /v1/bots/:id/deactivate Deactiveer
DELETE /v1/bots/:id Verwijder
GET /healthz Liveness
GET /readyz Readiness (db + redis + llm)

Volledige spec: /docs of openapi.yaml.

E2E tests

# Start de stack eerst
docker compose up -d
E2E=true API_URL=http://localhost:8000 BOT_SERVER_KEY=your-key npm test