How remiges-tech/sqld works
Main Components
a) Core Library Components (Central Layer):
• Model Metadata System
• Query Builder System
• Executor System
• Safe Raw Query System
b) External Dependencies:
• squirrel (for query building)
• PostgreSQL Parser (for SQL validation)
• scany (for result mapping)
• sql.DB/pgx.Conn interfaces
c) Client Application Integration Points
Model Metadata System
• Model Registration
• Field Mapping
• Type Validation
Query Builder
• Structured Query Building
• Parameter Binding
• Pagination Handler
• Order By Handler
Executor
• Query Execution
• Result Mapping
• Pagination Processing
Safe Raw Query System
• Parameter Validation
• SQL Syntax Validation
• Type Checking
BOTTOM LAYER - Database Integration:
• Database Connectors (sql.DB/pgx.Conn)
• Database Systems (PostgreSQL)
Flow Representation
• Client request → Query Building → Execution → Database
• Database → Result Mapping → Client response
• Model registration → Metadata validation
• Query parameters → Type validation
• Raw SQL → Syntax validation
Component Details
For each component, include:
• Input/Output formats
• Key responsibilities
• Integration points
┌─────────────────────────┐
• Query Builder │
• ┤
• Build SELECT/WHERE │
• Handle pagination │
• Process ordering │
• Validate fields │
• ┘
Notes
Annotations for:
• Type safety guarantees
• Validation checkpoints
• Performance considerations
• Extension points
• The clear separation between structured and raw query systems
• The type-safety mechanisms throughout the pipeline
• The validation layers at different stages
• The flexibility in database connectivity
Keep the abstraction level focused on the architectural components while including enough detail to show the sophisticated type-safety and validation mechanisms that make this library unique.