clabonte/codeprimer

CodePrimer, customizable production-grade code generator for architects and team leads

0.2.1 2020-12-29 11:39 UTC

This package is auto-updated.

Last update: 2024-04-29 04:33:55 UTC


README

build-shield coverage-shield Issues MIT License

CodePrimer’s primary objective is to allow software architects and senior developers to define the data model and related processing from a business point of view so that it can be easily understood and manipulated by entrepreneurs, business managers and business analysts before starting the software development process.

As such, it is meant to prime the software development process using simple, easy to use and effective representations that can be objectively interpreted by business and techies willing to cooperate to create digital businesses.

CodePrimer interprets this data model to generate a set of artifacts (e.g. source code) that are combined to build a production-grade software solution following the architect's vision to guide the development team to use his best practices.

The project offers an opinionated architecture, called Business Bundle to get started. The resulting solution is meant to be highly scalable, yet requiring very low maintenance by leveraging the best DevOps practices with a minimal technical team.

It liberally borrows and integrates concepts and best practices that have been made available over the years by several movements in the software development space, such as UML, Domain-Driven Design (DDD), agile, micro services and DevOps.

The resulting architecture and implementation is not meant to please everyone but the underlying goal is to produce top quality software that is meeting the business objectives for what it is being built and be easily understood, maintained and evolved by a software development team at a fraction of the time usually required to achieve production-grade software..

Thanks to the high flexibility of its artifact generation engine, the project can be easily tailored to suit any programming language or any architecture/framework chosen by the architect.

Documentation

In order to fully understand and leverage the capabilities offered by CodePrimer, you should refer to the following documents:

Getting Started

CodePrimer can be added as a library to an existing PHP project or used standalone to either generate artifacts or prime a new project.

Prerequisites

No matter how you want to use it, the installation instructions assume you already have the following:

Installation

Generating artifacts in an existing project

If you already have an existing PHP project, and you want to use CodePrimer to generate artifacts (e.g. source code) in it, you can simply add CodePrimer via composer:

composer require clabonte/codeprimer

Then, you will need to generate the configuration files for your project by running the init command and answering the various questions asked:

vendor/bin/codeprimer init

This will generate a set of files under the codeprimer directory that will be used by the prime command to generate the various artifacts you need:

vendor/bin/codeprimer prime

Using CodePrimer in standalone mode

If you don't have an existing project, or you are simply curious to see how it works, you can still clone the repository and installing its dependencies:

  1. Clone the repo
  2. Run composer install
git clone https://github.com/clabonte/codeprimer.git
cd codeprimer
composer install

Once you have cloned and installed the project, you can generate a set of Artifacts based on the Channel sample application by running the following command:

composer sample-app

Take a look at the sample/output folder to see the Artifacts generated by CodePrimer.

Usage

In order to understand what CodePrimer can be used for, it is best to look at a sample application.

You can also consult the list of Artifacts currently available and planned for CodePrimer.

Command Line

CodePrimer offers a simple CLI to either initializes a new CodePrimer-compatible project via the init command:

[vendor/]bin/codeprimer init

This command will create, at a minimum, the following files in the selected destination:

codeprimer/codeprimer.yaml
codeprimer/bundle.php
codeprimer/DatasetFactory.php
codeprimer/BusinessModelFactory.php
codeprimer/BusinessProcessFactory.php

Once you have initialized your project, you can prime artifacts via the prime command:

[vendor/]bin/codeprimer prime [-c <configuration_file>] [-d <destination>]

Configuration

The prime command currently uses the following files (generated by the init command) to configure its execution:

codeprimer/codeprimer.yaml

This file defines the list of Artifacts to generate for your project. Unless you want to change the list of artifacts to generate for your project, you do not need to modify this file.

codeprimer/bundle.php

This file coordinates the creation of your Business Bundle through the invocation of your factories (see below). As such, you should not modify this file.

codeprimer/DatasetFactory.php

This factory defines the list of Dataset instances that are part of your application.

You need to modify this file to design your business/application model as follow:

  • Create a set of public methods starting with the create name prefix with no parameters (e.g. createUserRole())
  • Each create method must return a Dataset instance describing a dataset used in your application.
  • The bundle.php file (see above) will automatically invoke all the create methods to add all Dataset instances to your application business bundle.

codeprimer/BusinessModelFactory.php

This factory defines the list of BusinessModel instances that are part of your application.

You need to modify this file to design your business/application model as follow:

  • Create a set of public methods starting with the create name prefix with no parameters (e.g. createUser())
  • Each create method must return a BusinessModel instance describing a business model used in your application. Your business model may reference datasets and/or other business models defined in their respective factories.
  • The bundle.php file (see above) will automatically invoke all the create methods to add all BusinessModel instances to your application business bundle.

codeprimer/BusinessProcessFactory.php

This factory defines the list of BusinessProcess instances that are part of your application.

You need to modify this file to design your business/application model as follow:

  • Create a set of public methods starting with the create name prefix with no parameters (e.g. createRegister())
  • Each create method must return a BusinessProcess instance describing a business process used in your application. Your business process must reference datasets and/or business models defined in their respective factories.
  • The bundle.php file (see above) will automatically invoke all the create methods to add all BusinessProcess instances to your application business bundle.

Roadmap

The high level roadmap and progress is available here

To have a more detailed view on upcoming changes, please look at the Product Roadmap or open issues for a list of proposed features and known issues.

Contributing

See CONTRIBUTING

Contact

Christian Labonte LinkedIn

Project Link: https://github.com/clabonte/codeprimer

License

This project uses the following license: MIT