Next.js frontend for wahl.chat.
bun installcp .env.example .env.localFill in the required values in .env.local:
- Backend:
NEXT_PUBLIC_API_URLdefaults tohttp://localhost:8080. Run the AI backend locally or point it to a hosted endpoint. - Firebase Public and Private Credentials: Required for the app to function. Obtain from Firebase Console > Project Settings.
- Stripe: Optional unless working on donation features.
The app uses geo-detection to redirect users to their regional election context. The mapping is defined in lib/constants.ts under REGION_TO_CONTEXT.
Each region code (e.g., HH) maps to a context ID (e.g., hh2029) that must exist in the Firestore contexts collection. If a context doesn't exist, users are redirected to the default context (landtagswahl-baden-württemberg-2026).
bun devOpen http://localhost:3000.
Deployed via the Vercel Platform. See the Next.js deployment docs for details.
The app caches Firestore data (sources, parties, contexts) for performance. To revalidate:
# By cache tag
curl -X POST https://wahl.chat/api/revalidate \
-H "Authorization: Bearer <REVALIDATE_SECRET>" \
-H "Content-Type: application/json" \
-d '{"tag": "source_documents"}'
# By path
curl -X POST https://wahl.chat/api/revalidate \
-H "Authorization: Bearer <REVALIDATE_SECRET>" \
-H "Content-Type: application/json" \
-d '{"path": "/bundestagswahl-2025/sources"}'Available cache tags (defined in lib/cache-tags.ts):
source_documents— Source documents for the sources pageparties— Global party datacontexts— Election contextscontext_parties— Parties per contextproposed_questions— Suggested questions