Third instance of the "soft-delete blocks retry" pattern this week — same shape as the workshop re-registration fix (6c5e6d0a) and the repairer re-application fix (89e0bc66). Found by continuing the cross-codebase pattern audit started in those sessions. The gap: - /api/it-hilfe/requests/[id]/offers POST checked for any existing offer (request_id + helper_id) without filtering by status, then returned 400 "Du hast bereits ein Angebot für diese Anfrage abgegeben" if found. - The withdraw endpoint sets the row's status to 'withdrawn' and decrements offerCount — it does NOT delete the row. - DB schema has UNIQUE(request_id, helper_id) (migration 010 line 71), so a fresh INSERT would hit a constraint violation anyway. Net: a helper who pulled their offer was permanently blocked from re-offering on the same request, even while it's still OPEN. The error message implied an active offer existed when the helper had actively pulled theirs. Fix: - Existing-offer check now SELECTs id + status (not just id). - An existing NON-withdrawn offer still returns 400 (the prior PENDING/ACCEPTED behavior is preserved). - An existing WITHDRAWN offer falls through to a new UPDATE path that resurrects the row: same id, new message/details, status reset to PENDING. UNIQUE constraint stays satisfied because we reuse the row. - offerCount increment unchanged — the withdraw flow decremented it, so resurrecting + incrementing balances back to where it was. - INSERT path unchanged when no existing row. Tests: - Added OFFER_STATUS to two test files' @/config/it-hilfe mocks (offers/__tests__/route.test.ts AND offer/__tests__/route.test.ts — there are two test files for the same area, both needed updating). - New "resurrects a withdrawn offer" test case at the create-offer test file: mocks the existing-offer SELECT returning a withdrawn row, mocks the UPDATE→returning chain (override the default chain which has no .returning()), asserts returned offerId is the resurrected row's id, asserts mockInsert NOT called, asserts the resurrect-returning mock was hit. - 12 offers-route + 459 IT-Hilfe tests across 33 suites all pass; tsc clean. Found by reading the create-offer + withdraw flows side-by-side, same method as6c5e6d0aand89e0bc66. This completes the three-area pattern audit (workshops, repairer-applications, IT-Hilfe offers). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Revamp-IT
Technology deserves a second life. So does the right to use it.
Mission
RevampIT is a Swiss nonprofit enabling the free exchange of technology on a nonprofit basis. We redistribute computers, hardware, and software while promoting open-source as the ideal form of human collaboration. Based in Zurich, everything we build serves that mission -- including this codebase.
Architecture
Why a Custom CMS
We built a lightweight CMS instead of adopting Strapi. The reasoning:
- Complete control over features and TypeScript integration -- no fighting the framework
- Lighter footprint -- simpler deployment, lower resource usage
- No complexity tax -- Strapi's setup conflicts and over-engineering weren't worth it
The CMS runs as an Express.js backend (port 3001) with JWT authentication, role-based access control (Admin / Editor / Viewer), and a RESTful API.
TABLE_NAMES as Single Source of Truth
src/config/database.ts defines 165 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 (@revamp-it.ch email) --> Super Admins (hardcoded list)
is_staffboolean +staff_permissionstext array on the users table- Staff detection by email domain; super admins by explicit list
- Sensitive sections require permission checks -- no implicit trust
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 |
|---|---|
| Frontend | Next.js 16, React 18, TypeScript 5, Tailwind 3 |
| CMS | Express.js, JWT, RBAC |
| Database | PostgreSQL (Neon), Redis, Meilisearch |
| Payments | Stripe |
| Nodemailer (Listmonk / Brevo) | |
| AI | HIRN (in-house), OpenAI |
| Maps | Leaflet |
| Testing | Jest (312 tests), Playwright (E2E) |
| CI/CD | GitHub Actions, Vercel |
Quick Start
Prerequisites
- Node.js 20+
- PostgreSQL (or a Neon account)
- Redis
Setup
git clone https://github.com/revamp-it/revampit.git
cd revampit
cp .env.example .env.local # fill in your database URL, Stripe keys, etc.
npm install
npm run db:migrate
npm run dev # Next.js on :3000, CMS on :3001
Environment Variables
At minimum, configure:
DATABASE_URL-- PostgreSQL connection stringREDIS_URL-- Redis connection stringSTRIPE_SECRET_KEY/STRIPE_WEBHOOK_SECRETJWT_SECRET
See .env.example for the full list.
Testing
312 tests across 24 suites.
| 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
Vercel handles production deployment on merge to main.
Project Structure
src/
app/ # Next.js pages and API routes
components/ # React components (UI only, no business logic)
config/
database.ts # TABLE_NAMES SSOT (165 constants)
lib/
auth/ # JWT, permissions, staff detection
domain/ # Business logic (no HTTP, no UI)
email/ # Templates and delivery
logger.ts # Structured logging
hooks/ # Data fetching, state management
scripts/
db/migrations/ # Sequential SQL migrations
tests/ # Jest test suites
e2e/ # Playwright E2E tests
cms/ # Express.js CMS backend
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
Revamp-IT -- Birmensdorferstrasse 379, 8055 Zürich -- revamp-it.ch