How cairnepal/heritagegraph works
1. This is a multi-app monorepo, not a single application. The runtime is split into a Django backend, two Next.js frontends, and supporting infrastructure for identity, database, proxying, documentation, and ontology assets.
2. Public-facing entry point: heritage_graph_landing is a separate Next.js site for the public homepage and narrative content. It uses client-heavy visual components like ThreeCanvas, NetworkVisualization, and a small set of marketing UI components, distinct from the authenticated product UI.
3. Main product UI: heritage_graph_ui is the authenticated Next.js application. It is organized by product area: dashboard, contribute, curation, knowledge browsing, community, notifications, and user/team pages. The app router structure and reusable component library suggest a page-driven UI over API-backed data, with some pages also using static JSON fixtures.
4. Backend API and domain logic: heritage_graph is a Django REST Framework service. Its main domain apps are heritage_data and cidoc_data. heritage_data appears to own the core heritage entities, contribution/review workflows, permissions, signals, serializers, and role setup. cidoc_data likely supports CIDOC-CRM-aligned or ontology-derived data structures.
5. Primary request/response flow: browser requests hit the reverse proxy, then route to the Next.js frontend or Django API depending on hostname/path. The frontend talks to the backend over REST, while the backend also exposes a browsable/admin interface and OpenAPI docs. This means the architecture has a clear UI/API boundary.
6. Authentication boundary: authentication is OIDC-based and centered on Keycloak. The frontend uses NextAuth-style routes and session handling, while the backend contains auth helpers and token verification logic. The repo includes custom Keycloak themes, so auth is not just external plumbing; it is branded and configured as part of the system.
7. Persistence layer: the operational database is PostgreSQL in the containerized deployment. The backend has migrations, seed/import commands, and CSV fixtures for domain entities such as persons, deities, festivals, monuments, locations, and sources. This indicates the database is the canonical store for structured heritage content and workflow state.
8. Knowledge/ontology layer: the repo also contains a formal schema and RDF/OWL assets (schema.yaml, final_schema.yaml, ontology/Heritage.ttl, doc_schema.owl, generated .owl/.yaml files). This suggests the domain model is ontology-driven, with the backend and UI likely reflecting schema-registry concepts rather than purely ad hoc forms.
9. Graph/RDF artifact boundary: the presence of oxigraph_db and ontology conversion scripts (parse_ontology.py) indicates there is a graph-knowledge representation layer alongside the relational app. Even if not all of it is live runtime, it is architecturally important because it anchors linked-open-data publishing and semantic interoperability.
10. Infrastructure and deployment: Docker Compose is the main orchestration mechanism, with separate compose files for backend, frontend, Keycloak, Postgres, and Traefik. Traefik is the edge router, and the repo includes production variants plus Coolify deployment notes. This means environment topology is designed around multiple internal services rather than a single deployable.
11. Admin and operations surfaces: the backend includes Django admin and management commands such as CSV import, DB seeding, and role setup. These are operational tools for maintaining data and access control, separate from the public contributor/reviewer UI.
12. Documentation is a first-class subsystem: MkDocs content lives in docs/, with a generated published site in site/, plus several repo-level guides for architecture, auth, forms, deployment, conventions, and troubleshooting. The documentation mirrors the system boundaries and is intended to support both engineers and AI agents.
13. Internationalization is built into the product: both backend and frontend have English and Nepali translation assets. The UI and docs are multilingual, so locale routing/content is part of the user-facing architecture, not an afterthought.
Main entry points: heritage_graph Django API · heritage_graph_ui Product UI · docker-compose.yml Compose · docs Docs source
Components 21
Infrastructure
Deployment, routing, and service orchestration.
Frontends
Public and authenticated Next.js applications.
- Landing site · Public-facing homepage and narrative content.
heritage_graph_landing - Visuals · Hero and graph-like marketing visuals used on the public site.
heritage_graph_landing/app/components - Site shell · Global layout and main landing page entry points.
heritage_graph_landing/app - Product UI · Authenticated application for dashboard, contribution, curation, and knowledge browsing.
heritage_graph_ui - App routes · Route tree for dashboard areas, auth, and content flows.
heritage_graph_ui/src/app - UI kit · Reusable product components, tables, forms, and navigation.
heritage_graph_ui/src/components - Localization · Locale routing, message catalogs, and translation hooks.
heritage_graph_ui/src/i18n
Backend
Django API, domain apps, and operational commands.
- Django API · Main backend service exposing REST, admin, and browsable API surfaces.
heritage_graph - API surface · Project URL routing and service entrypoints.
heritage_graph/urls.py - Heritage data · Core heritage entities, contribution workflow, permissions, serializers, and role setup.
heritage_graph/apps/heritage_data - CIDOC data · CIDOC-CRM-aligned or ontology-derived backend data structures and views.
heritage_graph/apps/cidoc_data - Ops commands · Import, seed, and role provisioning commands for maintaining data and access.
heritage_graph/apps/heritage_data/management/commands
Identity
OIDC authentication and Keycloak theming.
Knowledge
Ontology, schema, and graph data assets.
Docs
Documentation sources and generated site.
- Docs source · MkDocs and documentation sources for architecture, auth, deployment, forms, and translation.
docs - Published docs · Built documentation site and static API reference output.
site
Connections 29
- Compose → Traefik: deploys · Compose defines the edge router service.
- Compose → Landing site: starts · Compose includes the public Next.js site.
- Compose → Product UI: starts · Compose includes the authenticated Next.js app.
- Compose → Django API: starts · Compose includes the Django backend.
- Compose → Keycloak: starts · Compose includes Keycloak.
- Compose → Graph DB: mounts · Deployment includes the graph store volume.
- Traefik → Landing site: routes · Public traffic is routed to the landing site.
- Traefik → Product UI: routes · Authenticated browser traffic is routed to the product UI.
- Traefik → Django API: routes · API and admin traffic reach the Django service.
- Landing site → Site shell: contains · Landing app shell and page entrypoints.
- Landing site → Visuals: contains · Visual storytelling and hero components.
- Product UI → App routes: contains · App router defines the product area pages.
- Product UI → UI kit: uses · Pages compose shared UI components and widgets.
- Product UI → Localization: uses · Locale-aware routing and messages power translations.
- Product UI → Django API: calls · The frontend consumes backend APIs over REST.
- Product UI → Keycloak: authenticates · Login and session handling rely on OIDC.
- Django API → API surface: exposes · Project URL routing exposes API and admin surfaces.
- Django API → Heritage data: contains · Core heritage domain app.
- Django API → CIDOC data: contains · CIDOC-aligned domain app.
- Django API → Ops commands: administers · Management commands support importing and role setup.
- Django API → Keycloak: verifies · Backend auth helpers verify identity tokens and sessions.
- Django API → Schemas: aligns to · Backend domain models reflect formal schema artifacts.
- Schemas → Ontology: derives · Schema and OWL assets are part of the semantic model.
- Ontology → Graph DB: loads into · Ontology/graph artifacts are persisted in the RDF store.
- Keycloak → Themes: brands · Custom themes shape login and account experience.
- Docs source → Published docs: builds · Docs sources are published as the generated site.
- Docs source → Schemas: documents · Documentation explains the ontology and forms model.
- Docs source → Product UI: documents · Docs cover product workflows and UI behavior.
- Docs source → Django API: documents · Docs cover backend architecture and authentication.