How levinhne/event-driven-architecture-in-golang works
Main Components
• Common Infrastructure/Shared Libraries: Include components representing shared directories (internal/ddd, internal/es for event sourcing, internal/logger, internal/registry, etc.) which underlie multiple bounded contexts.
• API Gateway & Communication Interfaces: Show how gRPC and REST “gateways” and associated protobuf definitions (look for files in “*.pb.go”, “*.proto”, and “api.swagger.json” or OpenAPI files) are used to expose services.
• Deployment & Containerization: Represent the docker-compose, Dockerfiles, and database initialization scripts. Use a component to denote the containerized environment or the underlying Postgres databases (as suggested by the docker/database folder).
• Command-Line Entrypoints: Mark the “cmd/mallbots” (and possibly other entry points) as the actual application launch points which bind these modules together.
Relationships and Interactions
• Communication Paths: Within each module, illustrate the flow from incoming requests (via REST or gRPC) through application services (commands, queries, event handlers) to the domain layer, and further down to the repository/persistence layer (e.g., postgres integrations).
• Shared Infrastructure: Identify and show how common components (DDD foundations, event sourcing mechanisms, logging and monitoring) connect to each module.
Architectural Patterns & Design Principles
• Modular Monolith Architecture: The project is structured using modular monolith principles. Each domain is self-contained with its own internal layers, yet they all run within an integrated system.
• Domain-Driven Design (DDD): Stress the presence of Aggregates, Domain Events, Repositories, and Application Services (as seen in the internal application and domain folders).
• Event Sourcing Elements: Components under internal/es and the presence of snapshot and event stores indicate an event-driven design.
• API Layer Separation: There is a clear separation between REST and gRPC interfaces, which suggests adherence to a separation of concerns principle in the communication layer.
Technologies, Frameworks, and Tools
• Go: The entire codebase is implemented in Go.
• Protobuf/gRPC: Used extensively for API definitions and service communication.
• Docker & Docker-Compose: For containerizing the system and setting up Postgres databases.
• PostgreSQL: Evidenced by database initialization scripts that create and load various schemas.
• Swagger/OpenAPI: For REST API documentation.
• Internal Libraries: Custom DDD, event sourcing, logging, and registry libraries that underpin the business logic.
Elements to be Included
• Each Bounded Context: Clearly drawn with subgroupings (API layer, application logic, domain layer, persistence layer).
• Technology Annotations: Next to each component include technology or protocol labels (e.g., “gRPC”, “REST”, “Postgres”).
• Shared Infrastructure Layer: A common layer that includes event sourcing, logging, and DDD support libraries.
– Clearly decomposes the project into its major bounded contexts (baskets, customers, depot, notifications, ordering, payments, stores).
– Demonstrates the layered architecture (API, application, domain, persistence) within each context.
– Clearly annotates the protocol/technology used by each component (gRPC, REST, protobuf, Docker, PostgreSQL).