How dev-denish/platform works
Purpose and Runtime
dMRV is a Phase-1 land-use, forestry, and carbon-project monitoring platform that ingests satellite/geospatial data, runs analyses, renders map layers, and produces reports. It runs as a FastAPI modular monolith plus a React/Vite frontend served by nginx. Container orchestration is Docker Compose: deploy/docker-compose.yml.
Entry Points and Delivery
The API application factory owns lifecycle, middleware, error handling, and router registration in backend/app/main.py; the production ASGI entry point is backend/app/asgi.py. The SPA starts at frontend/src/main.jsx and composes routes/application state through frontend/src/App.jsx. Docker images are defined by backend/Dockerfile and frontend/Dockerfile.
Versioned API and Internal Boundaries
HTTP endpoints are grouped under a v1 router, including auth, projects, datasets, layers, analyses, jobs, reports, tile delivery, and WMS/external layers: backend/app/api/v1/router.py, backend/app/api/v1/analyses.py, backend/app/api/v1/tiles.py. Dependency injection and request authorization form the API boundary in backend/app/api/deps.py. The intended flow is API → service orchestration → repository persistence, with typed contracts and policy concepts in backend/app/domain/dtos.py and backend/app/domain/authz.py.
Persistence, Access Control, and Auditing
PostGIS is the material datastore, initialized and versioned through Alembic migrations: backend/migrations/env.py, backend/migrations/versions/0001_initial.py. Repositories isolate parameterized SQL for core aggregates and geospatial records, e.g. backend/app/repositories/projects.py, backend/app/repositories/datasets.py, and backend/app/repositories/vector_layers.py. Authentication, token handling, memberships, permission grants, and project-scoped access are separated into backend/app/services/auth_service.py, backend/app/services/permission_service.py, and backend/app/services/project_access.py.
Geospatial Ingestion and Layer Serving
Dataset ingestion is a bounded raster/vector pipeline that detects and processes COGs, rasters, vectors, and storage concerns: backend/app/services/ingestion/service.py, backend/app/services/ingestion/raster.py, backend/app/services/ingestion/vector.py. Ingested and external/WMS data become map-facing layers through backend/app/services/tile_service.py, backend/app/services/tile_renderer.py, and backend/app/services/wms_service.py. This is the main boundary between geospatial source formats/services and browser-consumable tiles/layer metadata.
Analysis and Background Execution
Analysis configuration/catalog definitions drive service-level Google Earth Engine (GEE) execution: backend/app/domain/analysis_catalog.py, backend/app/services/gee_analysis_service.py, backend/app/services/gee_client.py. Jobs decouple long-running GEE analyses and report generation from request handling: backend/app/services/jobs_service.py, backend/app/workers/arq_worker.py, backend/app/workers/gee_analysis_jobs.py. Redis/ARQ is implied by the queue-worker abstraction; the README specifies a threadpool-now/queue-later evolution boundary.
Frontend Map and Project Workspaces
The authenticated SPA organizes project lifecycle, upload, forest-definition, user, and WMS administration pages: frontend/src/pages/ProjectDetailPage.jsx, frontend/src/pages/UploadPage.jsx, frontend/src/pages/ForestDefinitionPage.jsx. Interactive map composition, draw/measure tools, layer controls, and analysis UI reside in frontend/src/components/ProjectMap.jsx, frontend/src/components/LayersPanel.jsx, and frontend/src/components/AnalysisPanel.jsx. Auth state and route enforcement are client-side boundaries at frontend/src/context/AuthContext.jsx and frontend/src/routes/ProtectedRoute.jsx.
Reporting and External Dependencies
Reports combine calculated content, charts, map images, and PDF rendering in backend/app/services/report_service.py, backend/app/services/report_map_image.py, and backend/app/services/report_pdf.py. Key external integrations are Google Earth Engine for satellite analysis, CDSE ingestion (backend/app/services/cdse_ingestion.py), external layer retrieval, and WMS servers. Operational security, rate limiting, metrics, and structured logging are centralized under backend/app/core/security.py, backend/app/core/ratelimit.py, and backend/app/core/metrics.py.
Main entry points: router.py v1 endpoints · tile_service.py Layer and tile delivery · arq_worker.py ARQ worker · projects.py Geospatial repositories
Components 19
Browser SPA
- React SPA
frontend/src/main.jsx - Project workspace · Project pages compose map, layers, uploads, and analysis controls.
frontend/src/pages/ProjectDetailPage.jsx - Client auth guard
frontend/src/context/AuthContext.jsx
FastAPI monolith
- API application · Owns lifecycle, middleware, errors, and router registration.
backend/app/main.py - v1 endpoints · Exposes auth, projects, datasets, layers, analyses, jobs, reports, tiles, and WMS.
backend/app/api/v1/router.py - Request authorization · Injects request dependencies and enforces authorization.
backend/app/api/deps.py - Domain contracts
backend/app/domain/dtos.py - Identity and project access · Handles tokens, memberships, grants, and project-scoped authorization.
backend/app/services/auth_service.py
Geospatial and jobs
- Dataset ingestion · Detects and processes raster, COG, vector, and storage inputs.
backend/app/services/ingestion/service.py - Layer and tile delivery · Converts ingested and external data into layers and browser tiles.
backend/app/services/tile_service.py - GEE analysis · Executes catalog-driven satellite analyses.
backend/app/services/gee_analysis_service.py - Job orchestration · Decouples long-running analyses and reports from HTTP requests.
backend/app/services/jobs_service.py - ARQ worker
backend/app/workers/arq_worker.py - Report generation · Combines calculated content, charts, map images, and PDFs.
backend/app/services/report_service.py
Persistence
- Geospatial repositories · Isolate parameterized persistence for projects, datasets, and vector layers.
backend/app/repositories/projects.py - PostGIS
backend/migrations/env.py
External services
- Google Earth Engine
- CDSE and WMS sources · Supplies satellite datasets and external map layers.
backend/app/services/cdse_ingestion.py
Other components
- Docker Compose · Deploys frontend, API, datastore, and worker runtime.
deploy/docker-compose.yml
Connections 27
- Docker Compose → React SPA: runs
- Docker Compose → API application: runs
- Docker Compose → ARQ worker: runs
- React SPA → Client auth guard: uses
- React SPA → Project workspace: renders
- Client auth guard → v1 endpoints: authenticated requests
- Project workspace → v1 endpoints: API requests
- Project workspace → Layer and tile delivery: map tiles and metadata
- API application → v1 endpoints: registers
- v1 endpoints → Request authorization: enforces
- Request authorization → Identity and project access: authorizes through
- v1 endpoints → Domain contracts: uses contracts
- v1 endpoints → Dataset ingestion: submits datasets
- v1 endpoints → Layer and tile delivery: serves layers
- v1 endpoints → Job orchestration: queues work
- v1 endpoints → Report generation: requests reports
- Identity and project access → Geospatial repositories: reads and writes access data
- Dataset ingestion → Geospatial repositories: persists geospatial records
- Layer and tile delivery → Geospatial repositories: reads layer metadata
- Geospatial repositories → PostGIS: parameterized SQL
- Dataset ingestion → CDSE and WMS sources: imports from
- Layer and tile delivery → CDSE and WMS sources: retrieves external layers
- Job orchestration → ARQ worker: dispatches
- ARQ worker → GEE analysis: runs analyses
- ARQ worker → Report generation: generates reports
- GEE analysis → Google Earth Engine: executes
- Report generation → Layer and tile delivery: renders map images