How statebox/cql works
Project’s Main Components
• Core Language Modules (Core Engine):
– This is primarily under the src directory (src/Language and its submodules) where all the logic for CQL constructs is implemented. It encompasses parsing (src/Language/CQL/Parser/*), language constructs (like Collage, Congruence, Morphism, Schema, etc.), transformation, and query evaluation.
• Interfaces:
– CLI Frontend: The cli folder contains a Main.hs that is used when executing CQL via the command-line (e.g., “stack exec cql examples/Employee.cql”).
– HTTP API Service: The http folder houses an HTTP server (http/Main.hs plus additional modules under http/src/Api and http/src/Api/Config) which exposes an endpoint for processing CQL specifications over port 8080.
• Examples:
– Located in the examples folder, these sample .cql files provide concrete cases for how CQL scripts are structured.
• Testing & Build Infrastructure:
– The test directory includes modules for unit testing (e.g., CQLSpec.hs, ParserSpec.hs).
– Build and configuration files are laid out for several build systems (Stack, Cabal, Nix) and include package.yaml, stack.yaml, Setup.hs, and various configuration files (e.g., .editorconfig, .travis.yml).
Relationships and Interactions
• Both the CLI and HTTP API components are “frontends” that interact with the core engine.
– For the CLI:
• The module in cli/Main.hs invokes functions from the core language modules to parse, evaluate, and execute .cql files.
– For the HTTP API:
• The modules in http (especially under http/src/Api) set up an HTTP server that listens for POST requests containing CQL specifications.
• These modules also call functions from the core engine to process the CQL input and return a proper response.
• The core language modules are composed of several sub-components (parsers, transformers, algebra, schema management, and query execution) that work together to provide the declarative migration capabilities.
• Test modules validate the functionalities provided by these components to ensure correctness.
• The examples offer usage scenarios or demonstrations of CQL files that can be fed to either the CLI or HTTP API.
Architectural Patterns, Design Principles, and Technologies
• Separation of Concerns:
– There is a clear separation between the interface layers (CLI, HTTP) and the core processing engine.
• Modularity:
– The src/Language directory is subdivided into logical areas (such as Parser, Transform, Prover, etc.) which hints at a modular design based on functional decomposition.
• Layered Architecture:
– At the top, there are end-user interfaces (CLI and HTTP). The middle layer is the core engine that provides language processing and transformation. The lower layer (implicitly supported by the build system) includes testing and configuration.
• Build and Deployment:
– Multiple build tools (Stack, Cabal, Nix) are supported, emphasizing the importance of reproducible builds. This can be visualized as a supporting “build infrastructure” component.
• Technologies & Tools:
– Haskell is the main language.
– Stack, Cabal, and Nix configurations indicate multi-environment build support.
Final Checklist for the Principal Software Engineer
– Ensure all major components are represented: Core Language Engine, CLI, HTTP API, Testing, Examples, and Build Infrastructure.
– Optionally, include annotations about technology choices (Haskell, Stack/Cabal/Nix) and design principles (separation of concerns, modularity).