Example CRUD project applying Hexagonal Architecture, Domain-Driven Design (DDD), Event-Driven Architecture (EDA), Command Query Responsibility Segregation (CQRS), Behavior-Driven Development (BDD), Continuous Integration (CI), and more... in Go.






go run github.com/bastean/codexgo/v4/cmd/codexgo@latest -demo
[!NOTE]
- Demo version does not require any configuration, because the required ENV values are already preset.
- Here we can find the ENV preset values that are used in the Demo.
In-Memoryimplementation will be used for EventBus, CommandBus, QueryBus and Database (BadgerDB).- Links to confirm and recover the account are sent through the
Terminalwith the following messages:- "Hi \<username>, please confirm your account through this link: \<link>".
- "Hi \<username>, please reset your password through this link: \<link>".
go install github.com/bastean/codexgo/v4/cmd/codexgo@latest
codexgo -h
_________ ________________
_____________ ______ /_____ ____ __ __ ____/__ __ \
_ ___/_ __ \_ __ / _ _ \__ |/_/ _ / __ _ / / /
/ /__ / /_/ // /_/ / / __/__> < / /_/ / / /_/ /
\___/ \____/ \__,_/ \___/ /_/|_| \____/ \____/ v4.17.4
Example CRUD project applying Hexagonal Architecture, DDD, EDA, CQRS, BDD, CI, and more... in Go.
Usage: codexgo [flags]
-demo
Use preset ENV values
-env string
Path to custom ENV file
-v Print version
[!NOTE]
- We can use the .env.demo.cli file or we can create our own
.envfile where we define our own values.- In the .env.example.cli file, we can see the values that can be used.
- If
CODEXGO_SMTP_*is omitted, the links to confirm and recover the account are sent through theTerminalwith the following messages:- "Hi \<username>, please confirm your account through this link: \<link>".
- "Hi \<username>, please reset your password through this link: \<link>".
- We can define our own SMTP configuration by simply modifying the
CODEXGO_SMTP_*variables, then we will be able to receive the links by mail.- If
CODEXGO_BROKER_*is omitted, an in-memory EventBus will be used.In-Memoryimplementation will be used for CommandBus and QueryBus.- If
CODEXGO_DATABASE_*is omitted, aBadgerDBin-memory database will be used.- We can use a file as a database instead of memory by defining the file name in the
CODEXGO_DATABASE_BADGERDB_DSNvariable.
codexgo -env path/to/.env
[!NOTE]
- System Requirements
- In the Demo version (.env.demo):
RabbitMQimplementation will be used for the EventBus.
- URL:
http://localhost:15672- User/Password:
codexgo-demoIn-Memoryimplementation will be used for CommandBus and QueryBus.MongoDBimplementation will be used as Database.
- Compass:
mongodb://codexgo-demo:codexgo-demo@localhost:27017Mailpitwill be used as SMTP to receive emails with the links to confirm and recover the account.
- URL:
http://localhost:8025codexGOServer.
- URL:
http://localhost:8080
task demo
bash
task commit*.go: GolangCI-Lint.*.templ: templ fmt.*.feature (Gherkin): Cucumber extension.*.*: Prettier cli/extension.*.go: deadcode./v*The system allows users to register a new account, log in and update their data or permanently delete their account, as well as verify and reset their account through a link sent to their email.
It is a monolith where CRUD operations can be performed from different presentations to the same database, this allows us to manage users from the different presentations available, in addition to having a messaging system that allows to communicate the events occurred, thus avoiding a coupling to the source of the same.
pkg/context/(modules)It is the logical core that contains all the necessary functionalities that are agnostic of any presentation.
internal/pkg/service
It is responsible for initializing all context functionalities so that they are ready for use, as well as for "mapping" certain values to centralize all imports required for presentations in a single place.
internal/app/(presentations)
[!TIP] VSCode Snippets available (We can see them in IntelliSense (
Ctrl+Space) or simply by typinggo-).
errors.New[...](), errors.BubbleUp() & errors.Panic()Domain layer and in the *_test.go files can we throw errors.Panic().New*(), Open() & Close()sessionerrors.New[...]() & errors.BubbleUp()Run(), Handle() & On()errors.New[...]() & errors.BubbleUp()Start() & Stop()errors.BubbleUp()Init(), Up() & Down()log.[Wrap]()errors.New[...]() & `errors.BubbleU$ claude mcp add codexgo \
-- python -m otcore.mcp_server <graph>