This project aims to create a REST API that connects directly to MongoDB, performing CRUD operations. I developed the API using the Go programming language and the GIN framework, and all endpoints are documented with Swagger.
To facilitate deployment and ensure consistency of the development environment, I used Docker to upload and manage the MongoDB instance.
The project design is modular, following recognized development standards. I carefully selected the logic and structure, creating a specific folder for settings. This folder includes log files, connection to MongoDB and database initialization.
I developed a custom logger to handle various responses and information from endpoints, from success responses to errors.
I opted for a custom approach to data validation, avoiding external libraries, which allowed me to validate JSON structures accurately.
To speed up development, I also created a Makefile with customized commands that facilitate routine tasks.
To use it, you need to clone the repository, install the dependencies and run the project.
# Up Docker
$ docker compose up
# Open terminal/cmd and then Clone this repository
$ git clone https://github.com/JuanCampbsi/go_api_mongo_db.git
# Access project folder in terminal/cmd
$ cd go_api_mongo_db
# Install the dependencies
$ go mod tidy
# Run the application in development mode
$ go run main.go
- Golang - version 1.20
- GIN - version 1.9.0
- GORM - version 1.25.1
- MongoDB - version 1.12.1
- Swaggo - version 1.16.1
- Docker_Compose - version 3
👨💻 Author 💻
Developed by Juan Campos