The project follows a modular structure for better organization. Here's a breakdown of the main components:
- app: Contains the application logic and main entry point.
- controllers: Handles HTTP requests, business logic, and response formatting.
- database: Manages database connections and interactions.
- models: Defines data structures and entities used in the application.
- repository: Provides an abstraction for database operations.
- routes: Defines API endpoints and connects them to controller methods.
- services: Implements the core business logic and interacts with repositories.
- utils: Contains utility functions and shared components.
- main.go: The application's entry point.
-
Clone the repository:
git clone https://github.com/JubaerHossain/golang-starter-fiber.git cd golang-starter-fiber
-
Install dependencies:
go mod tidy
-
Create a
.env
file in the root directory and add the following environment variables:# Database MONGOURI=mongodb://localhost:27017 PORT=3000 APP_URL=http://localhost DB_NAME=hrm
-
Start the server:
go run main.go
Endpoint | Method | Description |
---|---|---|
/api/users | GET | Get all users |
/api/users | POST | Create a new user |
/api/users/:id | GET | Get a user by ID |
/api/users/:id | PUT | Update a user by ID |
/api/users/:id | DELETE | Delete a user by ID |
docker build -t golang-starter-fiber .
docker run -p 3000:3000 golang-starter-fiber
The API documentation is available at http://localhost:3000/api-docs.
Contributions are welcome! Please refer to the contributing guide for more details.
This project is licensed under the MIT License.