Giter Club home page Giter Club logo

go-structure's Introduction

Golang Project Structure

Overview📦

This project structure is designed for Golang projects and is based on the hexagonal architecture, with some modifications😵.

/cmd

This directory serves as the entry point for the application, containing the main.go file. Keep the code in this directory minimal.

/internal

This directory contains the functional code for the application, including routing and database interactions.

/database

This directory contains the configuration file for the database used in the project. In this example, the database used is PostgreSQL.

internal/ports

This directory contains two files: repository.go and service.go. These files define the functions of the application, with repository.go responsible for querying the database (Data Access Layer) and service.go containing the business logic.

internal/repositories

This directory contains the ORM (such as gorm) used to query the database on function calls from the service layer.

internal/services

This directory contains functions called by the repository layer and contains the business logic of the application. It is framework agnostic.

internal/handler

This directory contains the application's routes and is not framework agnostic. Functions in this directory can only call the service layer.

internal/model

This directory contains the database models with gorm and json extensions.

internal/middleware

This directory contains the middleware functions used inside the handler directory

internal/utils

This directory contains any repeating code, such as code for generating IDs or verifying tokens.

Note🎯

This project structure is not suitable for small projects and may become unwieldy for large projects.

go-structure's People

Contributors

leoantony72 avatar

Stargazers

Edgars Burtnieks avatar Aad Miqdad avatar Edward avatar MS avatar jasonLuFa avatar Adam Reuben avatar Karuppaiah Alagappan avatar Jon Wright avatar Queen Audrey avatar Alexandre Moraes da Silva avatar Beau Hoyt avatar Quang Nguyen avatar Ignasius Wahyudi avatar Christoph Wolf avatar Alessandro Gambin da Silva avatar aobakwe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.