JubaerHossain / golang-starter-fiber

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Golang Starter Fiber

Table of Contents

Project Structure

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.

Setup

  1. Clone the repository:

    git clone https://github.com/JubaerHossain/golang-starter-fiber.git
    cd golang-starter-fiber
  2. Install dependencies:

     go mod tidy
  3. 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
  4. Start the server:

    go run main.go

Usage

API Endpoints

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

Build the Docker image:

docker build -t golang-starter-fiber .

Run the Docker container:

docker run -p 3000:3000 golang-starter-fiber

API Documentation

The API documentation is available at http://localhost:3000/api-docs.

Contributing

Contributions are welcome! Please refer to the contributing guide for more details.

License

This project is licensed under the MIT License.

About

License:MIT License


Languages

Language:Go 86.9%Language:Dockerfile 6.8%Language:HTML 6.3%