Backend guidelines
Design pattern - MVC design pattern
Structuring a project using the Model-View-Controller (MVC) design pattern involves organizing the codebase into three distinct layers: Model, View, and Controller, each with its specific responsibilities.
Please follow the link for further understanding of design patterns:
Design Patterns
General Structure
Project ⮑bin .gitkeep ⮑cmd ⮑api ⮑migration ⮑deployments .gitkeep ⮑db ⮑migrations .gitkeep ⮑seeds .gitkeep ⮑pkg ⮑database ⮑server ⮑internal ⮑handler ⮑dto ⮑model ⮑service ⮑repository(optional) ⮑docs ⮑openapi ⮑static ⮑.gitkeep .env.example .gitignore Makefile README.md
Coding guidelines ( Based on Golang)
In Go programming, adhering to consistent naming conventions is crucial for readability and maintainability. Here are some naming conventions to follow:
  1. Package Names: Use short, lowercase package names that are concise and descriptive. Avoid using underscores or mixed-case names. For example, a package that provides utilities for handling HTTP requests might be named httputil.
  2. Variable Names: Use camelCase for variable names. Variable names should be descriptive and concise, conveying their purpose and meaning. Local variables should have short, meaningful names, while global variables should be descriptive enough to indicate their purpose. For example:
    • totalCount
    • httpRequest
    • isReady
  3. Constant Names: Use UPPERCASE for constant names to distinguish them from variables. Constants should be named using snake_case and should be descriptive of their purpose. For example:
    • const MaxRetries = 3
    • const Pi = 3.14159
  4. Exported Identifiers: Go uses the concept of exported and unexported identifiers. Exported identifiers (functions, types, variables) start with a capital letter, making them accessible from outside the package. Unexported identifiers start with a lowercase letter and are only accessible within the same package. For example:
    • func ComputeTotal()
    • type User struct { Name string }
    • var apiKey string
  5. Function Names: Use camelCase for function names. Function names should be descriptive and convey the action or purpose of the function. Follow the principle of "verb-noun" naming. For example:
    • getUserByID
    • calculateTotalAmount
    • handleHTTPResponse
  6. Interface Names: Interfaces in Go typically describe behavior and should be named based on the behavior they define. Name interfaces with an 'er' suffix if they describe actions or behaviors. For example:
    • type Reader interface { Read([]byte) (int, error) }
    • type Writer interface { Write([]byte) (int, error) }
  7. Struct Names: Use PascalCase for struct names. Struct names should be descriptive and follow the principle of encapsulating related fields and methods together. For example:
    • type User struct { Name string; Age int }
    • type Point struct { X, Y int }
  8. Error Variables: When declaring error variables, use the err suffix to denote errors. For example:
    • var readErr error
    • var writeErr error
API Standard
For REST API’s please follow the following standard while maintaining swagger documentation as shown below.
OpenAPI
REST
  • Request/Response data
    • Case I / Object data (Singular data)
      // Response data { "responseStatus": "ok", "message":"Successfully created RUDe", "data":{}, "errors":[ { "field":"{field}", "message":"{message}", "code":"{code}" } ], }
    • Case II / List data
      // Request data { "filter":{ "or_condition":[ { "and_condition":[ { "column":"laboris elit eu id", "comparator":"LT", "value":[ "pariatur in irure minim qui", "dolore exercitation cillum est aute" ] }, { "column":"cupidatat adipisicing nisi", "comparator":"GT", "value":[ "tempor officia ut fugiat laborum", "nostrud eiusmod" ] } ] }, { "and_condition":[ { "comparator":"LT", "column":"magna incididunt eiusmod veniam aliquip", "value":[ "deserunt dolore in aute commodo", "qui exercitation occaecat" ] } ] } ], "query":"consequat tempor" }, "pagination":{ "order":[ "id", "-name" ], "page":1, // for simple pagination "cursor":{ // for cursor pagination "after":"abcd11223", "before":"abcd112244" }, "size":10 } }

      // Response data { "responseStatus": "ok", "message": "Successfully created RUDe", "data": [], "errors": [ { "field": "{field}", "message": "{message}", "code": "{code}" } ], "pagination": { "totalPages": "string", "cursor": { "startCursor": "string", "endCursor": "string", "hasNextPage": true, "hasPreviousPage": true }, "currentPage": "string", "totalCount": "string" } }