Skip to content

i4erkasov/go-ddd-cqrs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go DDD CQRS layout

This is a Go application template utilizing Domain-Driven Design (DDD) and Command Query Responsibility Segregation (CQRS) principles.

Project Structure

.
├── cmd                         # Command line interface and main application entry points.
│   └── myapp                   # Main application directory.
│       ├── cli                 # CLI-specific code, such as command definitions and parsers.
│       │   ├── cli.go          # CLI tool setup and command configuration.
│       └── main.go             # Entry point of the application.
├── internal                    # Application's internal codebase, not accessible from outside.
│   ├── application             # Application layer: orchestrates the application flow, configuration, and CQRS implementation.
│   │   ├── app.go              # Application configuration and initialization.
│   │   ├── command             # Command side of CQRS: handles the execution of commands.
│   │   │   └── command.go      # Command handling (CQRS).
│   │   └── query               # Query side of CQRS: handles data retrieval requests.
│   │       └── query.go        # Query handling (CQRS).
│   ├── domain                  # Core domain logic: entities, aggregates, services, and repository interfaces.
│   │   ├── aggregate           # Domain aggregates, representing collections of entities that are processed together.
│   │   ├── entity              # Domain entities, the fundamental objects of the business context.
│   │   ├── repository          # Domain repository interfaces, abstract definitions for data access layers.
│   │   └── service             # Domain services, containing business logic that doesn't naturally fit within an entity or aggregate.
│   ├── genmocks.go             # Mock generation for testing, facilitating unit and integration testing.
│   ├── infrastructure          # Infrastructure layer: frameworks, drivers, and tools for technical capabilities.
│   │   ├── api                 # API interfaces, particularly HTTP for web interaction.
│   │   │   └── rest            # REST-specific implementations: servers, handlers, middleware.
│   │   │       ├── handler     # REST handlers, processing incoming HTTP requests.
│   │   │       ├── middleware  # REST middleware, intercepting requests for cross-cutting concerns like logging, authentication.
│   │   │       └── validator   # REST request validation, ensuring requests meet the expected format.
│   │   ├── decorator           # Decorators for enhancing or altering behavior (e.g., logging, metrics).
│   │   │   ├── decorator.go    # Base decorators, potentially for cross-cutting concerns.
│   │   │   └── logging.go      # Logging decorator, adding logging capabilities to operations.
│   │   └── pgsql               # PostgreSQL implementation: models and repositories for the database.
│   │       ├── model           # Data models for PostgreSQL, representing the database structure in code.
│   │       └── repository      # Domain repository implementation for PostgreSQL, concrete data access operations.
│   └── mocks                   # Mocks for testing, automatically generated or manually crafted stubs for unit tests.
└── pkg                         # Shared libraries and utilities, potentially reusable across different projects.

Component Descriptions

cmd

Contains the application's entry point (main.go), where the server is started and all necessary components are initialized.

internal

The core of the application, divided into layers according to DDD and CQRS.

application

The application layer, responsible for coordinating actions and delegating tasks between the domain layer and the infrastructure layer. Includes command and query processing.

domain

The heart of the domain model, containing business logic, entities, aggregates, repository interfaces, and domain services.

infrastructure

The layer that facilitates communication between the application layer and the external world (databases, web services, etc.). Includes API implementation, database access, etc.

pkg

General packages for the entire application, e.g., the logging service.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages