-
Notifications
You must be signed in to change notification settings - Fork 4
Data Model Overview.md
Kelsey Smuczynski edited this page Mar 24, 2026
·
1 revision
The codebase centers on this field-data chain:
Location → Thing → FieldEvent → FieldActivity → Sample → Observation
| Model | Description |
|---|---|
Location |
A geographic point (Lat/Lon in WGS84) and site metadata |
Thing |
A physical monitored feature at a location (e.g., a well, spring, or sensor); holds construction metadata |
FieldEvent |
A single site visit on a specific date by field personnel |
FieldActivity |
A specific task performed during a field event (e.g., manual water level measurement) |
Sample |
A physical or digital "slice" of data collected during an activity |
Observation |
The actual measured value or result (e.g., pH=7.2, depth=15.4m); links to a Parameter
|
-
Contact,Phone,Email,Address -
GroupandGroupThingAssociation -
AssetandAssetThingAssociation -
SensorandDeployment -
ParameterandAnalysisMethod -
LexiconCategory,LexiconTerm,LexiconTriple
Several models use mixins or related tables for shared metadata:
- Release status (
ReleaseMixin) - Audit fields
- Notes
- Data provenance (
DataProvenanceMixin) - Permission history
- Status history
Thing and Location are especially important aggregation points.
Thing contains many well-specific attributes, including:
- depth, casing, pump, completion, formation zone
- location history, contacts, field events, deployments
- groups, screens, measuring point history, monitoring frequency history
The database includes a large family of legacy-oriented models in db/nma_legacy.py. These are still actively used by the transfer pipeline and admin interface:
- Chemistry sample info
- Field parameters and hydraulics
- Soil/rock results and stratigraphy
- Surface water data and photos
- Weather data and photos
- Radionuclides, major/minor/trace chemistry
- Pressure-daily water levels
- NGWMN legacy views
When a core model changes, you typically need to update all of:
-
db/model definitions - Corresponding
schemas/ - Alembic migrations
- Tests
- Transfer logic (if the field participates in legacy migration)
The repo contains generated ERD artifacts at the project root:
schema_erd.dotschema_erd.pngschema_erd.svg
Regenerate with: python scripts/generate_erd.py
| System | Role |
|---|---|
| PostgreSQL + PostGIS | Primary data store with spatial extensions |
| Authentik | OIDC/OAuth2 provider for Admin interface and API auth |
| pygeoapi | OGC API exposure at /ogcapi
|
| Google App Engine | Primary hosting environment |
| Google Cloud SQL | Managed PostgreSQL in production |
| Google Cloud Storage | Database backups, restore artifacts, transfer metrics/logs |
| GitHub Actions | CI/CD pipeline for staging and production deployments |
| Apitally | API traffic analytics and monitoring |
| Sentry | Error tracking and release management |
| ArcGIS Feature Service | Project-area boundary import |
-
Legacy NM_Aquifer transfers —
transfers/pipeline migrates historical data into the new schema - CLI and API bulk CSV uploads — ongoing data loads for well inventory and water level records; see CSV Ingestion and Validation
-
Derived geospatial views — materialized views for pygeoapi (
ogc_*resources) -
Post-Alembic data migrations — corrective or transitional data changes tracked in
data_migration_history