Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • B boilerplate
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 7
    • Merge requests 7
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Terraform modules
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Pavel Shustrov
  • boilerplate
  • Merge requests
  • !6

Zain/code structure

  • Review changes

  • Download
  • Patches
  • Plain diff
Open Zain Basharat requested to merge zain/code-structure into master Apr 14, 2022
  • Overview 1
  • Commits 3
  • Pipelines 0
  • Changes 41

Following the discussions we had so far and also adding some learnings from this repo https://github.com/golang-standards/project-layout. I did the following changes

  • pkg folder on root level contains all the packages we want to make publicly available. i.e. http/grpc clients or some common util lib

  • internal has some new folders pkg, usecase and entities

    • pkg will contain all the libs we are going to use and create wrappers around it if needed to make code agnostic of vendors.
    • entities are acting as DTO objects - @akundu
    • usecase where you will aggregate your business logic from different services. a use case can granular or can grouped in multiple functions (in current code file will be used as a group). @akundu
  • factory.go is a file which is added in folder where we need to create objects for external use. if needed this will return objects to all internal packages and will only take the dependencies which are not available in current or any of the child packages. (think of a tree)

  • service folder will contain domain specific packages (which are flat)

  • cmd is used to handle all the communication we will have from outer traffic. we can define different protocols as an outer layer and call the use cases which does the actual work.

  • cmd/server/http contains the http server definition using gin-gonic lib and handles all the network layer logic.

Edited Apr 14, 2022 by Zain Basharat
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: zain/code-structure

For any queries, kindly contact us on Slack channel https://cafuglobal.slack.com/archives/C056RSXMPB7