Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .claude/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## Overview

**Botsmann** is a modern AI bot platform featuring intelligent assistants for legal, medical, research, and language learning. Built with Next.js 16 and React 19.
**Botsmann** is a modern AI bot platform featuring intelligent assistants for legal, medical, research, and language learning. Built with Next.js 16 and React 19, self-hosted on the Hetzner box "bitbaum" behind Caddy (botsmann.orangecat.ch).

---

Expand All @@ -19,7 +19,7 @@
| Language | TypeScript |
| Styling | Tailwind CSS |
| Testing | Jest |
| Deployment | Vercel |
| Deployment | Self-hosted (Hetzner + Caddy) |

---

Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

# Botsmann is deployed self-hosted on the Hetzner box "bitbaum" behind Caddy.
# Deployment runs from the local `.husky/pre-push` hook (build -> rsync -> systemd
# restart) when main is pushed. This workflow only validates build/lint/tests.

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'

- name: Install dependencies and build
run: npm run build:ci
env:
NEXT_PUBLIC_DEPLOY_TIME: ${{ github.event.head_commit.timestamp }}

- name: Run format check
run: npm run format:check --if-present

- name: Run linting
run: npm run lint --if-present

- name: Run tests
run: npm run test --if-present
53 changes: 0 additions & 53 deletions .github/workflows/deploy.yml

This file was deleted.

3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ Thumbs.db
logs/
*.log

# Vercel
.vercel

