Database Schema & Data Models
Netgoat uses MongoDB as its primary persistent storage system for Control Plane and Admin functions. Because our system requires near-instant read availability mapping complex relational graph data across tenants, Mongoose schemas bridge relational modeling strategies within a document store syntax.
The Edge Data Store (DuckValue) is wholly separate—it does not interact with this schema list.
Core Collections
1. Teams & Users
At the root of the hierarchy are Teams. A User inherently belongs to one or more Teams, serving as our primary mechanism for multi-tenant isolation.
UserSchema stores identity, authentication tokens, and referencesteamsarray ([ObjectID]).Teamis the ultimate boundary. All domains, DNS records, and alerts belong completely to aTeam.
2. Domain & DNS Ecosystem
DomainCollection: The central entity representing a managed hostname (e.g.,api.example.com). It tracks TLS lifecycle (Pending, Active, Expired), ownership flags, and global traffic routing rules (WAF status).DNSRecordCollection: Children to a singleDomain. Represents A, AAAA, CNAME, or MX records.- Linking: Maintains a direct
domainId(ObjectId, ref:'Domain'). A query for a zone involves matching allDNSRecordinstances pointing to a specificdomainId.
- Linking: Maintains a direct
3. Proxy Configurations
ProxyConfigCollection: Stores complex WAF rules, caching strictness, edge-function injects, and custom rate limits natively.- Linking: Every configure matches a specific
domainId. When the Edge Node connects via WebSocket, the Control Plane performs an aggregate lookup ofDomain+ its activeProxyConfigand broadcasts the merged model down the wire.
- Linking: Every configure matches a specific
4. Observability & Reporting
Alert&IncidentCollections: Handle uptime tracking and system anomalies. When an edge node reports a 502 Bad Gateway streak, anIncidentis created here, referencing the affectedDomain.AnalyticsData: Time-series log records representing traffic volume (aggregated into minutes or hour chunks) assigned to a specificdomainId.
Entity Relationship Summary
The central pillar dictating schema design is the Team.
graph TD
User -->|Belongs To| Team
Team -->|Owns Many| Domain
Domain -->|Contains Many| DNSRecord
Domain -->|Has One| ProxyConfig
Domain -->|Has Many| Alert
Because MongoDB doesn't enforce strict joins, application logic within the Control Plane leverages standard .populate() or explicit reference queries to map DNSRecords into a single JSON payload for Edge push synchronization.