- ๐ Overview
- ๐ฆ Features
- ๐ Structure
- ๐ป Installation
- ๐๏ธ Usage
- ๐ Hosting
- ๐ License
- ๐ Authors
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.
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. |
โโโ 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
- Python 3.9+
- PostgreSQL 15+
- Docker (recommended)
- Clone the repository:
git clone https://github.com/coslynx/Library-Digital-Management-System-MVP.git cd Library-Digital-Management-System-MVP
- Create a virtual environment:
python -m venv .venv source .venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- 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
- Create a
- Start the database (using Docker Compose):
docker-compose up -d database
- Start the backend server:
uvicorn api.main:app --host $HOST --port $PORT --reload
- Access the API:
- The API is now accessible at
http://localhost:8000
(or the specified port in.env
).
- The API is now accessible at
.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.
- Create a strong secret key for JWT token generation and store it in the
- 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
- Build the Docker image:
docker build -t library-backend .
- Run the container:
docker run -p 8000:8000 library-backend
- AWS Elastic Beanstalk: Consider using Elastic Beanstalk for easy deployment to AWS.
- Heroku: Heroku is a popular choice for deploying Python applications.
DATABASE_URL
: Connection string for the PostgreSQL database.- Example:
postgresql://user:password@host:port/database
- Example:
JWT_SECRET
: Secret key for JWT token generation.- Example:
your-256-bit-secret
- Example:
HOST
: Server host.- Example:
0.0.0.0
- Example:
PORT
: Server port.- Example:
8000
- Example:
DB_HOST
: Database host.- Example:
localhost
- Example:
DB_PORT
: Database port.- Example:
5432
- Example:
DB_USER
: Database user.- Example:
user
- Example:
DB_PASSWORD
: Database password.- Example:
password
- Example:
DB_NAME
: Database name.- Example:
database
- Example:
- POST
/api/register
: Register a new user.- Request Body: JSON object with
username
,email
, andpassword
. - Response: 201 (Created) if successful, 400 (Bad Request) if there are validation errors.
- Request Body: JSON object with
- POST
/api/login
: Logs in an existing user.- Request Body: JSON object with
email
andpassword
. - Response: 200 (OK) with JWT token if successful, 401 (Unauthorized) if authentication fails.
- Request Body: JSON object with
- 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.
- Request Body: JSON object with book details (e.g.,
- 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.
- 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
.
# 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"}'
This Minimum Viable Product (MVP) is licensed under the GNU AGPLv3 license.
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
For any questions or concerns regarding this AI-generated MVP, please contact CosLynx at:
- Website: CosLynx.com
- Twitter: @CosLynxAI
Create Your Custom MVP in Minutes With CosLynxAI!