Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jubaerhossain/golang-starter-fiber


https://github.com/jubaerhossain/golang-starter-fiber

Last synced: 5 days ago
JSON representation

Awesome Lists containing this project

README

        

# Golang Starter Fiber

## Table of Contents

- [Project Structure](#project-structure)
- [Setup](#setup)
- [Usage](#usage)
- [Contributing](#contributing)
- [License](#license)

## 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:

```bash
git clone https://github.com/JubaerHossain/golang-starter-fiber.git
cd golang-starter-fiber
```

2. Install dependencies:

```bash
go mod tidy
```

3. Create a `.env` file in the root directory and add the following environment variables:

```bash
# Database
MONGOURI=mongodb://localhost:27017
PORT=3000
APP_URL=http://localhost
DB_NAME=hrm
```

4. Start the server:

```bash
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:

```bash
docker build -t golang-starter-fiber .
```

## Run the Docker container:

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

### API Documentation

The API documentation is available at [http://localhost:3000/api-docs](http://localhost:3000/api-docs).

## Contributing

Contributions are welcome! Please refer to the [contributing guide](CONTRIBUTING.md) for more details.

## License

This project is licensed under the [MIT License](LICENSE).