How jasperfx/marten works
Marten is a .NET document database and event store backed by PostgreSQL. The main user workflow is to open a session, store or query documents, and commit or receive results; event-stream operations and projections provide a parallel event-sourcing workflow. The graph also shows query-handler and storage internals evidenced by sampled source. README capabilities such as async projections, subscriptions, and tenancy are included at subsystem level; their implementation wiring was not sampled, so those links are intentionally limited.
Main entry points: LinqQueryParser.Handlers.cs LINQ parsing · Marten Sessions and store · DocumentSessionBase.ProjectionStorage.cs Document operations · QueryOnlyClosedShapeStorage.cs Closed-shape storage
Components 20
Document database
- Sessions and store
src/Marten - Document operations
src/Marten/Internal/Sessions/DocumentSessionBase.ProjectionStorage.cs - Document metadata
src/Marten/Storage/Metadata/EntityMetadataQueryHandler.cs - Native patching
src/Marten - Multi-tenancy
src/Marten
Event sourcing
- Event store
src/Marten/Events/Querying/SingleEventQueryHandler.cs - Stream state
src/Marten/EventStorage/Querying/ClosedShapeStreamStateQueryHandler.cs - Event projections
src/Marten - Async daemon
src/Marten - Subscriptions
src/Marten
Query execution
- LINQ parsing
src/Marten/Linq/Parsing/LinqQueryParser.Handlers.cs - Advanced SQL
src/Marten/Linq/QueryHandlers/AdvancedSqlQueryHandler.cs - Include handling
src/Marten/Linq/Includes/IncludeQueryHandler.cs - Compiled queries
src/Marten/Internal/CompiledQueries/CompiledQueryHandlerDescriptor.cs
Storage runtime
- Read-only storage
src/Marten/Internal/Storage/QueryOnlyDocumentStorage.cs - Closed-shape storage
src/Marten/Internal/ClosedShape/QueryOnlyClosedShapeStorage.cs - Projection storage
src/Marten/Internal/Sessions/DocumentSessionBase.ProjectionStorage.cs - Single-event query
src/Marten/Events/Querying/SingleEventQueryHandler.cs
Other components
- Application code
- PostgreSQL
Connections 23
- Application code → Sessions and store: opens session
- Sessions and store → Document operations: queues operations
- Document operations → PostgreSQL: persists documents
- Sessions and store → LINQ parsing: builds queries
- LINQ parsing → Include handling: wraps handler
- LINQ parsing → Advanced SQL: builds handler
- Include handling → LINQ parsing: delegates results
- Advanced SQL → PostgreSQL: executes SQL
- Document metadata → PostgreSQL: reads metadata
- Read-only storage → PostgreSQL: loads documents
- Closed-shape storage → Read-only storage: specializes storage
- Closed-shape storage → Sessions and store: builds selector
- Projection storage → Document operations: queues writes
- Application code → Event store: queries events
- Event store → PostgreSQL: reads event
- Application code → Stream state: requests stream state
- Stream state → PostgreSQL: queries stream
- Compiled queries → LINQ parsing: binds query parameters
- Event projections → Async daemon: processed by
- Async daemon → PostgreSQL: reads and writes
- Subscriptions → Async daemon: processed by
- Native patching → PostgreSQL: updates documents
- Multi-tenancy → PostgreSQL: scopes storage