golang-mongodb-restful-starter-kit is a golang restful api starter kit using mongoDB and JWT. It is very useful for beginners.
- Used mux for routing
- Used salt to hash the password
- Used JWT for authentication
- Follows repository, service and model structure
- Used interface to hide implementation of repositories and services
- Error handling
├── app // Contains API related files
│ ├── handlers // Contains HTTP handler functions
│ │ ├── authHandler.go // Contains Auth related HTTP handler
│ │ ├── base.go
│ │ └── userHandler.go // Contains User related HTTP handler
│ ├── models // Models contains data models of the application
│ │ └── user.go // User model
│ ├── repositories // Repositories
│ │ └── user
│ │ ├── userRepository.go // UseRepository Interface
│ │ └── userRepositoryImp.go // UserRepository implementation
│ └── services // Services
│ ├── auth
│ │ ├── authService.go // AuthService interface
│ │ └── authServiceImp.go // AthService interface implementation
│ ├── jwt
│ │ └── jwt.go // JWT related operations
│ └── user
│ ├── userService.go // UserService interface
│ └── userServiceImp.go // UserService interface implementation
├── config
│ └── config.go // Environment configurations, read from .env file
├── db
│ └── mongo.go // Mongodb Connection and Session
├── main.go // Starting point of the application
├── .env // Environment configurations
└── utility // Contains helpers, basic operations, commons operations, errors, validations
├── common.go
├── errors.go
├── handler.go
├── role.go
└── string.go
golang-mongodb-restful-starter-kit requires Go 1.10+ to run.
Install the dependencies and devDependencies and start the server.
$ git clone https://github.com/ypankaj007/golang-mongodb-restful-starter-kit.git
$ cd golang-mongodb-restful-starter-kit
$ go get
For production release:
$ go build
- Email verification
- Containerized - Docker + Kubernetes
- Write Tests
- Write scripts
Project uses a number of open source projects to work properly:
- Go - Awesome programing language by Google
- mux - Implements a request router and dispatcher in Go
- MongoDB - document-based, big community, database
- Redis - in-memory database using key-value pairs
- Docker - Build, Share, and Run Any App, Anywhere
- Kubernetes - Automating deployment, scaling, and management of containerized applications
API endpoint - http://localhost:8080 Swagger endpoint - http://localhost:8080/swagger/index.html