High-Level Architecture
Relevant source files
The following files were used as context for generating this wiki page:
The flext-target-ldap project is a specialized Singer target designed for loading data into LDAP directories. It leverages the flext-core and flext-ldap ecosystems to provide a robust, type-safe, and scalable integration for directory services. The architecture follows a modular approach, separating the CLI entry point, stream-specific processing logic (Sinks), and low-level LDAP communication.
Sources: README.md:9-11, src/flext_target_ldap/api.py:34-40, pyproject.toml:23
Core Components
The system architecture is built around three primary layers: the Facade/CLI layer, the Processing layer (Sinks), and the Utility layer (Client).
1. Facade and Orchestration
The FlextTargetLdap class serves as the primary entry point and facade for the target. It manages the lifecycle of the application, including configuration validation, dependency injection (DI) container setup, and orchestrator management.
FlextTargetLdap: Inherits fromFlextTargetLdapTargetand implements the Singer target protocol.FlextTargetLdapOrchestrator: Manages the execution flow and coordination between different components.
Sources: src/flext_target_ldap/api.py:34-110, src/flext_target_ldap/application/orchestrator.py
2. Sink Hierarchy
Data processing is delegated to stream-specific "Sinks". The architecture employs a specialized sink pattern to handle different LDAP object types such as Users, Groups, and Organizational Units.
| Sink Class | Responsibility | Supported Stream |
|---|---|---|
FlextTargetLdapUsersSink | Maps Singer records to LDAP inetOrgPerson or person objects. | users |
FlextTargetLdapGroupsSink | Manages groupOfNames entries and member attributes. | groups |
FlextTargetLdapOrganizationalUnitsSink | Handles organizationalUnit creation and updates. | organizational_units |
FlextTargetLdapBaseSink | Provides fallback logic and common methods for custom streams. | Generic fallback |
Sources: src/flext_target_ldap/api.py:75-90, src/flext_target_ldap/_models/sinks.py:90-510
3. Client and Utilities
The FlextTargetLdapClient acts as the bridge between the high-level sinks and the flext-ldap library. It encapsulates connection management, entry persistence (Add/Modify/Delete), and search operations.
Sources: src/flext_target_ldap/_utilities/client.py:27-243
Data Flow Architecture
The following diagram illustrates the flow of a Singer message through the target, from the CLI input to the final LDAP operation.
The data flow begins with Singer-formatted JSONL messages on stdin. The cli method parses these messages. STATE messages are echoed back to stdout to maintain checkpointing. RECORD messages are routed to the appropriate sink based on the stream name. The sink then constructs the Distinguished Name (DN) and attribute mapping before invoking the client.
Sources: src/flext_target_ldap/api.py:167-244, src/flext_target_ldap/_models/sinks.py:157-190
Component Relationship
The class hierarchy demonstrates a strong adherence to the Dependency Inversion Principle, where high-level modules depend on abstractions provided by flext-core.
Configuration and Validation
The architecture utilizes Pydantic-based models for configuration and domain entities. This ensures that all incoming settings and data records are validated against strict business rules before execution.
Settings Normalization
The FlextTargetLdapSettings class includes a normalization step to convert flat Singer configurations into a nested structure compatible with the enterprise ConnectionConfig model.
Sources: src/flext_target_ldap/settings.py:31-83
Domain Validation
The FlextTargetLdapModels class defines domain-specific validation logic for LDAP entries.
| Model | Validation Rule |
|---|---|
AttributeMapping | Ensures field names are alphanumeric and transformation rules (e.g., lowercase, trim) are valid. |
Entry | Validates DN format, ensures object_classes contains top, and checks required attributes for person and groupOfNames. |
Sources: src/flext_target_ldap/models.py:39-160
Conclusion
The high-level architecture of flext-target-ldap is designed for extensibility and reliability. By utilizing a sink-based dispatch system and centralized LDAP client, the project provides a clean separation of concerns that allows for complex directory management while remaining compatible with the Singer specification.