causelist.co.ke
The source code for the now defunct https://causelist.co.ke, a service that made Kenyan court cause lists and case law easier to access.
It provided a calendar view of daily cause lists, full-text case law / precedent search, and causelist search (by party or case number) — all drawn from data published on https://kenyalaw.org — plus a directory of legal professionals, a paid subscription tier, and an advertising platform for law firms.
The service was operational from Jan 2024 to Aug 2024 and was shut down due to financial difficulties. The code is released here under the AGPL-3.0 license for reference and reuse.
Architecture
The project is a monorepo built as three cooperating services, all written in TypeScript:
causelist-stack/
├── app/ # Next.js 14 frontend (web app + PWA)
├── causelist-api/ # NestJS backend / REST API
├── kenyalaw-crawler/ # Crawlee/CheerioCrawler scraper for kenyalaw.org
├── helm/ # Helm chart for Kubernetes deployment
├── docker-compose.yaml # Local Mongo + nginx proxy
├── Tiltfile # Local development orchestration
└── scripts/ # DB import/export helpers, dev snapshots
1. kenyalaw-crawler — data acquisition
A Crawlee / CheerioCrawler scraper that crawls kenyalaw.org for daily cause lists (main-causelist.ts) and case law (main-cases.ts). Downloaded documents (PDF etc.) are converted to plain text using Apache Tika, LibreOffice and Tesseract OCR, then uploaded to S3-compatible object storage (MinIO/SeaweedFS). Post-processing scripts (process-crawled-data.ts, process-crawled-cases.ts) clean and reshape the raw output for ingestion.
2. causelist-api — backend
A NestJS service providing:
- Auth & users — OTP sign-up/sign-in, JWT sessions, subscriptions
- Case law & cause lists — models, import pipeline, and serving of parsed data
- Search — full-text search backed by ManticoreSearch and Meilisearch
- Payments — iPay Africa, K2 Connect, and M-Pesa (STK push / paybill)
- SMS & email — Zettatel SMS gateway and SMTP (Mailhog in dev)
- Admin — AdminJS panel over Mongoose models
- K8s jobs — triggers crawler jobs in-cluster
- Storage — S3 uploads, plus a
cli.ts command runner for data importing/parsing
3. app — frontend
A Next.js 14 (React + MUI) application exposing:
- Check Calendar — browse a court's cause list by court and date
- Law Reports & Case Law — search cases, authorities and precedents by subject matter or party names
- Causelist Search — search cause lists by party or case number
- Directory — legal professionals / law firms (get listed, ad placements)
- Account — subscriptions, payments, profile (PWA-enabled)
Shared interfaces
causelist-api/src/interfaces contains the shared API types. pre-build.sh copies them into app and kenyalaw-crawler before building:
./pre-build.sh
Tech Stack
| Layer |
Technologies |
| Frontend |
Next.js 14, React 18, MUI, SWR, Zustand, PWA, PostHog, Sentry |
| Backend |
NestJS 10, Mongoose (MongoDB), Bull/Redis, class-validator, Pino, Sentry |
| Search |
ManticoreSearch, Meilisearch |
| Storage |
MongoDB, Redis, MinIO / SeaweedFS (S3-compatible) |
| Crawling |
Crawlee / CheerioCrawler, Apache Tika, LibreOffice, Tesseract, Pino, Sentry |
| Payments |
iPay Africa, K2 Connect, M-Pesa (Daraja) |
| Infra |
Docker, Kubernetes (Helm), GitHub Actions, Tilt |
Error Tracking
All three services report to Sentry, disabled in development and enabled in staging/production:
app — @sentry/nextjs configured in sentry.{client,server,edge}.config.ts; global errors captured via global-error.jsx.
causelist-api — @sentry/nestjs registered in app.module.ts (SentryModule.forRoot) with SentryGlobalFilter capturing all unhandled exceptions.
kenyalaw-crawler — @sentry/node initialized through src/sentry.ts in every entry point, with explicit capture/flush on failures.
The API and crawler read the DSN from the SENTRY_DSN env var; if it is unset they log a warning and skip initialization. Reporting can also be toggled with DISABLE_SENTRY / NEXT_PUBLIC_ENVIRONMENT (disabled in development).
Logging
All three services log structured JSON to stdout via Pino (pretty-printed in development), with consistent base fields (service, environment, version) and shared redaction rules for secrets (authorization headers, cookies, passwords, OTPs, tokens, DSNs, payment/SMS credentials):
app — pino + next-logger; src/instrumentation.ts pipes Next's server console output through pino (experimental.instrumentationHook), plus a server-only src/logger.ts.
causelist-api — nestjs-pino (LoggerModule.forRoot) replaces Nest's Logger for all modules and requests, with request IDs, an excluded /health route, and a request_id tag sent to Sentry for correlation.
kenyalaw-crawler — a pino-backed src/logger.ts exposing the same log API previously used from Crawlee, so existing call sites produce structured logs; Crawlee's own internal output is untouched.
Configuration is shared across services via the same env vars: LOG_LEVEL (default info, debug in development) and LOG_PRETTY (pretty output; auto-enabled in development, JSON lines otherwise). When a Sentry span is active, log records also carry trace_id / span_id.
Linting
All three services use ESLint 8 (legacy .eslintrc configs) with @typescript-eslint, plus Prettier enforced through eslint-plugin-prettier. Code style is preserved per service (the API uses single quotes, app/crawler use double quotes) via a .prettierrc in each.
app — next lint over next/core-web-vitals + prettier (yarn lint / yarn lint:fix).
causelist-api — eslint with @typescript-eslint/recommended + prettier; ~250 pre-existing unused imports are warnings (non-blocking) and can be cleaned up incrementally.
kenyalaw-crawler — eslint with @typescript-eslint/recommended + prettier; fully clean.
From the repo root, run everything with yarn lint (no autofix), yarn lint:fix, yarn typecheck, or yarn format. A GitHub Actions workflow runs lint and typecheck for all three services on pull requests.
Getting Started (Local Development)
Prerequisites
- Node.js 20 (with corepack for the
app's Yarn 4 workspace)
- Docker
- kubectl and a local cluster — a minikube cluster at
192.168.49.2 is assumed by the sample env values
- Helm
- Tilt for the recommended dev workflow
- direnv (optional, used to load
.envrc → .env)
1. Clone & prepare the environment
git clone <repo-url> causelist-stack
cd causelist-stack
# Load environment variables from .env.sample (via direnv, or copy manually)
cp .env.sample .env # if not using direnv
# Copy shared API interfaces into app + crawler
./pre-build.sh
Install dependencies per workspace:
(cd app && yarn install)
(cd causelist-api && yarn install)
(cd kenyalaw-crawler && yarn install)
2. Start the stack with Tilt
Tilt renders the Helm chart (using values-tilt.yaml) against your local cluster and live-reloads the three services as you edit:
tilt up
This deploys the dev dependencies (MongoDB, Redis, MinIO, Manticore, Meilisearch, Mailhog, proxy) plus causelist-app, causelist-api, and kenyalaw-crawler into the causelist-dev namespace. Access the app at the host configured in values-tilt.yaml (default http://causelist.tilt).
The causelist-api/src/interfaces directory is watched by Tilt; changing it re-runs pre-build.sh automatically.
3. Alternative: docker-compose
For a minimal local backend (MongoDB + nginx proxy) only, without Kubernetes:
docker compose up
This starts database (Mongo, exposed on 27017-27019) and proxy (nginx on 3128).
4. Import / export MongoDB data
The sample env points at a local Mongo. Helpers exist for round-tripping a dev database against the in-cluster pod:
# Export a dump to ./mongo/<timestamp>.dump
yarn db:export
# Restore a dump (pass the local dump path)
yarn db:import ./mongo/2024-01-01.12-00-00.dump
5. API CLI
The API ships a command runner for data import/parsing work (e.g. parse:files, parse:courts):
(cd causelist-api && yarn cli --help) # production build
(cd causelist-api && yarn cli:dev --help) # via ts-node
The .vscode/launch.json includes ready-made debug configurations for parse:path and parse:courts.
Tests
# causelist-api
(cd causelist-api && yarn test) # unit tests
(cd causelist-api && yarn test:e2e) # e2e tests
(cd causelist-api && yarn test:parsing) # parser-focused tests
Building & Deploying
Docker images are built by the GitHub Actions workflow whenever a tag is pushed, then pushed to GHCR (ghcr.io/zaro/causelist-app, -api, kenyalaw-crawler).
Deploy to a cluster via the included Helm chart:
helm install causelist-stack ./helm -f values-tilt.yaml
See helm/values.yaml and values-tilt.yaml for the available configuration (images, ingress hosts, and API env such as MONGO_URL, REDIS_URL, S3_*, JWT_SECRET, payment gateway credentials, etc.).
Configuration
Environment variables are documented in .env.sample. Notable groups:
| Group |
Purpose |
S3_* |
Object storage access (crawler bucket, endpoint, region) |
MANTICORE_BASE_PATH / MEILI_HOST / MEILI_API_KEY |
Search backends |
SMTP_* |
Outbound email (Mailhog in dev) |
IPAY_AFRICA_* / K2_* / MPESA_* |
Payment gateways (live mode off in dev) |
MONGO_URL / REDIS_URL / PROXY_URL |
Core infra connectivity |
License
All code in this repository is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0). See LICENSE.txt.