Categorygithub.com/Debt-Solvers/BE-auth-service
repository
1.0.0
Repository: https://github.com/debt-solvers/be-auth-service.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

Debt Solver - Authentication Microservice

This repository contains the authentication microservice for the Debt Solver project, an expense management mobile application that allows users to track and manage their finances.

Key Features

  • User Registration: Securely create and store user accounts.
  • User Login: Validate credentials and issue JWT tokens for session management.
  • Password Management: Hash and securely manage user passwords.
  • Authorization: Protect routes with JWT authentication.

Technologies Used

  • Golang & Gin: For building the service.
  • PostgreSQL: For storing user data.
  • GORM: For ORM database interactions.
  • JWT: For user authentication and authorization.
  • Bcrypt: For password hashing.
  • Viper: For configuration management.

Directory Structure

auth-service/
│
├── cmd/
│   └── auth-service/
│       └── main.go                  # Entry point for the application
│
├── configs/
│   └── config.yaml                  # Configuration file for the service
│
├── db/
│   └── migrate.go                   # Database migrations
│
├── internal/
|   |── common/
│   │   └── common.go                # common utility codes for dynamic use
│   ├── controller/
│   │   └── auth_controller.go       # Controller for authentication handlers
│   ├── middleware/
│   │   └── auth_middleware.go       # Middleware for JWT authentication
│   ├── model/
│   │   └── user.go                  # User model and database interactions
│   └── routes/
│       └── routes.go                # Define routes for authentication endpoints
│
├── utils/
│   └── response.go                  # Utility functions for handling responses
│
├── Dockerfile                       # Dockerfile for building the container
├── go.mod                           # Go module file
└── README.md                        # Project documentation

Setup and Installation

git clone https://github.com/debt-solver/DB-auth.git
cd debt-solver-auth

Setup PostgreSQL

docker run --name debt-solver-postgres -e POSTGRES_PASSWORD=yourpassword -d -p 5432:5432 postgres

Install Dependencies

go mod tidy

SMTP Testing

Mailtrap.io Server Will be used for testing purpose

{{d.backend.developer.personal.email.will.receive.all.code}}

Run Database Migrations

Setup the database schema using the migration file

Run the application

go run cmd/auth-service/main.go

Build and Run with Docker

docker build -t auth-service .
docker run -p 8080:8080 auth-service

API Endpoints

POST /signup: Register a new user POST /login: Authenticate and receive a JWT token

POST /reset-password POST /logout POST /verify-email

Environment Varibles

DB_HOST=localhost DB_PORT=5432 DB_USER=postgres DB_PASSWORD=root

JWT_SECRET=DebtSolver JWT_EXPIRATION_HOURS=24

License

This project is open-source and licensed under the MIT License.

Contributions

Contributions are welcome! Feel free to open an issue or submit a pull request.