Gerege Template Platform¶
Production · Layer 3 — Platform foundation ·
Repo: template-gerege-mn · open.gerege.mn
The foundation for building digital services. This is not sample code — it is a complete, production-ready, security-hardened, tested platform. Most products in the ecosystem branched from here.
The successor foundation is Gerege Nexus
In 2026-08 the 2nd generation of the platform foundation arrived: Gerege Nexus, a modular monolith with an app store. Instead of forking the template, a new product is now written as a Nexus module — or, for a brand, as a fork of the upstream. The Template remains in production, but if you are starting a new project, look at Gerege Nexus first.
open.gerege.mn is unreachable as of 2026-08-07 — that host now serves the
nexus.gerege.mn certificate, so HTTPS fails on a name mismatch. See the
Domain map.
The core idea¶
No new service should have to solve identity, security, the permission model, auditing and AI again. All of it arrives ready on day one; the developer adds only the logic of their own domain.
You build value, not infrastructure.
What comes ready inside¶
Authentication and sessions¶
- Sign in with eID — QR / deep link / push by national ID number (long-poll session).
- Google OAuth — a secondary link; the first time, eID verification is mandatory.
- JWT access + refresh (rotation); logout invalidates both.
- No passwords, no email/OTP sign-in.
Permissions and organisations¶
- RBAC — dynamic roles plus a permission catalogue; a four-level model
(
superadmin → admin → manager → user). - The super admin is a separate, MFA-protected account — created through an onboarding wizard (invite allow-list → Google → eID → email OTP → TOTP + recovery codes). It is stored in its own table, so one person can be both an eID admin and a Google super admin.
- Organisations and membership — create/search (looked up against the state registry via Gerege Verify), manage members and permissions, all protected per user by RLS.
The service surface¶
- A public-services portal — service catalogue, requests, lookups, notifications, payments, appointments.
- API gateway — admin-managed services / routes / consumers / API keys / policies, plus request telemetry.
- Document signing (PAdES) — through G-Sign.
- Third-party integrations — Google Drive/Meet and Dropbox connections, with tokens stored encrypted using AES-256-GCM. Plus the app's own SFTP storage.
AI¶
- Gemini pipeline — text and voice chat, STT, TTS, live translation.
- Layered system prompt — guardrails built into the code plus scope configured by admins through the database.
- The
search_knowledgetool — grounds answers in real data from the knowledge base.
Security and observability¶
- Strict security headers (CSP, HSTS, COOP/COEP/CORP), a CORS allow-list, rate limiting, HTTP server timeouts.
- Parameterised queries; Postgres RLS plus a boot-time enforceability guard.
- Audit log — hash-chained, append-only.
- OpenTelemetry + Prometheus + Zap.
See Security for the detail.
Structure¶
template-gerege-mn/
├── backend/ # Go · chi (net/http) · pgx (pgxpool) · PostgreSQL · Redis
│ └── docs/ # ARCHITECTURE · DEVELOPMENT · API_CONTRACT · SECURITY (EN/MN)
├── frontend/ # Next.js BFF — proxies from the server side, cookie sessions
└── ios/ # SwiftUI eID client (GeregeSmartID SDK)
The backend follows Clean Architecture — handler → usecase → repository →
domain, with no back-imports. The business core does not import a web
framework.
Origin and licence¶
The backend derives from the open-source
snykk/go-rest-boilerplate (MIT,
Najib Fikri). The HTTP layer was converted from Gin to chi (net/http) and
the data layer from sqlx to pgx (pgxpool, hand-written SQL). Attribution to
the original project is preserved in the AUTHORS file. The project is
MIT-licensed.
Variants¶
| Variant | Stack | Repo |
|---|---|---|
| Gerege Template Platform | Go + Next.js | template-gerege-mn |
| Government Template Platform V3.0 | Go + Next.js | template-dgov-mn |
| Government Template — Node.js edition | Node.js/TS + React | template-dgov-mn-nodejs |
The Node.js variant is a port of the Go one — Express 5 · pg · RLS + React.
Stabilisation is ongoing.
Products branched from here¶
- Gerege Platform — extended, an IdP in its own right
- Developer Portal
- Gerege Wallet
- Ring System · the "Khurdan" platform — the government line
Shared code and autosync — no longer automatic since 2026-08-06
Shared backend capabilities still live in open-gerege-core, and frontend
capabilities in @gerege/ui-core. But the daily git autosync that carried
template changes into the products was stopped fleet-wide on 2026-08-06.
A fix made in the template no longer flows downstream on its own; it has to be
triggered by hand. This holds until the move to Gerege Nexus
completes.
Full documentation¶
The ARCHITECTURE, DEVELOPMENT, API_CONTRACT and SECURITY documents live
in the backend/docs/ directory of the template-gerege-mn repository, in both
MN and EN.