Skip to main content

ZiWound — Overview

This is a complete, step-by-step case study of ZiWound — a real, production-grade war crimes documentation platform built entirely on Lesan. It is the largest real-world Lesan application you can study outside this repo: 13 models, 98 acts, JWT authentication with role-based access control, GeoJSON geospatial search, full-text search, 9-language internationalization, file uploads, and a Next.js frontend.

ZiWound is open source. The entire codebase lives at github.com/hemedani/ziwound, so every page in this series links to the real source file instead of reproducing it here.

note

Not a beginner tutorial You should already know the basics from Getting Started and the country/city/user tutorials. This series is an advanced case study — it assumes you know newModel, setAct, insertOne, findOneAndUpdate, relations, and projections.

What the app does

ZiWound documents war crimes. Users submit reports (with geolocation, file attachments, tags, categories, and references to accused war criminals), explore documented incidents through interactive maps, read blog articles, and admins manage everything from a dashboard.

user ── submits ──> report ──┬── reporter (User)
├── documents (Document[] ── documentFiles)
├── tags (Tag[]) / category (Category)
├── hostileCountries / attackedCountries (Country[])
├── attackedProvinces / attackedCities (Province[]/City[])
└── warCriminals (WarCriminal[])

├── country ── province ── city (geographic hierarchy)
├── blogPost (author, coverImage, tags)
├── heroSlide (landing page slider)
└── confirmation (email/account verification)

The 13 models

ModelPurposePage
userauthentication, roles, profileThe User Model
fileuploads (images, videos, documents)The File Model
countrycountries with localized war historyLocation Models
provinceprovinces with war historyLocation Models
citycities with war history + capital relationsLocation Models
categorycategorization (shared pattern)Catalog Models
tagmetadata tagging (shared pattern)Catalog Models
reportthe core war crime reportThe Report Model
documentsupporting documents for reportsThe Document Model
blogPostarticles with publish workflowContent Models
heroSlidelanding-page sliderContent Models
warCriminalaccused individuals/entitiesThe War Criminal Model
confirmationemail/account confirmationThe Confirmation Model

What makes ZiWound a great Lesan case study

  • 13 real models with deep relation graphs — reports link to reporters, documents, tags, categories, countries, provinces, cities, and war criminals, all with Lesan's automatic reverse-relation syncing.
  • 98 production acts — the full CRUD surface plus login/register/getMe, publish/unpublish, getBySlug, getRelated, statistics, CSV/PDF export, uploads, and dashboard statistics.
  • Auth as a preAct chainsetTokens → setUser → grantAccess(...) on protected acts, proving how Lesan's request hooks handle real authorization.
  • Localization done two wayslocalizedWarInfo (nested {fa,en,ar,...} objects) vs selected_language (per-record language filter). ZiWound shows exactly when to use each.
  • Search & geospatial — MongoDB text indexes and 2dsphere GeoJSON queries power real search and map exploration.
  • Generated typestypeGeneration: true writes declarations/selectInp.ts, which the Next.js frontend consumes directly.

Chapter guide

  1. Project Layout — the repo structure (back/ Deno + Lesan, front/ Next.js) and how mod.ts wires everything together.
  2. The Models — one page per model (or logical group): pure fields, relations, back-references, and indexes, with links to the real source.
  3. Lesan Patterns — the reusable lessons ZiWound teaches: the auth chain, localization, search & indexes, geospatial queries, file uploads, and act structure.

Every page links to the exact file in github.com/hemedani/ziwound — open it side by side as you read.

Run it

ZiWound is a real production app. To run it locally, clone the repo and follow its README:

git clone https://github.com/hemedani/ziwound.git
cd ziwound

# Backend (Deno + Lesan)
cd back
deno task bc-dev # starts the Lesan server (MongoDB required)

# Frontend (Next.js)
cd front
pnpm install
pnpm dev
  • Playground: http://localhost:1406/playground (development mode)
  • Static uploads: served under /uploads
  • Generated types: declarations/selectInp.ts written on boot (typeGeneration: true)

Next: Project Layout.