LazyMagic Model Driven Development is a deterministic system code generator. It ingests LazyMagic directives, openAPI specifications, project templates, code templates, and deployment templates to generate deployable artifacts for one or more deployment targets. Unlike LLM based systems, the code generated is consistent across generation runs. All artifacts are generated in clear text. Developers may extend the generated code without fear of losing their work. The generated artifacts include deployment scripts that may be used in CI/CD pipelines for full end-to-end automation into your existing engineering process.
LazyMagic ingests inputs and generates artifacts:
The LazyMagic generator is available as a Visual Studio IDE Extension and dotnet CLI command.
It is normal practice to use a services like GitHub or GitLab to compile and test source code checked-in by a developer. If the compiled artifacts are found suitable, they are then made available for deployment by the Continuos Deployment Pipeline. Here at LazyMagic we use GitHub Actions and a GitFlow process to implement our CI. However, LazyMagic makes no substantial assumptions about your CI process implementation.
When doing development, it is common to do local compilation and test before checking in newly developed code (which would kick off a CI process). LazyMagic aggressively supports local development and integration testing. Integration testing is supported on the local workstation by providing a hybrid local .NET Host. This local host runs service-side logic code while also providing access to deployment target services.
For an AWS SAM application this means we run the same code used in AWS Lambdas, but we run it locally so you can debug it easily. Typically, one would launch a debugging session on the client app and one on the service app and then debug calls from the client through the local service and back to the client.
It is normal practice to use generalized tools like Teraform, or proprietary tools, like AWS CloudFormation, to deploy your approved artifacts to a target environment. For small systems, you can perform such deployments using command line tools or even a browser based dashboard provided by the target deployment environment.
LazyMagic produces PowerShell scripts that may be used in CD Pipelines or used from your workstation. These scripts use the AWS CloudFormation service along with the AWS CLI and AWS SAM CLI, called.
Deploying directly from a workstation is usually only appropriate for development environments.
The current supported targets include:
LazyMagic is designed to be extensible and will support additional deployment targets going forward. Planned extensions include:
LazyMagic provides a collection of .NET libraries to accelerate service side development. A sample muti-tenant SaaS solution is provided that demonstrates the use of these libraries in a non-trivial reference architecture that you can copy and extend to fit your system needs.
The LazyMagic sample system includes a collection of AWS CloudFront templates that you may modify and extend to suite your system requirements. The provided templates exemplify AWS Best Practices for a multi-tenant system utilizing AWS Services like Cognito, CloudFront, API Gateway, Lambda, and DynamoDB.
Note: We are current working on extending the sample system to include Azure templates so you can target the Azure cloud.
LazyMagic provides a sample app and collection of .NET libraries to accelerate client side development using Microsoft's MAUI and Blazor frameworks.
The LazyMagic sample application, client side libraries, and generated system service access libraries, demonstrate how to target iOS, Android, Windows, MacOS and WebApp deployment with a single codebase. These libraries and sample app go well beyond the simple example projects provided by Microsoft and address many of the differences among native platform and web applications.
Some of the advanced features demonstrated in our sample client app and libraries include:
LazyMagic MDD is an open source platform. The generator itself is dual-licensed with GPL and Proprietary license options. All supplied libraries, packages, and templates, that may be included in your generated system, are provided under the permissive MIT license allowing your generated code to be licensed under your preferred/required terms; including a proprietary closed-source license.
This documentation is tailored to full-stack architects and those with an interest in understanding the concepts and particulars of designing systems at scale using modern design patterns. The current version of LazyMagic MDD focuses on the following technologies:
We do not attempt to provide a step-by-step tutorial. However, we do provide a complete and rather robust sample system generated by LazyMagic and all of the necessary system specification documents necessary to generate the system from scratch and deploy it.
Many AWS Services are "Serverless". Not all of them are included in the AWS Free Tier. For instance, we use the DynamoDB database in our sample system because it is both Serverless and included in the AWS Free Tier. In addition, DynamoDB encrypts data at rest and this feature is included in the AWS Free Tier service.
Our sample system includes only services that are provided in the AWS Free Tier. Generally, these are services that cost nothing unless a substantial amount of usage is reached.
Our sample system implements the AWS Serverless Application Model (SAM) reference architecture. We use the AWS CloudFormation service to deploy the system as a collection of SAM stacks. This sample system is a multi-tenant Software-as-a-Service (SaaS) system with many advanced features:
Here is a high level diagram of this SAM architecture:
Note: For developers that have used three-tier service stacks, this architecture looks sparse and simplistic. That is the point of Serverless Application Models. There are no instances to manage or scale; there is no Virtual Private Cloud network to define, secure, and manage. There are only Services, no servers. Of course, the AWS Services have servers behind them, but you don't have to configure, manage or scale them, so from your perspective, you have a serverless architecture.
LazyMagic is not limited to the use of the AWS Serverless Application Model (SAM) architecture.
Systems are defined as modular components, in a LazyMagic.yaml file, using a hierarchy of directives:
A system definition may have many of each type of directive.
Since directives reference other directives, a dependency graph is maintained and used to generate artifact closures, thereby eliminating manual configuration of code and deployment scripts.
Modular system design is achieved using multiple Schema and Module directives, each referencing different OpenAPI specification documents. The final aggregate OpenAPI specification, for each API, is generated by traversing the directive dependencies: eg: Api -> Containers -> Modules -> Schemas.
Because a Container may be referenced by multiple Api directives, each Api serves a different aggregate OpenAPI specification.
In general, modularity is achieved based on these directives relation axioms:
|
|
The use of modular system design is not mandated. You can define a monolithic system having one OpenAPI specification file, and one each of Schema, Module, Container, Api, Service and Authentication directives. You may still have multiple WebApp directives and multiple Tenancy directives but they all reference the single API directive and authenticate using the single Authentication directive.
The use of modular system design offers numerous advantages:
In general, we treat Containers, for example a Lambda or Fargate instance, as modular-monoliths. To satisfy the modular-monoliths pattern, each Module referenced by the Container must satisfy these criteria:
Directive artifacts map system and code elements onto a target platform's services. Here is our how the various directive artifacts map to AWS services and .NET code in our sample system. Each directive may have one or more Artifacts associated with it.
Artifacts types include:
Here are our Sample System's CloudFormation templates and the AWS CLI and AWS SAM CLI, called from PowerShell scripts, to create AWS Stacks.
The scripts (*.ps1) and CloudFormation templates (*.yaml) in bold are final artifacts ready for use in a CI/CD pipeline (or from your workstation). The items in italics are template scripts or CloudFormation template snippets ingested by generators to produce the final artifacts.
Edit the scripts, and template snippets to modify the generated system to suit your specific needs. The templates and scripts provided are robust and may be suitable for many system requirements as is.
Each directive may have one or more artifact Generators associated with them. Each Generator produces one or more artifacts for the system. For example, here are the Generators, grouped by associated directives, supporting the generation of .NET projects and AWS SAM deployment templates and scripts in the sample system's reference architecture.
New targets are supported through the addition of new artifact generators. New Artifact Generator specifications are added to the existing Directives, producing the artifacts required for additional target deployments.
LazyMagic generators reference template projects in your solution to generate the artifacts. This means you may edit these template projects to generate artifacts tailored to your specific needs. This allows solution by solution control over artifact generation.
You may also create your own Artifact Generator to implement more substantial changes to artifact generation. The existing generators provide a solid framework for the development of new generators.
We are currently implementing a plug-in architecture for artifact generators. Currently, you would fork the LazyMagicMDD repo to add your own artifact generators. With plug-in support, LazyMagic will discover your plug-in and register it for use. This is a high-priority feature for the team.