Glossary: treetracker-admin-api
Generated by .github/scripts/build-glossary.mjs from domain-graph.json (source commit 1f25d3e). Do not edit by hand.
This glossary lists the business terms of treetracker-admin-api. Each term links to its domain, which says what the domain does, its rules, and its flows. The estate glossary shows which other repos use the same terms.
Terms
- AdminRole: Identity & Access Control
- AdminUser: Identity & Access Control
- AuditRecord: Identity & Access Control
- DomainEvent: Capture Verification
- Organization: Organization Management
- Planter: Grower Management
- PlanterRegistration: Grower Management
- Policy: Identity & Access Control
- Species: Capture Verification, Species & Tag Catalog
- Tag: Species & Tag Catalog
- Trees (capture): Capture Verification
- TreeTag: Capture Verification, Species & Tag Catalog
Domains
Capture Verification
The core domain. It manages tree-capture records collected by the Treetracker mobile app and lets admins browse, search, and verify them. A verify action approves or rejects a capture, records a domain event, and publishes the outcome to downstream services over RabbitMQ.
Terms: Trees (capture), DomainEvent, TreeTag, Species
Rules:
- A verification event is raised only when approval changes or an active capture is rejected (not approved and not active while previously active).
- The capture update, the domain event insert, and the commit run inside one READ_COMMITTED transaction; any failure rolls back the whole change.
- The domain event is marked 'sent' only after the RabbitMQ publish succeeds (outbox pattern).
- Event publishing is gated by the enableVerificationPublishing feature flag.
Flows:
- Browse and Search Captures (
GET /trees): Lists, counts, looks up, and geospatially searches tree captures using LoopBack filters translated to parameterized SQL. - Verify, Approve, or Reject Capture (
PATCH /trees/{id}): Updates a capture in a transaction, raises a VerifyCaptureProcessed domain event when the verification state changes, and publishes it to RabbitMQ using an outbox pattern. - Manage Tree Tags (
POST /trees/{id}/tree-tags): Associates tags with captures, lists a capture's tags, and removes tag associations through the trees relation accessor.
Grower Management
Manages planters (growers), the people who collect captures in the field, and their registration records. It exposes organization-scoped listing, lookup, selfie retrieval, and profile updates over raw parameterized SQL.
Terms: Planter, PlanterRegistration
Rules:
- Grower queries are filtered by the caller's organization scope when an organization id is present.
- Organization-scoped planter access checks the requested entity id against the caller's allowed entity ids.
Flows:
- Browse and Find Growers (
GET /planters): Counts and lists growers within the caller's organization scope, looks them up by id, and returns their selfies. - Update Grower Profile (
PATCH /planters/{id}): Updates a grower record after checking the caller's authorization and organization-scoped access to the entity. - Query Planter Registrations (
GET /planterRegistrations): Finds planter-registration records with filtered SQL, enforcing entity-id access checks in the organization-scoped variant.
Organization Management
Manages stakeholder organizations and provides the organization-scoping mechanism that other domains reuse for access control. It resolves the set of entity ids under an organization and builds the where clauses that restrict data to that scope.
Terms: Organization
Rules:
- An organization resolves to a set of entity ids that define its data scope.
- Queries for scoped resources receive an organization-derived where clause before execution.
Flows:
- Browse Organizations (
GET /organizations): Counts and lists organizations, finds them by parent organization, and looks them up by id. - Resolve Organization Scope (
OrganizationRepository.getEntityIdsByOrganizationId): Resolves the entity ids belonging to an organization and builds the organization-scoped where clause that other domains apply to their queries.
Identity & Access Control
Handles admin authentication, role-and-policy authorization, and audit logging. Login issues a JWT carrying the user roles; the isAuth middleware enforces policy-based permissions per route; the audit middleware records every successful auditable action.
Terms: AdminUser, AdminRole, Policy, AuditRecord
Rules:
- Passwords are verified against a stored hash before a JWT is issued.
- A composite policy object is built from the union of a user's roles.
- Each API route pattern maps to a named permission that isAuth must satisfy.
- User roles are refreshed on each request and the JWT is re-signed when they change.
Flows:
- Admin Login (
POST /auth/login): Authenticates an admin by username and password, loads roles and policy, and issues a signed JWT. - Authorize Request (
isAuth middleware): The isAuth middleware verifies the JWT, refreshes user roles, matches the route to a named permission, and allows or denies the request. - Audit Action (
audit middleware): The audit middleware decodes the JWT, inspects the response outcome, and persists a record of each successful auditable action. - Manage Admin Users (
POST /auth/admin_users): Creates admin users, updates their roles, changes passwords, and lists users.
Species & Tag Catalog
Maintains the reference catalog of tree species and the tags applied to captures. It supports full CRUD, capture-count aggregation per species, and merging duplicate species into one.
Terms: Species, Tag, TreeTag
Rules:
- Species mutations require policy-based authorization.
- Combining species reassigns captures from the merged species to the surviving species.
- Tags carry active and public flags that govern visibility.
Flows:
- Manage Species (
GET /species): Provides species CRUD plus capture-count aggregation and merging of duplicate species, all under policy-based authorization. - Manage Tags (
GET /tags): Provides full CRUD over the tag catalog applied to captures.