Skip to content

Unknowns24/backend-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backend Application Structure

To develop a RESTful application in Go with a structure that is easy to maintain and scalable in the future, as well as optimized in terms of development time and performance, you can consider the following structure and some recommendations:

Project Structure:

  • cmd/: This directory will contain the main entry point of the application, as well as any scripts or files related to running the application.
  • internal/: This directory will contain the internal code of the application, including controllers, middleware, models, and any other application-specific components.
    • api/: Contains code related to the REST API.
      • handlers/: Contains code related to the REST API handlers.
    • db/: Contains code related to database connection and database operations.
    • models/: Contains application data structures.
    • logs/: Contains application logs.
  • pkg/: This directory will contain reusable packages that can be used by other applications if necessary.
    • thirdparty/: Contains code related to integrations with third-party APIs.
    • middleware/: Contains code for application middlewares.
  • config/: This directory may contain configuration files for the application.
  • scripts/: This directory may contain scripts related to building, testing, or deploying the application.
  • tests/: This directory will contain the application's tests.

Library/Framework Choice:

Chi Framework: It's a lightweight, high-performance HTTP router built on top of net/http. It provides additional features such as multiplexed routing, middleware, and a set of useful utilities that can speed up development. Chi is an excellent choice if you want a balance between performance and ease of development.

Final Recommendations:

Use the sql library from the Go standard library to interact with the database if you don't need an ORM layer. It's simple and efficient.

Use interfaces to define contracts between different components of your application, making testing and implementation substitution easier.

Divide your code into logical packages and modules to facilitate navigation and maintenance.

Implement unit tests and integration tests to ensure the stability and reliability of your application.

Use tools like go fmt, go vet, go lint, and golangci-lint to maintain code quality and adhere to Go conventions.


With this structure and recommendations, you'll be able to develop a RESTful application in Go that is easy to maintain in the future and optimized in terms of development time and performance. The choice between net/http and Chi Framework will depend on your specific needs and personal preferences.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages