Generated: 2025-10-10 Purpose: Comprehensive dependency analysis of mORMot2 source folders for build planning and architecture understanding
mORMot2 follows a strict layered architecture with 14 source folders organized in 6 dependency layers. The foundation layer (core) has zero dependencies on other mORMot folders, while higher layers build progressively on lower ones. No circular dependencies exist.
- Layer 0 (Foundation): 1 folder (core)
- Layer 1 (System Libraries): 2 folders (lib, crypt)
- Layer 2 (Networking): 1 folder (net)
- Layer 3 (Database): 1 folder (db)
- Layer 4 (ORM/REST): 3 folders (orm, rest, soa)
- Layer 5 (Application): 6 folders (app, ui, script, misc, tools, ddd)
┌─────────────────────────────────────────────────────────────┐
│ Layer 5: Application & Tools │
│ ┌─────┬─────┬────────┬──────┬───────┬──────┐ │
│ │ app │ ui │ script │ misc │ tools │ ddd* │ │
│ └─────┴─────┴────────┴──────┴───────┴──────┘ │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────────┐
│ Layer 4: ORM / REST / SOA │
│ ┌─────┬──────┬─────┐ │
│ │ orm │ rest │ soa │ │
│ └─────┴──────┴─────┘ │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────────┐
│ Layer 3: Database Access │
│ ┌────┐ │
│ │ db │ │
│ └────┘ │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────────┐
│ Layer 2: Networking │
│ ┌─────┐ │
│ │ net │ │
│ └─────┘ │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────────┐
│ Layer 1: System Libraries & Cryptography │
│ ┌─────┬────────┐ │
│ │ lib │ crypt │ │
│ └─────┴────────┘ │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────────────────────┐
│ Layer 0: Foundation (RTL-Only) │
│ ┌──────┐ │
│ │ core │ (24 units - no mormot.* dependencies) │
│ └──────┘ │
└─────────────────────────────────────────────────────────────┘
* ddd folder contains only documentation (no .pas files)
| Folder | Layer | Depends On (mORMot folders) | File Count | Description |
|---|---|---|---|---|
| core | 0 | (none - RTL only) | 24 | Foundation types, JSON, RTTI, OS abstraction |
| lib | 1 | core | 14 | External library bindings (zlib, OpenSSL, curl, QuickJS) |
| crypt | 1 | core | 10 | Cryptography (AES, SHA, ECC, RSA, JWT, X.509) |
| net | 2 | core, crypt | 18 | Networking (sockets, HTTP, WebSockets, async) |
| db | 3 | core, crypt, net | 27 | Database access (SQL, NoSQL, RAD adapters) |
| orm | 4 | core, crypt, db | 9 | Object-Relational Mapping |
| rest | 4 | core, crypt, orm, soa, db | 8 | RESTful services framework |
| soa | 4 | core, orm | 4 | Service-Oriented Architecture (interfaces) |
| app | 5 | core | 3 | Application-level utilities (console, daemon) |
| ui | 5 | core, lib, orm, db | 6 | VCL/LCL UI components (reports, grids, PDF) |
| script | 5 | core, lib | 2 | Scripting engines (QuickJS integration) |
| misc | 5 | core | 2 | Miscellaneous utilities (PE/COFF, ISO) |
| tools | 5 | core, crypt, app | 2 | Command-line tools (ecc, mget) |
| ddd | 5 | (documentation only - no .pas files) | 0 | Domain-Driven Design documentation |
- Dependencies: None (RTL only: sysutils, classes, variants, typinfo)
- Key Units:
mormot.core.base- Framework version, basic types, RTL functionsmormot.core.os- Operating system abstraction layermormot.core.unicode- Unicode/UTF-8 text handlingmormot.core.text- Text processing and formattingmormot.core.rtti- Cross-compiler RTTI abstractionmormot.core.json- JSON parsing and serializationmormot.core.data- Data structures and algorithmsmormot.core.buffers- Memory buffer managementmormot.core.variants- Variant type handlingmormot.core.datetime- Date/time utilitiesmormot.core.threads- Threading primitivesmormot.core.log- Logging frameworkmormot.core.perf- Performance monitoringmormot.core.zip- ZIP compressionmormot.core.interfaces- Interface handlingmormot.core.search- Search and filteringmormot.core.test- Testing frameworkmormot.core.collections- Generic collectionsmormot.core.mustache- Mustache template enginemormot.core.mvc- MVC pattern supportmormot.core.os.security- OS security features
- Status: ✅ Pure RTL - can be compiled standalone
- Build Order: 1
- Dependencies: core
- Key Units:
mormot.lib.z- zlib/libdeflate compressionmormot.lib.static- Static library linking supportmormot.lib.openssl11- OpenSSL 1.1 bindingsmormot.lib.curl- libcurl HTTP clientmormot.lib.sspi- Windows SSPI authenticationmormot.lib.gssapi- POSIX GSSAPI authenticationmormot.lib.pkcs11- PKCS#11 cryptographic tokensmormot.lib.quickjs- QuickJS JavaScript enginemormot.lib.winhttp- Windows WinHTTPmormot.lib.gdiplus- Windows GDI+ graphicsmormot.lib.uniscribe- Windows text renderingmormot.lib.win7zip- 7-Zip archive supportmormot.lib.zstd- Zstandard compressionmormot.lib.lizard- Lizard compression
- Status: External library wrappers (no mORMot inter-dependencies)
- Build Order: 2
- Dependencies: core
- Key Units:
mormot.crypt.core- AES, SHA-2, SHA-3, HMAC, PBKDF2mormot.crypt.secure- Secure random, password hashingmormot.crypt.ecc- Elliptic Curve Cryptographymormot.crypt.ecc256r1- ECC secp256r1 curvemormot.crypt.rsa- RSA encryption/signaturesmormot.crypt.jwt- JSON Web Tokensmormot.crypt.x509- X.509 certificate handlingmormot.crypt.openssl- OpenSSL wrapper (uses lib.openssl11)mormot.crypt.pkcs11- PKCS#11 wrapper (uses lib.pkcs11)mormot.crypt.other- Additional crypto algorithms
- Status: Self-contained cryptographic layer
- Build Order: 2
- Dependencies: core, crypt
- Key Units:
mormot.net.sock- Low-level sockets API abstractionmormot.net.http- HTTP protocol implementationmormot.net.client- HTTP clientmormot.net.server- HTTP servermormot.net.async- Asynchronous I/Omormot.net.ws.core- WebSocket coremormot.net.ws.client- WebSocket clientmormot.net.ws.server- WebSocket servermormot.net.ws.async- Async WebSocketmormot.net.dns- DNS resolutionmormot.net.ldap- LDAP clientmormot.net.acme- ACME protocol (Let's Encrypt)mormot.net.relay- Network relay/proxymormot.net.tunnel- Network tunnelingmormot.net.tftp.client- TFTP clientmormot.net.tftp.server- TFTP servermormot.net.rtsphttp- RTSP over HTTPmormot.net.openapi- OpenAPI/Swagger support
- Crypto Usage: TLS/SSL encryption (uses crypt)
- Build Order: 3
- Dependencies: core, crypt (secure), net (proxy), db.core
- Key Units:
- Core:
mormot.db.core- Shared database types and definitionsmormot.db.sql- Abstract SQL database classesmormot.db.proxy- Database proxy/connection pooling
- Raw Database Access:
mormot.db.raw.sqlite3- SQLite3 APImormot.db.raw.sqlite3.static- Static SQLite3 librarymormot.db.raw.postgres- PostgreSQL APImormot.db.raw.oracle- Oracle OCImormot.db.raw.odbc- ODBC APImormot.db.raw.oledb- OLE DB API
- SQL Database Connectors:
mormot.db.sql.sqlite3- SQLite3 SQL connectormormot.db.sql.postgres- PostgreSQL SQL connectormormot.db.sql.oracle- Oracle SQL connectormormot.db.sql.odbc- ODBC SQL connectormormot.db.sql.oledb- OLE DB SQL connectormormot.db.sql.ibx- InterBase/Firebird IBXmormot.db.sql.zeos- Zeos Database Objects
- NoSQL:
mormot.db.nosql.bson- BSON encodingmormot.db.nosql.mongodb- MongoDB client
- RAD Studio Components:
mormot.db.rad- RAD Studio DB components basemormot.db.rad.bde- BDE adaptermormot.db.rad.firedac- FireDAC adaptermormot.db.rad.unidac- UniDAC adaptermormot.db.rad.nexusdb- NexusDB adaptermormot.db.rad.ui- UI data-aware componentsmormot.db.rad.ui.cds- ClientDataSet UImormot.db.rad.ui.sql- SQL UI componentsmormot.db.rad.ui.orm- ORM UI components
- Core:
- Build Order: 4
- Dependencies: core, crypt (secure), db
- Key Units:
mormot.orm.base- ORM low-level types and definitionsmormot.orm.core- TOrm class, TOrmModel, TOrmTablemormot.orm.rest- REST-based ORM client/server basemormot.orm.client- ORM client implementationmormot.orm.server- ORM server implementationmormot.orm.storage- Storage engines abstractionmormot.orm.sql- SQL-based ORMmormot.orm.sqlite3- SQLite3-specific ORMmormot.orm.mongodb- MongoDB ORM
- Build Order: 5
- Dependencies: core, orm
- Key Units:
mormot.soa.core- Interface-based SOA core typesmormot.soa.client- SOA client-sidemormot.soa.server- SOA server-sidemormot.soa.codegen- Service code generation
- Build Order: 5
- Dependencies: core, crypt, orm, soa, db
- Key Units:
mormot.rest.core- REST core types and TRest base classmormot.rest.client- REST client implementationmormot.rest.server- REST server implementationmormot.rest.http.client- HTTP REST clientmormot.rest.http.server- HTTP REST servermormot.rest.mvc- Model-View-Controller supportmormot.rest.sqlite3- SQLite3 REST servermormot.rest.memserver- In-memory REST server
- Note: Integrates orm, soa, and net layers for complete REST framework
- Build Order: 6
- Dependencies: core
- Key Units:
mormot.app.console- Console application support (ICommandLine)mormot.app.daemon- Daemon/service supportmormot.app.agl- Application-level abstractions
- Build Order: 7
- Dependencies: core, lib (gdiplus), orm, db
- Key Units:
mormot.ui.core- VCL/LCL cross-compatibilitymormot.ui.controls- Custom UI controlsmormot.ui.grid.orm- ORM-aware grid componentsmormot.ui.report- Reporting enginemormot.ui.pdf- PDF generationmormot.ui.gdiplus- GDI+ rendering
- Note: Requires VCL/LCL (GUI frameworks)
- Build Order: 7
- Dependencies: core, lib (static, quickjs)
- Key Units:
mormot.script.core- Scripting engine abstractionmormot.script.quickjs- QuickJS JavaScript engine integration
- Build Order: 7
- Dependencies: core
- Key Units:
mormot.misc.pecoff- PE/COFF file reader (Windows executables)mormot.misc.iso- ISO standards utilities
- Build Order: 7
- Dependencies: core, crypt, app
- Key Units:
mormot.tools.ecc- ECC command-line tool (certificate management)mormot.tools.mget- mget download tool
- Note: Executable tools, not libraries
- Build Order: 8
- Dependencies: N/A
- Status: Documentation-only folder (README.md, CLAUDE.md)
- Build Order: N/A
graph TD
%% Layer 0: Foundation
CORE[core<br/>RTL Foundation]
%% Layer 1: System Libraries
LIB[lib<br/>External Libraries]
CRYPT[crypt<br/>Cryptography]
%% Layer 2: Networking
NET[net<br/>Networking]
%% Layer 3: Database
DB[db<br/>Database Access]
%% Layer 4: ORM/REST/SOA
ORM[orm<br/>Object-Relational Mapping]
SOA[soa<br/>Service-Oriented Architecture]
REST[rest<br/>RESTful Services]
%% Layer 5: Application
APP[app<br/>Application Support]
UI[ui<br/>User Interface]
SCRIPT[script<br/>Scripting]
MISC[misc<br/>Miscellaneous]
TOOLS[tools<br/>Command-line Tools]
%% Dependencies
LIB --> CORE
CRYPT --> CORE
NET --> CORE
NET --> CRYPT
DB --> CORE
DB --> CRYPT
DB --> NET
ORM --> CORE
ORM --> CRYPT
ORM --> DB
SOA --> CORE
SOA --> ORM
REST --> CORE
REST --> CRYPT
REST --> ORM
REST --> SOA
REST --> DB
APP --> CORE
UI --> CORE
UI --> LIB
UI --> ORM
UI --> DB
SCRIPT --> CORE
SCRIPT --> LIB
MISC --> CORE
TOOLS --> CORE
TOOLS --> CRYPT
TOOLS --> APP
%% Styling
classDef layer0 fill:#e1f5ff,stroke:#01579b,stroke-width:3px
classDef layer1 fill:#e8f5e9,stroke:#1b5e20,stroke-width:2px
classDef layer2 fill:#fff3e0,stroke:#e65100,stroke-width:2px
classDef layer3 fill:#fce4ec,stroke:#880e4f,stroke-width:2px
classDef layer4 fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
classDef layer5 fill:#e0f2f1,stroke:#004d40,stroke-width:2px
class CORE layer0
class LIB,CRYPT layer1
class NET layer2
class DB layer3
class ORM,SOA,REST layer4
class APP,UI,SCRIPT,MISC,TOOLS layer5
- core - Foundation (must be first)
- lib + crypt - Can be built in parallel (both depend only on core)
- net - Networking layer (depends on core + crypt)
- db - Database layer (depends on core + crypt + net)
- orm + soa - Can be built in parallel (orm depends on db, soa on orm)
- rest - REST framework (depends on orm + soa + db)
- app + ui + script + misc - Can be built in parallel
- tools - Command-line tools (last)
Stage 1: core
↓
Stage 2: lib ║ crypt
↓
Stage 3: net
↓
Stage 4: db
↓
Stage 5: orm ║ soa
↓
Stage 6: rest
↓
Stage 7: app ║ ui ║ script ║ misc
↓
Stage 8: tools
Parallel Stages: 2, 5, 7 (3 stages can utilize multiple cores)
The mORMot2 architecture maintains strict layer separation with unidirectional dependencies flowing from higher layers to lower layers. This clean architecture enables:
- Incremental compilation - Changes in higher layers don't require rebuilding lower layers
- Selective deployment - Applications can include only required layers
- Modular testing - Each layer can be tested independently
- Clear separation of concerns - Each layer has well-defined responsibilities
-
orm ↔ rest ↔ soa: These three folders form the core service architecture but maintain proper layering:
soadepends onorm(interfaces need ORM types)restdepends on bothormandsoa(REST integrates both)- No backward dependencies
-
db → net: Database layer can use network for proxy connections
- This is a forward dependency only (net doesn't depend on db)
-
rest → orm → db: Clear unidirectional flow
- REST uses ORM
- ORM uses Database
- No backward references
All folders depend on Delphi/FPC RTL units:
sysutils,classes,variants,contnrs,typinfo
Additional external dependencies:
- ui: Requires
Graphics,Controls,Themes(VCL/LCL) - lib: Links to external libraries (zlib, OpenSSL, curl, etc.)
- crypt: May use OpenSSL via
lib.openssl11(optional)
Several folders contain platform-specific implementations:
- core:
mormot.core.os- Windows/POSIX abstraction - net:
mormot.net.sock- Socket API abstraction (WinSock/BSD) - lib: Windows-only units (sspi, winhttp, gdiplus, uniscribe, win7zip)
Some units are optional depending on project requirements:
- ui: Only needed for VCL/LCL GUI applications
- script: Only if JavaScript scripting is required
- tools: Command-line utilities (not libraries)
- db.rad.*: Only for RAD Studio component integration
- db.nosql.*: Only if MongoDB is used
- net.ws.*: Only if WebSockets are needed
For a basic REST server with SQLite:
Required folders:
1. core (foundation)
2. crypt (security)
3. db (database access - only db.sql.sqlite3)
4. orm (ORM layer)
5. rest (REST server)
Optional:
- net (if custom HTTP server needed beyond rest.http.server)
- soa (if interface-based services required)
For a GUI client with ORM and services:
Required folders:
1. core (foundation)
2. crypt (security)
3. net (networking)
4. db (database access)
5. orm (ORM layer)
6. soa (services)
7. rest (REST client)
8. ui (GUI components)
9. app (application framework)
For a command-line crypto tool:
Required folders:
1. core (foundation)
2. crypt (cryptography)
3. app (console support)
4. tools (if using mormot.tools.ecc)
- core is truly foundational - 24 units with zero mORMot dependencies
- lib and crypt are independent - Both only depend on core (parallel buildable)
- net is self-contained - Networking layer doesn't depend on database/ORM
- ORM/REST/SOA form the application core - Interdependent but properly layered
- Application folders are loosely coupled - Most only depend on core
- No framework lock-in - You can use core/crypt/net without ORM/REST
- Determine layer - Place in appropriate folder based on dependencies
- Check dependencies - Ensure no circular references introduced
- Update this document - Add to dependency matrix
- Verify build order - Confirm compilation sequence still valid
- Move dependencies down - Prefer dependencies on lower layers
- Extract to core - If multiple layers need it, consider moving to core
- Avoid cross-layer coupling - Don't bypass layer boundaries
- Keep lib/crypt independent - These should remain parallel
| Version | Date | Changes |
|---|---|---|
| 1.0 | 2025-10-10 | Initial comprehensive dependency analysis |
Analyzed by: Claude Code (Sonnet 4.5)
Source: mORMot2 /mnt/w/mORMot2/src/
Method: Uses clause analysis of representative files from each folder
Files Analyzed: 30+ representative .pas files across all folders