# Runtime state / cache (bot runtime artifacts)
.call_count
.circuit_breaker_history
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Domain-specialized AI professionals, not another generic chatbot wrapper.
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![TypeScript](https://img.shields.io/badge/TypeScript-5-3178C6.svg)](https://www.typescriptlang.org/)
[![Next.js](https://img.shields.io/badge/Next.js-14-000000.svg)](https://nextjs.org/)
[![Live](https://img.shields.io/badge/Live-botsmann.vercel.app-brightgreen.svg)](https://botsmann.vercel.app)
[![Live](https://img.shields.io/badge/Live-botsmann.orangecat.ch-brightgreen.svg)](https://botsmann.orangecat.ch)

---

Expand Down
3 changes: 1 addition & 2 deletions app/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import {
searchUserDocuments,
} from '@/lib/chat';

// Extend function timeout for model loading (Vercel)
// Note: Free tier max is 10s, Pro tier allows up to 60s
// Extend function timeout for model loading (Next.js route segment config)
export const maxDuration = 30;

/**
Expand Down
2 changes: 1 addition & 1 deletion app/api/custom-bots/[id]/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
parseResponseWithSuggestions,
} from '@/lib/chat';

// Extend function timeout for model loading (Vercel)
// Extend function timeout for model loading (Next.js route segment config)
export const maxDuration = 30;

const ChatRequestSchema = z.object({
Expand Down
2 changes: 1 addition & 1 deletion app/api/demo/document-chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { getClientIp } from '@/lib/request';
import { sanitizeUserMessage, sanitizePromptContent } from '@/lib/prompt-sanitizer';
import { logger } from '@/lib/logger';

// Extend function timeout for model loading (Vercel)
// Extend function timeout for model loading (Next.js route segment config)
export const maxDuration = 30;

// Maximum document content size (characters) to prevent abuse
Expand Down
2 changes: 1 addition & 1 deletion app/api/documents/process/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { DOMAIN_ERRORS } from '@/lib/constants';
import { detectDomains } from '@/lib/context/domain-detector';
import { logger } from '@/lib/logger';

// Extend function timeout for embedding generation (Vercel)
// Extend function timeout for embedding generation (Next.js route segment config)
export const maxDuration = 60; // Allow longer for document processing

/**
Expand Down
2 changes: 1 addition & 1 deletion app/api/documents/search/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { jsonSuccess, jsonError, jsonUnauthorized, handleError, HTTP_STATUS } fr
import { DOMAIN_ERRORS } from '@/lib/constants';
import { logger } from '@/lib/logger';

// Extend function timeout for embedding generation (Vercel)
// Extend function timeout for embedding generation (Next.js route segment config)
export const maxDuration = 30;

/**
Expand Down
2 changes: 1 addition & 1 deletion app/api/professional-chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
import { getUserLLMSettings, searchUserDocuments } from '@/lib/chat';
import { getRelevantContext, extractAndSaveContext } from '@/lib/context';

// Extend function timeout for model loading (Vercel)
// Extend function timeout for model loading (Next.js route segment config)
export const maxDuration = 30;

const MAX_CONTEXT_CHARS = 4000; // Leave room for system prompt + response
Expand Down
2 changes: 1 addition & 1 deletion app/api/quick-chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
wrapUserContext,
} from '@/lib/prompt-sanitizer';

// Extend function timeout for model loading (Vercel)
// Extend function timeout for model loading (Next.js route segment config)
export const maxDuration = 30;

export async function POST(request: NextRequest) {
Expand Down
2 changes: 1 addition & 1 deletion app/api/warmup/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* GET /api/warmup - Pre-loads the embedding model to avoid cold start delays
*
* Called periodically by Vercel cron to keep the function warm
* Called periodically by a cron/uptime check to keep the embedding model warm
*/

import { NextResponse } from 'next/server';
Expand Down
2 changes: 1 addition & 1 deletion app/demo/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ const DemoPage: FC = () => {
• <strong>Backend:</strong> Next.js API routes
</li>
<li>
• <strong>Deployment:</strong> Vercel serverless
• <strong>Deployment:</strong> Self-hosted (Hetzner + Caddy)
</li>
</ul>
</div>
Expand Down
23 changes: 11 additions & 12 deletions docs/COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,21 @@ npm audit fix

## Deployment

### Manual Deploy to Vercel
Botsmann is self-hosted on the Hetzner box "bitbaum" behind Caddy
(botsmann.orangecat.ch). There is no Vercel.

```bash
# Install Vercel CLI if needed
npm i -g vercel
### Automatic Deploy

# Deploy to preview
vercel
Push to `main` — the local `.husky/pre-push` hook runs the self-hosted deploy
script (build → rsync → systemd restart) in the background. Logs stream to
`/tmp/push-deploy-botsmann.log`.

# Deploy to production
vercel --prod
```
### Manual Deploy

### Automatic Deploy

Push to `main` branch - GitHub Actions handles deployment.
```bash
# Re-run the same self-hosted deploy the pre-push hook triggers
bash /home/g/dev/fleetcrown/scripts/hetzner/deploy.sh botsmann
```

---

Expand Down
29 changes: 14 additions & 15 deletions docs/SHARED_CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ This document provides comprehensive technical context for the Botsmann project.

### Infrastructure

| Service | Purpose |
| -------- | -------------------------------- |
| Vercel | Hosting & deployment |
| Service | Purpose |
| -------------------- | -------------------------------- |
| Hetzner + Caddy | Hosting & deployment (self-host) |
| Supabase | Database, Auth, Storage, SQL API |
| AWS SES | Email delivery |

Expand Down Expand Up @@ -130,13 +130,14 @@ Chosen for:
- Built-in Auth, Storage, and realtime subscriptions
- Strong TypeScript support via generated types

### Serverless API Routes
### API Routes

All backend logic runs in Vercel serverless functions:
All backend logic runs in Next.js API routes, served by the self-hosted
Next.js server (systemd) on the Hetzner box:

- No server to maintain
- Auto-scaling
- Pay-per-use
- Single long-running server (no cold starts)
- Fronted by Caddy for TLS + reverse proxy
- Predictable, flat hosting cost

---

Expand Down Expand Up @@ -218,27 +219,25 @@ User → components/*Form.tsx

### Automatic (Recommended)

Push to `main` branch → GitHub Actions → Vercel
Push to `main` → local `.husky/pre-push` hook → self-hosted deploy on the
Hetzner box "bitbaum" (build → rsync → systemd restart), behind Caddy.
GitHub Actions runs build/lint/tests as CI only.

### Manual

```bash
npm run build
vercel --prod
bash /home/g/dev/fleetcrown/scripts/hetzner/deploy.sh botsmann
```

### Preview Deployments

Every PR gets a preview URL automatically.

---

## Performance Considerations

1. **Server Components**: Use by default, add `'use client'` only when needed
2. **Image Optimization**: Use `next/image` for all images
3. **Code Splitting**: Automatic with App Router
4. **Caching**: Vercel Edge caching for static content
4. **Caching**: Caddy + Next.js caching for static content

---

Expand Down
Loading
Loading