Skip to content

Latest commit

 

History

History
105 lines (82 loc) · 1.87 KB

README.md

File metadata and controls

105 lines (82 loc) · 1.87 KB

Go User Management Service

A RESTful user management service built with Go, MongoDB, and Uber Fx for dependency injection.

Features

  • User registration and authentication
  • Password hashing using bcrypt
  • MongoDB for data persistence
  • Dependency injection using Uber Fx
  • RESTful API endpoints for CRUD operations

Prerequisites

  • Go 1.21 or higher
  • MongoDB running on localhost:27017

Installation

  1. Clone the repository:
git clone <repository-url>
cd go-di-webservice
  1. Install dependencies:
go mod tidy
  1. Run the application:
go run main.go

The server will start on http://localhost:8080.

API Endpoints

Create User

POST /users
Content-Type: application/json

{
    "email": "[email protected]",
    "password": "password123",
    "first_name": "John",
    "last_name": "Doe"
}

Get User

GET /users/{id}

Update User

PUT /users/{id}
Content-Type: application/json

{
    "first_name": "John",
    "last_name": "Doe",
    "password": "newpassword" // Optional
}

Delete User

DELETE /users/{id}

Login

POST /users/login
Content-Type: application/json

{
    "email": "[email protected]",
    "password": "password123"
}

Project Structure

.
├── internal/
│   ├── config/      # MongoDB configuration
│   ├── models/      # Data models
│   ├── repositories/# Data access layer
│   ├── services/    # Business logic
│   └── handlers/    # HTTP handlers
├── main.go         # Application entry point
└── README.md

Dependencies