modularizer

package
v0.1.65 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 12 Imported by: 0

README

Modularizer Tool

The Modularizer Tool is designed to instantiate a new Go Full module adhering to the recommended module structure. It provides a streamlined process for creating a new module with as much boilerplate code as possible, allowing developers to focus on implementing the core logic of their module.

Example Usage

The below command demonstrates how to use the Modularizer Tool to create a new module named "work" with an aggregate root of "work_item". It includes commands for "assign_to" and "start_work", events for "work_item_created" and "work_item_started", and a query for "find_all_work_items".

go run tools/modularizer/cmd/modularize/main.go modularize --config tools/modularizer/modularizer.yaml

Outputs

Upon running the above command, the Modularizer Tool will generate a new module with the following structure along with generating the relevant files for the module, its adapters, its domain, and its application commands, events, and queries.

├── api
│   ├── frontend/
│   │   ├── src/work
│   │   └── test/mocks/work
│   └── rest/work
├── db
│   ├── migrations/
│   └── work/
├── internal/work/
│   ├── adapters
│   │   ├── inbound/
│   │   └── outbound/
│   ├── app
│   │   ├── command/
│   │   ├── event/
│   │   └── query/
│   └── domain/
│       └── work/

How it works

The Modularizer Tool makes use of the text/template package to generate files based on predefined templates. It takes in command-line arguments to specify the module name, aggregate root, commands, events, and queries, and then creates the necessary directory structure and files for the new module.

It also builds on top of the other code generation tools utilized within the project, SqlC, OapiCodeGen, openapi-generator to further simplify the process.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrModuleInitMigrationFileExists

type ErrModuleInitMigrationFileExists struct{}

func (ErrModuleInitMigrationFileExists) Error

type Modularizer

type Modularizer struct {
	// contains filtered or unexported fields
}

func FromConfig

func FromConfig(cfg module.ModuleConfig) ([]*Modularizer, error)

func NewModularizer added in v0.1.65

func NewModularizer(mod module.Module) (*Modularizer, error)

func (*Modularizer) CreateModule

func (m *Modularizer) CreateModule() error

CreateModule creates a new module based on the modularizer's template data, including the directory structure, module file, entity files, repository files, application file, command files, query files, event files, Postgres adapter files, database migration files, REST API files, OpenAPI schema file, and updates to the SQLC configuration and OpenAPI Generator configuration, and returns an error if there was an issue creating any of the files or directories

type SQLCConfig

type SQLCConfig struct {
	Sql []SqlCSqlConfig `json:"sql" yaml:"sql"`
}

type SqlCSqlConfig

type SqlCSqlConfig struct {
	Name    string `json:"name" yaml:"name"`
	Schema  string `json:"schema" yaml:"schema"`
	Queries string `json:"queries" yaml:"queries"`
	Engine  string `json:"engine" yaml:"engine"`
}

Directories

Path Synopsis
cmd
modularizer command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL