Codexgo
Example CRUD project applying Hexagonal Architecture, DDD, EDA, CQRS, BDD, CI, and more... in Go.
Install / Use
/learn @bastean/CodexgoREADME
<h1 align="center">
<!-- [](https://github.com/bastean) -->
</h1>
<div align="center">
</div> <br /> <div align="center"> </div> <div align="center"> </div> <div align="center"> </div>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.
Showcase
<div align="center"> <img src="assets/readme/desktop-home.png" /> <img src="assets/readme/desktop-dashboard.png" /> <img width="49%" src="assets/readme/mobile-home.png" /> <img width="49%" src="assets/readme/mobile-dashboard.png" /> <img src="assets/readme/mail-confirm-account.png" /> <img src="assets/readme/mail-reset-password.png" /> </div>CLI
Run (Demo)
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>".
Installation
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
Usage
[!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
Docker
Run (Demo)
[!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
Features
Project Layout
- Based on Standard Go Project Layout.
Git
- Hooks managed by husky:
- Pre-Push:
- Scanning Repository for secrets using TruffleHog CLI and Trivy
- Pre-Commit: lint-staged
- Scanning files for secrets using TruffleHog CLI
- Formatting files using GolangCI-Lint and Prettier.
- Commit-Msg: commitlint
- Check Conventional Commits rules
- Pre-Push:
- Commit message helper using czg.
- Interactive prompt that allows you to write commits following the Conventional Commits rules:
task commit
- Interactive prompt that allows you to write commits following the Conventional Commits rules:
Scanners
- TruffleHog CLI: Secrets.
- Trivy: Secrets, Vulnerabilities and Misconfigurations.
- OSV-Scanner: Vulnerabilities.
Linters/Formatters
*.go: GolangCI-Lint.*.templ: templ fmt.*.feature(Gherkin): Cucumber extension.*.*: Prettier cli/extension.
Debuggers
*.go: deadcode.
Tests
- Random data generator: Gofakeit.
- Unit/Integration: Testify.
- Acceptance: Testify, Godog (Cucumber) and Playwright.
Releases
- Automatically managed by Release It!:
- Before/After Hooks for:
- Linting
- Testing
- Bump version based on Conventional Commits and SemVer:
- CHANGELOG generator
- Commits and Tags generator
- GitHub Releases
- Before/After Hooks for:
GitHub
- Actions for:
- Setup Languages and Dependencies (setup)
- Workflows running:
- Issue Templates (Defaults).
Devcontainer
- Multiple Features already pre-configured:
- Go
- Task
- Docker in Docker
- Light-weight Desktop (Fluxbox)
- SSH
- Extensions and their respective settings to work with:
- Go
- Task
- Docker
- MongoDB
- Postman
- templ
- Cucumber
- Gherkin
- YAML
- TOML
- Prettier
- Better Comments
- Comment Divider
- Todo Tree
- cSpell
- Fomantic Snippets
Docker
- Dockerfile
- Multi-stage builds:
- Development
- Testing
- Build
- Production
- Multi-stage builds:
- Compose
- Switched by ENVs and Profiles.
Broker
- Message Routing Key based on AsyncAPI Topic Definition.
Server
Security
- Server log files.
- Requests Rate Limiting.
- Data authentication via JWT managed by Session Cookies.
- Captcha implementation in forms.
- Form validation at the client using Fomantic - Form Validation.
- On the server, the validations are performed using the Value Objects defined in the **C

