# yuebo119/palorm architecture

> Architecture diagram of the GitHub repository yuebo119/palorm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yuebo119/palorm
- Repository: https://github.com/yuebo119/palorm

## Overview

PalORM is a Native-AOT-oriented .NET micro-ORM. Its main workflow starts with an application defining entities and queries; the Roslyn generator validates entities and emits mapping, command, and migration code at compile time. At runtime, a DataSession and query executor use a selected database provider to perform CRUD, queries, and bulk operations. Separate documented capabilities include resilience, caching, auditing, and schema scaffolding. Edges follow the sampled calls or README descriptions; unsampled internals are represented only where the README documents their role.

Main entry points: [`src/PalORM.Core/DataSession.cs`](https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/DataSession.cs) (Data session), [`src/PalORM.SourceGen/PalORMGenerator.cs`](https://github.com/yuebo119/palorm/blob/main/src/PalORM.SourceGen/PalORMGenerator.cs) (Incremental generator), [`src/PalORM.Core/QueryBuilder.cs`](https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/QueryBuilder.cs) (Query builder), [`src/PalORM.Core/DataSession_Bulk.cs`](https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/DataSession_Bulk.cs) (Bulk operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_generation["Compile-time generation"]
  node_analyzer["Compile diagnostics<br/>[PalORMAnalyzer.cs]"]
  node_model["Table model<br/>[TableModel.cs]"]
  node_generator["Incremental generator<br/>[PalORMGenerator.cs]"]
  node_commands["Command generation"]
  node_rows["Row mapping"]
  node_migrations["Migration DDL"]
end

subgraph group_runtime["ORM runtime"]
  node_session["Data session<br/>[DataSession.cs]"]
  node_options["Session options<br/>[DbOptions.cs]"]
  node_querybuilder["Query builder<br/>[QueryBuilder.cs]"]
  node_queryexec["Query execution"]
  node_crud["CRUD operations"]
  node_bulk["Bulk operations"]
  node_metadata["CRUD metadata<br/>[CrudMetadata.cs]"]
  node_resilience["Retry and breaker<br/>[Resilience.cs]"]
  node_cache[("Query cache")]
  node_audit["Audit interception"]
end

subgraph group_providers["Database providers"]
  node_pg["PostgreSQL provider"]
  node_mysql["MySQL provider<br/>[MySqlProvider.cs]"]
  node_sqlite["SQLite provider<br/>[SqliteProvider.cs]"]
end

subgraph group_schema["Schema tooling"]
  node_scaffold["Entity scaffolding<br/>[EntityGenerator.cs]"]
  node_schema_provider["Schema providers<br/>[ISchemaProvider.cs]"]
end

node_application(("Application"))
node_entity["Entity models"]
node_database[("Database")]

node_application -->|"defines"| node_entity
node_entity -->|"diagnosed by"| node_analyzer
node_entity -->|"processed at compile time"| node_generator
node_generator -->|"builds model"| node_model
node_generator -->|"emits commands"| node_commands
node_generator -->|"emits mappings"| node_rows
node_generator -->|"emits DDL"| node_migrations
node_application -->|"creates session"| node_session
node_session -->|"uses configuration"| node_options
node_application -->|"builds query"| node_querybuilder
node_querybuilder -->|"executes via"| node_queryexec
node_session -->|"provides operations"| node_crud
node_session -->|"provides bulk API"| node_bulk
node_bulk -->|"uses metadata"| node_metadata
node_queryexec -.->|"runs SQL"| node_database
node_crud -.->|"reads and writes"| node_database
node_bulk -.->|"bulk writes"| node_database
node_session -->|"selects provider"| node_pg
node_session -->|"selects provider"| node_mysql
node_session -->|"selects provider"| node_sqlite
node_pg -.->|"connects to"| node_database
node_mysql -.->|"connects to"| node_database
node_sqlite -.->|"connects to"| node_database
node_session -->|"runs resilient reads"| node_resilience
node_querybuilder -->|"supports query cache"| node_cache
node_session -->|"supports auditing"| node_audit
node_application -->|"generates entities"| node_scaffold
node_scaffold -->|"uses schema provider"| node_schema_provider
node_schema_provider -.->|"reads schema"| node_database

click node_analyzer "https://github.com/yuebo119/palorm/blob/main/src/PalORM.SourceGen/PalORMAnalyzer.cs"
click node_model "https://github.com/yuebo119/palorm/blob/main/src/PalORM.SourceGen/TableModel.cs"
click node_generator "https://github.com/yuebo119/palorm/blob/main/src/PalORM.SourceGen/PalORMGenerator.cs"
click node_commands "https://github.com/yuebo119/palorm/blob/main/src/PalORM.SourceGen/CommandFactoryEmitter.cs"
click node_rows "https://github.com/yuebo119/palorm/blob/main/src/PalORM.SourceGen/RowFactoryEmitter.cs"
click node_migrations "https://github.com/yuebo119/palorm/blob/main/src/PalORM.SourceGen/MigrationEmitter.cs"
click node_session "https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/DataSession.cs"
click node_options "https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/DbOptions.cs"
click node_querybuilder "https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/QueryBuilder.cs"
click node_queryexec "https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/QueryBuilderExtensions.cs"
click node_crud "https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/DataSession.Crud.cs"
click node_bulk "https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/DataSession_Bulk.cs"
click node_metadata "https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/CrudMetadata.cs"
click node_resilience "https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/Resilience.cs"
click node_cache "https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/DataSessionCache.cs"
click node_audit "https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/AuditInterceptor.cs"
click node_pg "https://github.com/yuebo119/palorm/blob/main/src/PalORM.PostgreSql/PostgreSqlProvider.cs"
click node_mysql "https://github.com/yuebo119/palorm/blob/main/src/PalORM.MySql/MySqlProvider.cs"
click node_sqlite "https://github.com/yuebo119/palorm/blob/main/src/PalORM.Sqlite/SqliteProvider.cs"
click node_scaffold "https://github.com/yuebo119/palorm/blob/main/tools/PalORM.Scaffold/EntityGenerator.cs"
click node_schema_provider "https://github.com/yuebo119/palorm/blob/main/tools/PalORM.Scaffold/ISchemaProvider.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_analyzer,node_model,node_generator,node_commands,node_rows,node_migrations toneBlue
class node_session,node_options,node_querybuilder,node_queryexec,node_crud,node_bulk,node_metadata,node_resilience,node_cache,node_audit,node_database toneAmber
class node_pg,node_mysql,node_sqlite toneMint
class node_scaffold,node_schema_provider toneRose
class node_application,node_entity toneIndigo
```

## Components

### Compile-time generation

- [Compile diagnostics](https://github.com/yuebo119/palorm/blob/main/src/PalORM.SourceGen/PalORMAnalyzer.cs): `src/PalORM.SourceGen/PalORMAnalyzer.cs`
- [Table model](https://github.com/yuebo119/palorm/blob/main/src/PalORM.SourceGen/TableModel.cs): `src/PalORM.SourceGen/TableModel.cs`
- [Incremental generator](https://github.com/yuebo119/palorm/blob/main/src/PalORM.SourceGen/PalORMGenerator.cs): `src/PalORM.SourceGen/PalORMGenerator.cs`
- [Command generation](https://github.com/yuebo119/palorm/blob/main/src/PalORM.SourceGen/CommandFactoryEmitter.cs): `src/PalORM.SourceGen/CommandFactoryEmitter.cs`
- [Row mapping](https://github.com/yuebo119/palorm/blob/main/src/PalORM.SourceGen/RowFactoryEmitter.cs): `src/PalORM.SourceGen/RowFactoryEmitter.cs`
- [Migration DDL](https://github.com/yuebo119/palorm/blob/main/src/PalORM.SourceGen/MigrationEmitter.cs): `src/PalORM.SourceGen/MigrationEmitter.cs`

### ORM runtime

- [Data session](https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/DataSession.cs): `src/PalORM.Core/DataSession.cs`
- [Session options](https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/DbOptions.cs): `src/PalORM.Core/DbOptions.cs`
- [Query builder](https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/QueryBuilder.cs): `src/PalORM.Core/QueryBuilder.cs`
- [Query execution](https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/QueryBuilderExtensions.cs): `src/PalORM.Core/QueryBuilderExtensions.cs`
- [CRUD operations](https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/DataSession.Crud.cs): `src/PalORM.Core/DataSession.Crud.cs`
- [Bulk operations](https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/DataSession_Bulk.cs): `src/PalORM.Core/DataSession_Bulk.cs`
- [CRUD metadata](https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/CrudMetadata.cs): `src/PalORM.Core/CrudMetadata.cs`
- [Retry and breaker](https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/Resilience.cs): `src/PalORM.Core/Resilience.cs`
- [Query cache](https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/DataSessionCache.cs): `src/PalORM.Core/DataSessionCache.cs`
- [Audit interception](https://github.com/yuebo119/palorm/blob/main/src/PalORM.Core/AuditInterceptor.cs): `src/PalORM.Core/AuditInterceptor.cs`

### Database providers

- [PostgreSQL provider](https://github.com/yuebo119/palorm/blob/main/src/PalORM.PostgreSql/PostgreSqlProvider.cs): `src/PalORM.PostgreSql/PostgreSqlProvider.cs`
- [MySQL provider](https://github.com/yuebo119/palorm/blob/main/src/PalORM.MySql/MySqlProvider.cs): `src/PalORM.MySql/MySqlProvider.cs`
- [SQLite provider](https://github.com/yuebo119/palorm/blob/main/src/PalORM.Sqlite/SqliteProvider.cs): `src/PalORM.Sqlite/SqliteProvider.cs`

### Schema tooling

- [Entity scaffolding](https://github.com/yuebo119/palorm/blob/main/tools/PalORM.Scaffold/EntityGenerator.cs): `tools/PalORM.Scaffold/EntityGenerator.cs`
- [Schema providers](https://github.com/yuebo119/palorm/blob/main/tools/PalORM.Scaffold/ISchemaProvider.cs): `tools/PalORM.Scaffold/ISchemaProvider.cs`

### Other components

- **Application**
- **Entity models**
- **Database**

## Connections

- Application → Entity models: defines (evidence: `README.md`)
- Entity models → Compile diagnostics: diagnosed by (evidence: `README.md`)
- Entity models → Incremental generator: processed at compile time (evidence: `README.md`)
- Incremental generator → Table model: builds model (evidence: `src/PalORM.SourceGen/TableModel.cs`)
- Incremental generator → Command generation: emits commands (evidence: `README.md`)
- Incremental generator → Row mapping: emits mappings (evidence: `README.md`)
- Incremental generator → Migration DDL: emits DDL (evidence: `README.md`)
- Application → Data session: creates session (evidence: `README.md`)
- Data session → Session options: uses configuration (evidence: `src/PalORM.Core/DataSession.cs`)
- Application → Query builder: builds query (evidence: `README.md`)
- Query builder → Query execution: executes via (evidence: `src/PalORM.Core/QueryBuilderExtensions.cs`)
- Data session → CRUD operations: provides operations (evidence: `README.md`)
- Data session → Bulk operations: provides bulk API (evidence: `README.md`)
- Bulk operations → CRUD metadata: uses metadata
- Query execution → Database: runs SQL
- CRUD operations → Database: reads and writes
- Bulk operations → Database: bulk writes
- Data session → PostgreSQL provider: selects provider (evidence: `src/PalORM.Core/DataSession.cs`)
- Data session → MySQL provider: selects provider (evidence: `src/PalORM.Core/DataSession.cs`)
- Data session → SQLite provider: selects provider (evidence: `src/PalORM.Core/DataSession.cs`)
- PostgreSQL provider → Database: connects to
- MySQL provider → Database: connects to
- SQLite provider → Database: connects to
- Data session → Retry and breaker: runs resilient reads (evidence: `README.md`)
- Query builder → Query cache: supports query cache (evidence: `README.md`)
- Data session → Audit interception: supports auditing (evidence: `README.md`)
- Application → Entity scaffolding: generates entities (evidence: `README.md`)
- Entity scaffolding → Schema providers: uses schema provider (evidence: `tools/PalORM.Scaffold/Program.cs`)
- Schema providers → Database: reads schema
