/Library-Digital-Management-System-MVP

Streamlined digital library management system for cataloging, lending, and user access.... Created at https://coslynx.com

Primary LanguagePython

Library-Digital-Management-System-MVP

A backend system for streamlined library operations

Developed with the software and tools below.

Framework-FastAPI-blue Language-Python-red Database-PostgreSQL-blue LLMs-Custom,_Gemini,_OpenAI-black
git-last-commit GitHub commit activity GitHub top language

๐Ÿ“‘ Table of Contents

  • ๐Ÿ“ Overview
  • ๐Ÿ“ฆ Features
  • ๐Ÿ“‚ Structure
  • ๐Ÿ’ป Installation
  • ๐Ÿ—๏ธ Usage
  • ๐ŸŒ Hosting
  • ๐Ÿ“„ License
  • ๐Ÿ‘ Authors

๐Ÿ“ Overview

This repository houses the backend for the Efficient Library Digital Management System MVP. This system streamlines library operations by providing a robust backend system for managing library resources, handling user authentication and authorization, processing borrowing requests, and tracking due dates. The tech stack includes FastAPI, Python, PostgreSQL, and leverages custom LLMs like Gemini and OpenAI.

๐Ÿ“ฆ Features

Feature Description
โš™๏ธ Architecture The system uses a modular architecture with separate modules for authentication, book management, and user management, ensuring ease of development and maintenance.
๐Ÿ“„ Documentation This README file provides a detailed overview of the MVP, its dependencies, and instructions on how to set up and run the system.
๐Ÿ”— Dependencies The project relies on external libraries such as FastAPI, SQLAlchemy, psycopg2, and Pydantic for efficient development and robust data handling.
๐Ÿ” Security The system implements security measures, including JWT authentication for secure access and data validation to prevent vulnerabilities.
โšก๏ธ Performance The system optimizes performance by leveraging FastAPI's high-performance capabilities, efficient database queries, and appropriate data structures.
๐Ÿ“ถ Scalability The system is designed for scalability, utilizing a robust database like PostgreSQL and efficient architecture to handle increasing user load and data volume.
๐Ÿ”Œ Integrations The system can integrate with external APIs like OCLC or Worldcat for retrieving bibliographic data and external authentication systems.
๐Ÿงช Testing Unit tests are included to verify the correctness and robustness of the authentication, book management, and user management logic.
๐Ÿ”€ Version Control The project utilizes Git for version control and employs a robust CI/CD pipeline for automated builds and deployments.

๐Ÿ“‚ Structure

โ””โ”€โ”€ api
    โ””โ”€โ”€ routes
        โ””โ”€โ”€ auth_routes.py
        โ””โ”€โ”€ book_routes.py
        โ””โ”€โ”€ user_routes.py
    โ””โ”€โ”€ main.py
    โ””โ”€โ”€ dependencies.py
โ””โ”€โ”€ models
    โ””โ”€โ”€ book.py
    โ””โ”€โ”€ user.py
โ””โ”€โ”€ services
    โ””โ”€โ”€ auth_service.py
    โ””โ”€โ”€ book_service.py
    โ””โ”€โ”€ user_service.py
โ””โ”€โ”€ utils
    โ””โ”€โ”€ database.py
    โ””โ”€โ”€ config.py
    โ””โ”€โ”€ auth.py
    โ””โ”€โ”€ exceptions.py
    โ””โ”€โ”€ logger.py
    โ””โ”€โ”€ helpers.py
โ””โ”€โ”€ tests
    โ””โ”€โ”€ unit
        โ””โ”€โ”€ test_auth_service.py
        โ””โ”€โ”€ test_book_service.py
        โ””โ”€โ”€ test_user_service.py
โ””โ”€โ”€ .env
โ””โ”€โ”€ .gitignore
โ””โ”€โ”€ README.md
โ””โ”€โ”€ requirements.txt
โ””โ”€โ”€ startup.sh
โ””โ”€โ”€ commands.json

๐Ÿ’ป Installation

๐Ÿ”ง Prerequisites

  • Python 3.9+
  • PostgreSQL 15+
  • Docker (recommended)

๐Ÿš€ Setup Instructions

  1. Clone the repository:
    git clone https://github.com/coslynx/Library-Digital-Management-System-MVP.git
    cd Library-Digital-Management-System-MVP
  2. Create a virtual environment:
    python -m venv .venv
    source .venv/bin/activate
  3. Install dependencies:
    pip install -r requirements.txt
  4. Configure environment variables:
    • Create a .env file in the project root directory.
    • Copy the .env.example file and replace the placeholder values with your actual configuration:
      DATABASE_URL=postgres://user:password@host:port/database
      JWT_SECRET=your_secret_key
      HOST=0.0.0.0
      PORT=8000
      DB_HOST=localhost
      DB_PORT=5432
      DB_USER=user
      DB_PASSWORD=password
      DB_NAME=database
      

๐Ÿ—๏ธ Usage

๐Ÿƒโ€โ™‚๏ธ Running the MVP

  1. Start the database (using Docker Compose):
    docker-compose up -d database
  2. Start the backend server:
    uvicorn api.main:app --host $HOST --port $PORT --reload
  3. Access the API:
    • The API is now accessible at http://localhost:8000 (or the specified port in .env).

โš™๏ธ Configuration

  • .env file: This file contains environment variables for configuring the database connection, JWT secret key, server host and port, and other settings.
  • Database Configuration:
    • Ensure that the database is running and configured correctly.
    • Update the DATABASE_URL environment variable with your database credentials.
  • JWT Secret Key:
    • Create a strong secret key for JWT token generation and store it in the JWT_SECRET environment variable.

๐Ÿ“š Examples

  • Register a new user:
    curl -X POST http://localhost:8000/api/register \
    -H "Content-Type: application/json" \
    -d '{"username": "newuser", "email": "user@example.com", "password": "securepass123"}'
  • Login an existing user:
    curl -X POST http://localhost:8000/api/login \
    -H "Content-Type: application/json" \
    -d '{"email": "user@example.com", "password": "securepass123"}'
  • Search for a book:
    curl -X GET http://localhost:8000/api/books?title=The%20Hobbit

๐ŸŒ Hosting

๐Ÿš€ Deployment Instructions

Docker Deployment

  1. Build the Docker image:
    docker build -t library-backend .
  2. Run the container:
    docker run -p 8000:8000 library-backend

Other Hosting Options

  • AWS Elastic Beanstalk: Consider using Elastic Beanstalk for easy deployment to AWS.
  • Heroku: Heroku is a popular choice for deploying Python applications.

๐Ÿ”‘ Environment Variables

  • DATABASE_URL: Connection string for the PostgreSQL database.
    • Example: postgresql://user:password@host:port/database
  • JWT_SECRET: Secret key for JWT token generation.
    • Example: your-256-bit-secret
  • HOST: Server host.
    • Example: 0.0.0.0
  • PORT: Server port.
    • Example: 8000
  • DB_HOST: Database host.
    • Example: localhost
  • DB_PORT: Database port.
    • Example: 5432
  • DB_USER: Database user.
    • Example: user
  • DB_PASSWORD: Database password.
    • Example: password
  • DB_NAME: Database name.
    • Example: database

๐Ÿ“œ API Documentation

๐Ÿ” Endpoints

  • POST /api/register: Register a new user.
    • Request Body: JSON object with username, email, and password.
    • Response: 201 (Created) if successful, 400 (Bad Request) if there are validation errors.
  • POST /api/login: Logs in an existing user.
    • Request Body: JSON object with email and password.
    • Response: 200 (OK) with JWT token if successful, 401 (Unauthorized) if authentication fails.
  • GET /api/books: Retrieves a list of all books.
    • Response: 200 (OK) with a JSON array of book objects.
  • GET /api/books/{book_id}: Retrieves details for a specific book.
    • Response: 200 (OK) with a JSON object representing the book, 404 (Not Found) if the book doesn't exist.
  • POST /api/books: Creates a new book record.
    • Request Body: JSON object with book details (e.g., title, author, ISBN, etc.).
    • Response: 201 (Created) if successful, 400 (Bad Request) if there are validation errors.
  • PUT /api/books/{book_id}: Updates an existing book record.
    • Request Body: JSON object with updated book details.
    • Response: 200 (OK) if successful, 404 (Not Found) if the book doesn't exist.
  • DELETE /api/books/{book_id}: Deletes a book record.
    • Response: 204 (No Content) if successful, 404 (Not Found) if the book doesn't exist.

๐Ÿ”’ Authentication

  • The system utilizes JSON Web Tokens (JWT) for user authentication.
  • Upon successful registration or login, a JWT token is issued.
  • Include the JWT token in the Authorization header of subsequent requests using the format: Authorization: Bearer YOUR_JWT_TOKEN.

๐Ÿ“ Examples

# Register a new user
curl -X POST http://localhost:8000/api/register \
-H "Content-Type: application/json" \
-d '{"username": "newuser", "email": "user@example.com", "password": "securepass123"}'

# Login an existing user
curl -X POST http://localhost:8000/api/login \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "securepass123"}'

# Search for a book
curl -X GET http://localhost:8000/api/books?title=The%20Hobbit 

# Retrieve book details
curl -X GET http://localhost:8000/api/books/123

# Create a new book
curl -X POST http://localhost:8000/api/books \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{"title": "The Hitchhiker's Guide to the Galaxy", "author": "Douglas Adams", "isbn": "0345391802"}'

๐Ÿ“œ License & Attribution

๐Ÿ“„ License

This Minimum Viable Product (MVP) is licensed under the GNU AGPLv3 license.

๐Ÿค– AI-Generated MVP

This MVP was entirely generated using artificial intelligence through CosLynx.com.

No human was directly involved in the coding process of the repository: Library-Digital-Management-System-MVP

๐Ÿ“ž Contact

For any questions or concerns regarding this AI-generated MVP, please contact CosLynx at:

๐ŸŒ CosLynx.com

Create Your Custom MVP in Minutes With CosLynxAI!