backend

module
v0.0.0-...-00ede10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2025 License: MIT

README

Book Rental System API

Book Rental System is a RESTful API that allows users to browse, borrow, and return books from a virtual library. The system tracks book inventory, user accounts, rental history, and fees.

Technology Stack

  • Backend Language: Golang
  • Database: PostgreSQL (running in Docker container)
  • Web Framework: Gin
  • Database Migration: go-migrate
  • Testing: GoMock for mocking framework
  • Configuration: .env file
  • Build System: Makefile

Core Features

  1. User Management

    • User registration and authentication
    • User profile management
    • Role-based access control (Admin, Librarian, Member)
  2. Book Catalog Management

    • Add, update, and delete books
    • Book categorization and metadata management
    • Search and filter capabilities
    • Book availability status
  3. Rental Operations

    • Book borrowing process
    • Book return process
    • Rental period extension
    • Overdue book management
  4. Fees and Payments

    • Rental fee calculation
    • Late return penalty calculation
    • Payment processing
    • Refund handling
  5. Reporting and Analytics

    • Usage statistics
    • Popular book reports
    • Revenue reports
    • User activity reports

Installation

Requirements
  • Go 1.21+
  • Docker and Docker Compose
  • Make
Development Environment Setup
  1. Clone repository:

    git clone https://github.com/yourusername/book-rental-system.git
    cd book-rental-system
    
  2. Install necessary tools:

    make setup
    
  3. Create .env file from .env.example:

    cp .env.example .env
    
  4. Start PostgreSQL using Docker:

    make docker-db
    
  5. Run database migrations:

    make migrate-up
    
  6. Run development server:

    make run
    
Using Docker

To run the entire application in Docker:

make docker-run

API Endpoints

See the full API documentation in docs/prd.md.

Development

Project Structure
.
├── cmd/                  # Application entry points
│   └── api/              # API server
├── docs/                 # Documentation
├── internal/             # Internal code
│   ├── api/              # API handlers
│   ├── domain/           # Domain definitions and interfaces
│   ├── repository/       # Repository implementations
│   └── service/          # Service implementations
├── migrations/           # Database migrations
├── pkg/                  # Reusable packages
│   ├── auth/             # Authentication and authorization
│   ├── config/           # Configuration
│   └── logger/           # Logging
├── .env.example          # Example configuration file
├── docker-compose.yml    # Docker Compose configuration
├── Dockerfile            # Docker configuration
├── go.mod                # Go dependencies
├── go.sum                # Go dependencies checksum
└── Makefile              # Make commands
Useful Commands
  • make run: Run development server
  • make test: Run tests
  • make migrate-up: Run database migrations
  • make migrate-down: Rollback database migrations
  • make mock: Generate mocks for testing
  • make build: Build production binary
  • make docker-build: Build Docker image
  • make docker-run: Run Docker containers
  • make docker-stop: Stop Docker containers
  • make clean: Clean up

License

MIT

Directories

Path Synopsis
cmd
api command
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.
internal
api
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL