Skip to content

Architecture

Automatically generated structure

The following structure is generated by Ava according to your choices (with or without a database). You can modify it at any time.

Limitations

  • Security management, complex migrations, or unit tests are not included by default.
  • Make sure to adapt the Docker and CI configuration to your environment.

Generated project structure

<service>/
├── cmd/
│   └── <service-name>/
│       └── main.go       # Entry point
├── internal/
│   ├── api/
│   │   ├── handlers/     # HTTP Handlers
│   │   └── routers/      # Route definitions
│   ├── configs/          # Configuration (Env, Viper)
│   ├── db/               # Database init & migrations (Optional)
│   ├── helpers/          # Utilities
│   ├── models/           # Data entities
│   ├── repositories/     # Data access layer (Interfaces & Gorm impl)
│   ├── server/           # HTTP Server setup (Gin, Middlewares)
│   └── services/         # Business logic layer
├── .env
├── .gitignore
├── Dockerfile
├── docker-compose.yaml
└── README.md             # Detailed implementation guide

Key Components

  • Entry Point: cmd/<service-name>/main.go wires up dependencies (Repositories, Services, Handlers) and starts the server.
  • Clean Architecture:
    • Handlers: Parse requests and call Services.
    • Services: Contain business logic.
    • Repositories: Handle data access (DB).
  • Observability:
    • Prometheus: /metrics endpoint (Optional, via --with-prometheus).
    • Sentry: Error tracking (Optional, via --with-sentry & SENTRY_DSN).
    • Swagger: API Documentation (Optional, via --with-swagger).

Automatic generation

The Ava command creates all these files and folders according to your choices. It also generates a specific README.md inside your new service to guide you through implementing the Repository Pattern.