Skip to content

Web application to manage Leihläden (Borrow Stores, Library-of-Things)

License

Notifications You must be signed in to change notification settings

leihbase/leihbase

Repository files navigation

Leihbase

Web application to manage Leihladen, also known as Borrow Stores.

Important

This software is still in active development. It is being used in production for the Leihbar in Cologne, but might be lacking some (for you) critical features.

Features

  • 🏪 A webshop front-end showing borrowable products
  • 🏙️ Manage multiple borrow locations
  • 🏷️ Product category filtering
  • 🧑‍🤝‍🧑 User sign-up/login
  • 🎫 Product reservations
  • 👷 A back-end to manage products & reservations
  • 📧 Product pickup and return e-mail reminders
  • 🎨 Themeable

Screenshots

Tech

  • Back-end and API using PocketBase
  • Front-end with server-side rendering using NuxtJS

Deployment

Docker

Leihbase has two Docker Images available which are both required to set up the application:

Use the following docker-compose.yml as a base to deploy Leihbase using Docker:

services:
  leihbase-webapp:
    image: lumocra/leihbase-webapp:v1.7.0
    container_name: leihbase-webapp
    environment:
      NUXT_PUBLIC_POCKETBASE_SERVER_BASE_URL: http://leihbase-pb:8080
      NUXT_PUBLIC_POCKETBASE_CLIENT_BASE_URL: <leihbase-pb public url>

  leihbase-pb:
    image: lumocra/leihbase-pb:v1.7.0
    container_name: leihbase-pb
    environment:
      CONFIG_LOCALE: "en"
      # If a reservation (created in the admin section) is required to have a user
      CONFIG_RESERVATION_REQUIRE_USER: "false"
      CONFIG_LENDING_CONDITIONS_LINK: "https://example.com/borrow-conditions"
    volumes:
      - ./pb_data:/pb/pb_data

Fly.io

The repository contains fly.toml files to deploy the service as fly.io applications.

Development

Setup

Requirements: Mise

# Install repository tools (mailpit, pocketbase)
$ mise install
# Setup project
$ mise run //...:setup

Run

# Enable mise monorepo support
$ export MISE_EXPERIMENTAL=1
# Run services
$ mise run //...:dev

Initial content

After starting the service using the setup steps above. Enter some initial data to be able to use the application:

  1. Browse to localhost:8080/_/ to visit the Pocketbase admin interface
  2. Create an admin account
  3. Create a record in the leihbase collection, containing some configuration settings for the instance
  4. Create a location in the locations collection (make sure to set the location to as 'active')
  5. Create a product in the products collection (make sure to set the product to as 'active')
  6. Now you should be able to visit localhost:3000 to visit the front-end

E-mail

When starting the services, mailpit also starts. In Pocketbase (localhost:8080/_/ > Settings > Mail settings) the following SMTP values can be configured:

  • SMTP server host: localhost
  • Port: 1025
  • Username: <empty>
  • Password: <empty>

Any sent e-mail can then be viewed in the mailpit web interface at localhost:8025.

Tests

Tests are configured and run using Playwright, as the tests includes visual snapshots tests they are executed in a docker environment.

Run tests

# Run e2e tests
mise run test:e2e
# Run e2e tests, and update visual snapshots
mise run test:e2e

Configuration

Pocketbase Admin

Location

Notifications

Using the following JSON format the e-mail addresses which should receives notifications of this location can be configured:

["example@example.com", "sarah@example.com"]

Links

Links shown on the location page.

[
  {
    "text": "Leihbar Website",
    "link": "https://leihbar-koeln.de"
  }
]

Opening Hours

Using the following JSON format the opening hours of a location can be configured:

{
  "days": {
    "tuesday": [
      {
        "from": "18:00",
        "to": "19:00"
      }
    ],
    "friday": [
      {
        "from": "17:00",
        "to": "19:00"
      }
    ]
  },
  "except": {
    "dates": ["2024-12-25", "2024-12-26", "2024-12-31", "2025-01-01"]
  }
}

Config field

In the config JSON field of a location are the following configurations available:

config.allow_same_day_reservations - Allows a reservation to start on the same day as that another reservation ends