8000 GitHub - gfteix/book_loan_system
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

gfteix/book_loan_system

Repository files navigation

Book Loan System

A backend system to manage book loans.

Features

  • Create, retrieve, and list users
  • Retrieve books with filters
  • Retrieve book details and book item details
  • Lend and return book items
  • Notify users via email when a loan is about to expire

System Overview

Database Diagram

Database Modeling

System Design

System Design

Technologies Used

  • Go - Backend
  • PostgreSQL - Database
  • Docker - Containerization
  • RabbitMQ - Message queuing

TODO

  • Build API
  • Build loan expiring job
  • Build email handler
  • Add database migrations
  • Dockerfiles
  • Docker Compose
  • Swagger Docs
  • Rename book_copies to book_copies (db, code, db diagram and NOTES.md)
  • Integrate with Prometheus for metrics?

Getting Started

Setup and Run

  1. Create a .env file based on .env.example.

  2. Build and start the infrastructure:

    docker compose --env-file .env build --no-cache && docker compose --env-file .env up -d --force-recreate

API Documentation

Once the API is running, you can access the Swagger docs at:

http://localhost:8080/swagger/index.html

Alternatively, you can open the HTML documentation manually from the docs/ folder in a browser.

API Endpoints

User Management

Create a User

curl -X POST http://localhost:8080/users \
-H "Content-Type: application/json" \
-d '{
  "name": "John",
  "email": "john@example.com"
}' -v

Get Users

curl "http://localhost:8080/users"

Get a User by ID

curl http://localhost:8080/users/{id}

Book Management

Create a Book

curl -X POST http://localhost:8080/books \
-H "Content-Type: application/json" \
-d '{
  "title": "Book Title",
  "description": "A detailed description",
  "isbn": "123456789",
  "author": "Author Name",
  "numberOfPages": 250
}' -v

Search Books by Title

curl "http://localhost:8080/books?title=example"

Get a Book by ID

curl http://localhost:8080/books/{book_id}

Book Item Management

Create a Book Item

curl -X POST http://localhost:8080/books/{book_id}/items \
-H "Content-Type: application/json" \
-d '{
  "bookId": "book_uuid",
  "status": "available",
  "condition": "good",
  "location": "Section B"
}' -v

Get Book Items for a Book

curl http://localhost:8080/books/{book_id}/items

Loan Management

Create a Loan

curl -X POST http://localhost:8080/loans \
-H "Content-Type: application/json" \
-d '{
  "userId": "user_uuid",
  "status": "active",
  "bookCopyId": "book_item_uuid",
  "loanDate": "2025-01-26T15:30:00Z",
  "expiringDate": "2025-01-27T15:30:00Z"
}' -v

Get Loans by User ID

curl "http://localhost:8080/loans?userId={user_id}"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0