library

command module
v0.0.0-...-a622e30 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: GPL-3.0 Imports: 21 Imported by: 0

README ΒΆ

πŸ“š Library

Library is a lightweight πŸ“– web application built exclusively for cataloging and organizing your local ebook collection. It is not an online ebook reader β€” instead, it is designed as a central repository from which various ebook readers can download ebooks.

Think of it as a personal ebook server: it scans your local collection, extracts metadata, and makes it accessible through a clean, searchable web interface.


✨ Features

  • πŸ” Scans directories for ebooks (.epub, .mobi)
  • 🏷️ Extracts and categorizes metadata (title, author, etc.)
  • 🌐 Downloads missing metadata from external sources (currently moly.hu)
  • 🧭 Searchable web interface
  • πŸ’Ύ Stores data in a database (local, or remote) (mysql or mariadb)
  • πŸ“€ Designed to serve ebooks to external ebook readers (e.g. via download links)
  • 🐳 Optional Docker support for easy deployment with configurable volumes, user IDs (PUID/PGID), and environment variables

⚠️ Disclaimer

This application does not implement any user management, authentication, or security features.
It is designed to run:

  • locally on a trusted machine, or
  • behind a secure reverse proxy with authentication (e.g., Authelia, OAuth2 proxy, etc.)

Do not expose this application directly to the internet without proper protection.

πŸš€ Getting Started

Requirements
  • βœ… Go 1.21+
  • βœ… Mysql/mariadb database
  • βœ… Local folder with ebooks
Installation
git clone https://github.com/ignisVeneficus/library.git
cd library
go build -o library

Set up the environment variables than

./library

Then visit πŸ‘‰ http://localhost:8888

βš™οΈ Configuration

Set environment variables:

The application uses the following environment variables for configuration:

Variable Description Required
LIBRARY_DB_USERNAME Database username βœ…
LIBRARY_DB_PASSWORD Database password βœ…
LIBRARY_DB_HOST Database host URL βœ…
LIBRARY_DB_DATABASE Database name βœ…
LIBRARY_BOOKS Path to the directory with ebooks βœ…
LIBRARY_COVERS Path to the directory for cover images, the covers will extracted βœ…

Example usage in shell:

export LIBRARY_DB_USERNAME=myuser
export LIBRARY_DB_PASSWORD=secret
export LIBRARY_DB_HOST=localhost:5432
export LIBRARY_DB_DATABASE=library
export LIBRARY_BOOKS=/path/to/ebooks
export LIBRARY_COVERS=/path/to/covers
./library
Command-line Flags
Flag Attribute Description
--forceUpdate, -fu none Force update: force re-read all book, extract covers
--noServer, -ns none Not start the server (for maintainne)
--noCheck,-nc none No eBooks check at start
--export, -e export file name Export database in json format

πŸͺ΅ Logging

This application uses zerolog for structured, high-performance logging.

Configuration is managed via zeroconfig, allowing runtime log level and format customization through a config file.

πŸ”§ Configuration

Logging settings are read from a file named log.config located in the working directory.
It supports both JSON and plain text output, log levels, and other zerolog features.

Example log.config (already part of the code):

min_level: info
#min_level: trace
max_level: fatal
caller: false
metadata: null
writers:
- type: file
  filename: server.log
  max_size: 10
  max_age: 0
  max_backups: 1
  local_time: false
  compress: false
- type: stdout
  format: pretty-colored
  time_format: 2006-01-02 15:04:05
  min_level: trace
  max_level: fatal

For full configuration options, see the zeroconfig documentation.

πŸ“š API Documentation (Swagger)

This project uses Swagger (OpenAPI) for automated API documentation, powered by swaggo/swag.

πŸ“ Local Swagger files

The dopcumentation is already generated at the

./docs/swagger.json

place

πŸ”§ How to generate Swagger docs

If you make changes to your API routes or comments, regenerate the documentation with:

swag init

This will update the docs/ folder with the latest Swagger spec. Make sure swag is installed:

go install github.com/swaggo/swag/cmd/swag@latest

###Where to access the docs online Once the application is running, the Swagger UI is available at: http://localhost:8888/swagger/index.html

🐳 Usage with Docker

πŸ“¦ Build the image

Clone the repository and build the image using the Dockerfile located in the docker/ directory:

git clone https://github.com/ignisVeneficus/library.git
cd library

# Build the Docker image
docker build -f docker/Dockerfile -t library .

To always fetch the latest version from GitHub (no build cache):

docker build --no-cache -f docker/Dockerfile -t library .
πŸš€ Run the container
docker run -d \
  --name library \
  -p 8880:8888 \
  -e PUID=1000 \
  -e PGID=1000 \
  -e TZ=Europe/Budapest \
  -e LIBRARY_DB_USERNAME=dbuser \
  -e LIBRARY_DB_PASSWORD=mysecret \
  -e LIBRARY_DB_HOST=mydatabase \
  -e LIBRARY_DB_DATABASE=library \

  -v /host/books:/books \
  -v /host/covers:/covers \
  library
πŸ§ͺ Using Docker Compose
services:
  library:
    build:
      context: .
      dockerfile: docker/Dockerfile
    container_name: library
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Budapest
      - "LIBRARY_DB_USERNAME=dbuser"
      - "LIBRARY_DB_PASSWORD=mysecret"
      - "LIBRARY_DB_HOST=mydatabase"
      - "LIBRARY_DB_DATABASE=library"
    volumes:
      - /host/books:/books
      - /host/covers:/covers
    ports:
      - "8888:8888"
    restart: unless-stopped

πŸ›£οΈ Roadmap

  • ☐ Edit Author
  • ☐ Edit Series
  • ☐ Edit Tag
  • ☐ Maintaince tasks (delete orphan authors, tags, series, etc )
  • ☐ UI redesign for smaller screens
  • ☐ Import
  • ☐ Possibility to change UI to different webapp

πŸ“ License

This project is licensed under the MIT License. See the LICENSE file for details.

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis
db
dao
dbo
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.

Jump to

Keyboard shortcuts

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