The API handles the platform's core domain behavior, access control, validation, audit events, geospatial queries, dashboard summaries, and upload orchestration for both client surfaces.
Auth, Profile, and Password Flows
01Login, current-user bootstrap, forgot/reset password, forced reset for invited users, profile update, and change password are implemented behind JWT auth and role guards.
- Forced reset flow for invited users
- Password policy consistency across client/server
- Centralized JWT verification middleware
- Zod validation + centralized error handling
Estate Structure Administration
02Portfolio/property/area hierarchy administration is implemented with default role seeding on portfolio creation and naming/index constraints to protect data quality.
- Portfolio-scoped domain model
- Hierarchical property and area management
- Default role seeding on new portfolio
- Naming uniqueness/index constraints
Asset Operations + Audit Trail
03Assets support create/list/detail/update workflows, condition tracking, optional GPS capture, photo uploads, nearby search, and first-class audit events with diffs.
- CREATED / UPDATED / PHOTO_ADDED asset audit events
- Diff-based audit payloads
- GeoJSON location storage + 2dsphere index
- Nearby search endpoint for field workflows
Compliance Operations
04Compliance records capture category/risk/status, review cadence, due dates, and links back to the estate hierarchy or specific assets.
- Risk/status/cadence model
- Due-date and review scheduling support
- Links to property/area/asset
- Dashboard-ready compliance data shape
User, Roles, and Access Control
05GM-only user CRUD, role assignment, primary-role handling, and custom role management for non-system roles support portfolio-scoped administration.
- Role guard middleware
- Primary role handling on user-role assignments
- Custom role create/update (non-system roles)
- Indexing for role and user-role constraints
Dashboards + Operational Summaries
06Dashboard APIs support risk summaries, overdue/compliance insights, attention-needed assets, and recent updates for both web and mobile surfaces.
- Risk and overdue summaries
- Attention-needed asset views
- Recent activity/updates feed shape
- Shared API outputs for both clients
Security + Platform Middleware
07Express 5 middleware stack includes Helmet, CORS, JWT verification, role guards, and centralized validation/runtime error handling.
- Helmet security headers
- CORS handling
- JWT auth middleware
- Centralized validation/runtime error responses
Storage + Upload Integration
08Cloudflare R2 uploads are handled via presigned URL flows from the API, keeping file transfer off the backend server while maintaining authorization control.
- R2 presigned upload flow
- Cloudflare-backed media storage integration
- Upload failure tolerance in UX flows
- Thin service-layer integration pattern