E-Commerce Platform with Golang : Project Directory Structure

mohamedfawas1

MOHAMED FAWAS

Posted on October 4, 2024

E-Commerce Platform with Golang : Project Directory Structure

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
Enter fullscreen mode Exit fullscreen mode

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.

💖 💪 🙅 🚩
mohamedfawas1
MOHAMED FAWAS

Posted on October 4, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related