Our e-commerce platform will follow this directory structure
rmshop-clean-architecture/
│
├── cmd/
│ ├── api/
│ │ └── main.go # Main application entry point
│ └── seedadmin/
│ └── main.go # Admin seeding command
│
├── internal/
│ ├── config/
│ │ └── config.go # Application configuration
│ │
│ ├── delivery/
│ │ └── http/
│ │ ├── handlers/
│ │ │ ├── user_handler.go
│ │ │ ├── admin_handler.go
│ │ │ ├── product_handler.go
│ │ │ └── ...
│ │ ├── middleware/
│ │ │ ├── auth.go
│ │ │ └── ...
│ │ └── routes.go
│ │
│ ├── domain/
│ │ ├── user.go
│ │ ├── product.go
│ │ └── ...
│ │
│ ├── repository/
│ │ ├── interfaces.go
│ │ └── postgres/
│ │ ├── user_repository.go
│ │ ├── product_repository.go
│ │ └── ...
│ │
│ ├── usecase/
│ │ ├── user_usecase.go
│ │ ├── product_usecase.go
│ │ └── ...
│ │
│ └── server/
│ └── server.go
│
├── pkg/
│ ├── auth/
│ │ └── jwt.go
│ ├── database/
│ │ ├── migrations.go
│ │ └── postgres.go
│ └── ...
│
├── migrations/
│ ├── 001_create_users_table.up.sql
│ ├── 001_create_users_table.down.sql
│ └── ...
│
├── go.mod
├── go.sum
└── README.md
This structure adheres to clean architecture principles
-
cmd/
: Contains the main applications of the project. internal/
: Houses the core application code, inaccessible to other projects.config/
: Application configuration.delivery/
: Handles how the data is presented to and received from the user.domain/
: Defines core business logic and entities.repository/
: Handles data storage and retrieval.usecase/
: Contains application-specific business rules.server/
: Manages the HTTP server setup.pkg/
: Shared packages that can be used by external applications.migrations/
: Database migration files.
Top comments (0)