Comprehensive guides and references for the OpenFrame platform
The Data Mongo Core And Documents module defines the MongoDB configuration, core domain documents, and foundational persistence behavior for the OpenFrame platform. It acts as the primary document model layer for authentication, organizations, devices, events, OAuth, tags, and tenant-specific configuration.
This module is the backbone of all Mongo-backed services including:
It provides:
At a high level, this module sits beneath service-layer modules and exposes document models used by repositories and domain services.
flowchart TD
ApiService["API Service"] --> Repositories["Mongo Repositories"]
AuthServer["Authorization Server"] --> Repositories
ExternalApi["External API Service"] --> Repositories
Repositories --> Documents["Domain Documents"]
Documents --> MongoConfig["Mongo Configuration"]
MongoConfig --> MongoDB[("MongoDB")]
Key Responsibilities:
@CreatedDate, @LastModifiedDate)MongoConfig enables repository scanning and auditing.
It contains two nested configurations:
Activated when:
spring.data.mongodb.enabled=true
Responsibilities:
@EnableMongoRepositories@EnableMongoAuditingMappingMongoConverter__dot__flowchart LR
MongoConfiguration["MongoConfiguration"] --> Converter["MappingMongoConverter"]
Converter --> CustomConversions["MongoCustomConversions"]
Converter --> DbRefResolver["DefaultDbRefResolver"]
The dot replacement ensures Mongo compatibility when map keys contain ..
Activated for reactive web applications.
@EnableReactiveMongoRepositoriescom.openframe.data.reactive.repositoryThis supports WebFlux-based services such as reactive APIs and streaming integrations.
MongoIndexConfig ensures runtime index creation for critical collections.
flowchart TD
Events["application_events"] --> Idx1["userId ASC"]
Idx1 --> Idx2["timestamp DESC"]
Events --> Idx3["type ASC"]
Idx3 --> Idx4["metadata.tags ASC"]
These indexes optimize:
This module defines all Mongo document models used across the platform.
Collection: users
Fields include:
email (normalized to lowercase)rolesemailVerifiedstatusAutomatic auditing is enabled via @CreatedDate and @LastModifiedDate.
Extends User and adds:
tenantIdpasswordHashloginProviderexternalUserIdlastLoginflowchart LR
AuthUser["AuthUser"] --> TenantEmail["tenantId + email (unique)"]
A compound index enforces:
{ tenantId: 1, email: 1 } unique
This allows:
Collection: organizations
Represents a company or managed entity.
Key features:
organizationIddeleted, deletedAt)flowchart TD
Active["deleted = false"] --> Deleted["deleted = true"]
Deleted --> DeletedAt["deletedAt timestamp set"]
No hard deletes are required for logical removal.
Collection: devices
Models managed hardware:
machineIdserialNumberstatus (ACTIVE, OFFLINE, MAINTENANCE)typelastCheckinconfigurationhealthCollection: tags
namecolororganizationIdCollection: machine_tags
Compound index:
{ machineId: 1, tagId: 1 } unique
flowchart LR
Device["Device"] --> MachineTag
Tag["Tag"] --> MachineTag
This allows devices to have multiple tags without duplication.
Collection: events
Tracks internal system events.
Fields:
typepayloadtimestampuserIdstatus (CREATED, PROCESSING, COMPLETED, FAILED)Collection: external_application_events
Adds structured metadata:
sourceversiontags (map)Optimized via runtime indexes from MongoIndexConfig.
Collection: oauth_registered_clients
Used by Authorization Server.
clientIdCollection: oauth_tokens
Stores:
accessTokenrefreshTokenclientIdscopesflowchart LR
User --> OAuthToken
MongoRegisteredClient --> OAuthToken
Extends base SSO configuration and adds:
tenantIdThis enables:
Embedded configuration model for:
Used for distributing tool/agent binaries and configurations.
Enabled via @EnableMongoAuditing.
Documents supporting auditing:
This ensures consistent lifecycle tracking.
Multi-tenancy is implemented at document level via:
tenantId fieldsflowchart TD
Tenant["Tenant Context"] --> AuthUser
Tenant --> SSOPerTenantConfig
Tenant --> Organization
Isolation is achieved without separate databases.
Implemented via:
Avoids physical data removal and enables audit recovery.
flowchart TD
Users[("users")]
AuthUsers[("auth_users")]
Organizations[("organizations")]
Devices[("devices")]
Tags[("tags")]
MachineTags[("machine_tags")]
Events[("events")]
ExternalEvents[("external_application_events")]
OAuthClients[("oauth_registered_clients")]
OAuthTokens[("oauth_tokens")]
The Data Mongo Core And Documents module provides:
Without this module, higher-level services would lack:
The Data Mongo Core And Documents module is the foundational MongoDB modeling layer for OpenFrame. It standardizes document structures, enforces multi-tenant constraints, configures indexing and auditing, and supports both blocking and reactive repository patterns.
It ensures that all services across the platform share a consistent, performant, and secure persistence model built on MongoDB.