Five of this repo's model ids were retired by their vendors. Four of them at
once, in the same file.
`src/lib/ai/providers.ts` had the Groq default, the large-context fallback, the
OpenRouter default and the OpenRouter vision model all dead — the entire cascade
except the Groq vision model. `src/lib/hirn/providers/groq.ts` and
`openrouter.ts` carried two more, so both of this repo's AI layers were down.
The history matters more than the repin. This block has now been repinned three
times and the previous two are still legible in its own comments: Llama-4-Scout
was decommissioned, so it moved to `llama-3.3-70b-versatile`, and Groq then
retired the entire llama-3.x family. The comment in `hirn/openrouter.ts` even
predicted its own death — "free catalogues rot, so replace it with another
`:free` id" — and was right, and nothing acted on it.
So the durable part of this change is not the new ids. It is that two checks now
run without being asked:
- dotfiles/scripts/ci/model-pin-audit.mjs asks Groq and OpenRouter DAILY
whether these exact ids are still listed. It is the one that catches NEW
rot, because it talks to the vendor rather than to a list. It did not catch
these: `src/lib/hirn/providers/` was never opened, because nothing in that
path said "ai" loudly enough. That gap is fixed and tested.
- a new test here catches the cheaper mistake — a dead id reintroduced by
copying an old line, reverting a file or merging a stale branch. It matches
FAMILIES rather than individual ids, because what happened twice was a whole
lineage withdrawn at once, not one model being deprecated.
That test strips comments before matching, deliberately. The comments above
these constants name every retired id on purpose — that history is the most
useful thing on the page — and a sibling repo already shipped a guard that
grepped a function body and failed on a COMMENT, reporting on prose instead of
behaviour. A self-test asserts the stripper still finds a genuinely present id,
so the sweep cannot pass on an empty haystack.
Every replacement was verified against the live catalogue on 2026-08-27. The
vision id was chosen on three properties rather than on name: `:free` with
`pricing.prompt = 0`, `image` among its input modalities, and tool support.
── One thing fixed that was not a model id ────────────────────────────────────
`npm run verify` could not pass on a clean checkout. ESLint was linting
`.claude/worktrees/` — complete copies of this repo living inside it — and
reported 641 errors, every single one from those copies. The real tree had zero.
CI checks out without the worktrees, so CI was green while every developer's
local verify was red. That is the failure mode this fleet has already been
bitten by: a gate that fails on good code teaches people to reach for
--no-verify, and then the day it means something nobody reads it. Ignored by
family, so a new worktree needs no new line.
── Noted, not fixed ───────────────────────────────────────────────────────────
This repo has TWO independent AI provider layers, `src/lib/ai` and
`src/lib/hirn/providers`, each with its own Groq and OpenRouter client and its
own model ids. That duplication is why five ids needed changing instead of two,
and it will cause the same work again. Merging them is a design decision with
real consequences for the Hirn feature, so it belongs to a human rather than to
this PR.
verify: lint (0 errors), typecheck, 538 suites / 7766 tests, build.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
evig
Intelligenz, für alle bezahlbar — gute, langlebige Technik, kuratiert statt Ramsch.
evig makes genuinely good computing affordable to everyone — curated, decent hardware people actually want to use, not junk refurb. Founded 2026. This repository is the platform that runs it: a storefront, a community marketplace, repair & IT-help, workshops, an AI-assisted intake pipeline, and an in-house AI assistant.
What this platform does
| Surface | Who it serves | What it does |
|---|---|---|
| Storefront | The public | Sells refurbished hardware (evig-certified) to fund operations |
| P2P Marketplace | Community | Lets members buy / sell / give away tech between each other |
| IT-Hilfe | People who need help | Matches help requests with volunteer technicians; in-person + remote |
| Workshops | Community | Repair Café sessions, Linux installs, digital-skills classes — paid + free |
| Erfassung pipeline | Staff | AI-assisted intake → triage → photo → publish for donated hardware |
| Member services | Members | Member directory, Swiss-compliant donation receipts, voting on association decisions |
| HIRN AI | Staff | In-house knowledge / action assistant; cascades through Groq / OpenRouter / Ollama |
How evig funds this platform
evig is a non-profit association in formation, run on a market/quality model where affordable pricing is the product, not a subsidy. The economic model is deliberately mixed so no single source carries the whole organization:
- Storefront revenue — curated, decent hardware sold at affordable prices. Margin funds operations.
- Service revenue — paid workshops, repair services, IT-Hilfe billable to companies that can pay (kept affordable for individuals).
- Donations — direct BTC donations and in-kind hardware donations.
- Membership — yearly membership fees.
- Grants & partnerships — selective collaborations with aligned organizations.
The platform is the operational backbone for all five. It is open-source (MIT) so other circular-economy organizations can adopt it directly — there's no extractive layer in between.
Architecture
The application is a single Next.js 16 app with App Router for both pages and API routes. In production, data lives in self-hosted PostgreSQL 17 on the Hetzner box, accessed through Drizzle ORM via DATABASE_URL. Authentication uses NextAuth v5 (Auth.js) with the @auth/pg-adapter, sharing the same connection pool as the app. Search is powered by Meilisearch. Payments go through Payrexx (Swiss-based, ZKB/Twint/card). Email is delivered via Listmonk with Nodemailer / Brevo as fallback. Product/listing images are stored in Cloudflare R2 (S3-compatible).
TABLE_NAMES as Single Source of Truth
src/config/database.ts defines ~130 table name constants. Every database query references TABLE_NAMES -- never a hardcoded string. The constants are organized into logical groups:
User & Auth | Inventory | Messaging | Services | Workshops | Locations
Applications | Payments | Reviews | Documents | IT-Hilfe | HIRN AI
Staff | Tasks | Content | Activity Stream | Meeting Protocols
P2P Marketplace | Organizational Numbers
Related SSOT exports live alongside: APPOINTMENT_ROLES, REVIEW_TARGET_TYPES, CONVERSATION_TYPES, SERVICE_CATEGORIES, FEATURED_SERVICE_SLUGS.
Adding a new domain means adding constants to one file. If a table name is wrong, it's wrong in one place.
Permission System
Three tiers, zero ambiguity:
Users --> Staff (is_staff, granted by a super admin) --> Super Admins (DB flag + owner floor)
is_staffboolean +staff_permissionstext array on the users table- Staff status is never derived from the e-mail domain. Anyone may register;
is_staffis granted explicitly (PATCH /api/admin/users/[id]/permissionsor the HR hire flow).isStaffEmailis cosmetic only — it picks a welcome-email template. Super admins come fromusers.is_super_admin, withSUPER_ADMIN_EMAILSas a bootstrap floor so the org cannot lock itself out. - Sensitive sections (finance, users, settings, …) require an explicit
permission —
is_staffalone grants none of them, so money and admin routes must check the section, never the staff flag.
Content Approval Flow
draft --> pending --> approved / rejected
Stored in user_content_submissions. Nothing goes live without review.
HIRN AI
In-house AI knowledge management system with an action cockpit and executor. Handles organizational intelligence -- not a chatbot wrapper.
Development Standards
These are enforced, not suggested:
- Logger --
import { logger } from '@/lib/logger'. Neverconsole.log. - TABLE_NAMES -- never hardcoded table strings. Import from
src/config/database.ts. - Parameterized queries -- never string concatenation. No exceptions.
- Swiss German -- user-facing text uses
ss(notß), properä/ö/ü(neverae/oe/ue).npm run lint:umlautscatches violations.
Tech Stack
| Layer | Technology |
|---|---|
| Framework | Next.js 16 (App Router), React 19, TypeScript 5, Tailwind 4 |
| Database | PostgreSQL (prod: Hetzner self-hosted; dev: Docker 5433), Drizzle ORM |
| Auth | NextAuth v5 (Auth.js) + @auth/pg-adapter (shares the app DATABASE_URL pool) |
| Search | Meilisearch |
| Payments | Payrexx (Swiss-based; ZKB / Twint / card) |
| Listmonk (primary), Nodemailer / Brevo (fallback) | |
| Storage | Cloudflare R2 (S3-compatible) for product/listing images |
| Rate limiting | Redis (upstash) |
| AI | HIRN (in-house provider stack: Groq → OpenRouter → Ollama cascade) |
| Testing | Jest (7,500+ tests), Playwright (E2E) |
| CI/CD | GitHub Actions → self-hosted Hetzner deploy (systemd revampit-app) |
Quick Start
Prerequisites
- Node.js 20+
- A PostgreSQL database — local Docker via
npm run services:up(port 5433) - Optional: Meilisearch, Redis, Listmonk for full feature coverage
Setup
git clone https://github.com/maonakamoto/evig.git
cd evig
cp .env.example .env.local # fill in DATABASE_URL, AUTH_SECRET, payment keys, etc.
npm install
npm run db:migrate
npm run dev # Next.js on :3000
Environment Variables
At minimum, configure:
DATABASE_URL-- PostgreSQL connection string (postgresql://postgres:postgres@localhost:5433/revampit_cmsfor local Docker; prod uses Hetzner — see.env.selfhost.local.example)AUTH_SECRET-- 32+ char random string for NextAuth JWT signingPAYREXX_INSTANCE/PAYREXX_API_SECRET/PAYREXX_WEBHOOK_SECRET-- payment integrationLISTMONK_URL+ Listmonk credentials -- email deliveryMEILISEARCH_URL/MEILISEARCH_KEY-- search
See .env.example for the full list.
Testing
7,500+ tests across 500+ Jest suites, plus a Playwright E2E layer.
| Category | Coverage |
|---|---|
| API routes | Notifications, admin, IT-Hilfe |
| Business logic | Protocols, payments, currency, tax compliance, HIRN AI |
| Auth | Password handling, permissions, rate limiter |
| Data processing | Bulk extraction, file parsing, CSV export/import |
| Validation | Schema tests |
| E2E (Playwright) | Auth smoke, marketplace, IT-Hilfe, security |
npm test # run all Jest tests
npm run test:e2e # run Playwright E2E suite
CI Pipeline
Defined in .github/workflows/ci.yml:
- Code Quality -- ESLint + TypeScript type check + Next.js build
- Auth Smoke Test -- Playwright, runs conditionally
- Unit Tests -- Jest, PR only
On merge to main, the .github/workflows/deploy-selfhost.yml workflow lints, type-checks, builds the Next standalone bundle, rsyncs it to the Hetzner box, and restarts the systemd revampit-app service (with a page-render rollback gate). Vercel is not used for production.
Project Structure
src/
app/ # Next.js App Router (pages + API routes)
[locale]/ # Public site (next-intl, de/en/fr/es/it/ja/ko)
admin/ # Staff admin surface
api/ # API route handlers
components/ # React components (UI only, no business logic)
config/
database.ts # TABLE_NAMES SSOT (~130 constants)
org.ts # Org-wide data SSOT (name, address, email, hours)
lib/
auth/ # NextAuth v5 wiring, permissions, staff detection
services/ # Business logic (no HTTP, no UI)
email/ # Templates and delivery
it-hilfe/ # IT-Hilfe domain (notifications, matching, offers)
payments/ # Payrexx integration
logger.ts # Structured logging
hooks/ # Data fetching (SWR), state management
db/schema/ # Drizzle schemas
scripts/
db/migrations/ # Sequential SQL migrations (072 ADD COLUMN token_version, etc.)
tests/ # Jest test suites
e2e/ # Playwright E2E tests
Contributing
- Fork and create a feature branch
- Follow the development standards (TABLE_NAMES, logger, parameterized queries, Swiss German rules)
- Run
npm testandnpm run lint:umlautsbefore pushing - Open a PR against
main-- CI will validate code quality and tests
License
MIT
evig -- Intelligenz, für alle bezahlbar -- evig.orangecat.ch