Skip to content

Simple backend application for scheduling book pick ups from Open Library

Notifications You must be signed in to change notification settings

WolvenDotDev/simple-open-library

Repository files navigation

Simple Open Library

This repository contains the code of a simple backend application for scheduling book pickups from Open Library

Due to the nature of the pandemic, a local library is planning to reduce gatherings and crowds in its area by creating an online book pick up service. In order to borrow books from the library, users have to make an appointment at a specific time of day to come and pick up the books.

This backend application provides the necessary APIs to do so. Users can browse books from Open Library before making a schedule. Users can then submit a pick up schedule of the book they want to borrow. Librarians can get all appointed book pick up schedules with the book information. Librarians can also fetch a single appointment schedule. They can also update or delete an appointment.

API Access

Users do not have to login to use the backend application to browse books from Open Library or previouly submitted books. But an API Key (owned by a librarian) is needed to submit a pick up schedule, list, update, or delete schedules. This is done to prevent users from adding unnecessary schedules or changing submitted schedules without a librarian's verification.

API Specifications

For now, please copy the API Spec file (apispec.json) into a Swagger Editor to view the full API specifications.

Setup local development

Install tools

  • Golang
  • MySQL
  • Google Wire
    go install github.com/google/wire/cmd/wire@latest
  • Golang Migrate
    go install -tags 'mysql' github.com/golang-migrate/migrate/v4/cmd/migrate@latest

Setup infrastructure

  • Install the necessary tools to run / build the application
  • Setup the .env file. The .env.example file can be found in the root folder.
  • Setup a MySQL database, and migrate the schema using the command below.
    make migrateup
  • A separate database should be made for unit tests. Migrate the schema to the test database using the command below
    make migrateup_test
  • Optionally install an API testing tool such as Postman to manually test APIs with ease

How to run

  • Run server:

    make run
  • Build application:

    make build
  • Build and run application:

    make build_run
  • Run tests:

    make run_test

Database Migration Commands

  • Run db migration up all versions
    make migrateup
  • Run db migration up 1 version
    make migrateup1
  • Run db migration down all versions
    make migratedown
  • Run db migration down 1 version
    make migratedown
  • Run test db migration up all versions
    make migrateup_test
  • Run test db migration up 1 version
    make migrateup1_test
  • Run test db migration down all versions
    make migratedown_test
  • Run test db migration down 1 version
    make migratedown_test

Further Improvements

This software still has room for improvements:

  • A virtual container tool like Docker can improve development by automating deployment of applications in isolated lightweight containers so applications can work efficiently in different environments (machines)
  • API documentation should be more easily accessible

Libraries

Contributions

About

Simple backend application for scheduling book pick ups from Open Library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages