📚 Online web system for reserving books
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
bootstrap
config
database
public
resources
routes
storage
tests
.env.example
.gitattributes
.gitignore
.htaccess
Instructions.md
LICENSE
README.md
artisan
composer.json
composer.lock
package.json
phpunit.xml
server.php
webpack.mix.js
yarn.lock

README.md

Books Reservation

This is an online web system wrote for books 📚 reseravtion, typically old books collected from graduates 🎓. The project has been maintained since May 2017, which is excatly the time it was first deployed online, and then in the next year it was updated and worked in production again. Later in November 2018 it was used as my database coursework 🎈 and so I made even more modifications and optimizations to the core modules.

Brief Introduction

Note: In this system, reserve refers to the reserve operation itself while reservation is used to refer to the reserved order......maybe still kind of confusing = _ =!

  • User Module 📙:

    • Welcome modal will be displayed once the page is loaded, and then after clicking the confirm button you can get paged books' brief data ordered by their entry time, while books with no surplus will be showed in the final page
    • Navbar displays three options, you can get all books' list, search 🔍 books via keywords or search reservation via your student ID
    • Commit or modify a reservation: Choose no more than three books and then you can commit the reservation after filling in the information form, and the reservation can be modified 📝 any time after its commit
    • Student ID is used as unique identifier 📌 in this system, so it can not be modified, and an reservation with reserved student ID will not be committed.
  • Admin Module 🔒:

    • After logged in, this page will display all existed books with their detailed information 📖, add and update functions are provided as well, and the cursor will be automatically focused on remaining amount area when updating a book, so that update operations can be more efficient
    • To add a book to database, you will need to scan 📸 or input its ISBN, if there is no data responses after requesting the ISBN-based search, information of the book will need to be inputted manually
    • All reservations will be displayed in the page from "show all reservations" link 🔗, so that administrators can use them to hand out the reserved books

The API used in this system to get books' information from their ISBN is provided by douban, and the Front-End UI is based on Materialize.

Source of sample SideNav header picture was here and it was processed to fit in its element position.

A Brief Chinese introduction and direction of this system lays 🈶 in Instructions.md.

Experience Demo Sites

You can experience this entire system on https://db-demo.kingsley.cc, and here are some different versions deployed 🚀 online:

  • Version 0 🍬 should be the furthest version of this system, deployed on May, 2017, it is now an online demo which you can test with anyway you want.

  • Version 1 🍦 is in production mode, deployed on May, 2018. Reservation's add and modify interfaces are currently closed, so please DO NOT TEST WITH IT.

  • Version 2 🍭 is the link given above, it is used as a demo for my database coursework presentation, and this is also the up-to-date version. It is strongly recommended to experience with it if you want to try the system, since it has significant updates ⚗️ and optimizations ⚡️ from the former two versions.

Dependency Installation

Commands are as follows, based on my coursework presentation demo site using Ubuntu 16.04, the process to install LNMP/LAMP is ignored here. Besides, for convenience, any user permission related problem are not shown either.

Elasticsearch with IK analysis plugin 📦 and Java environment ☕️

References:

$ sudo add-apt-repository -y ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install -y oracle-java8-installer

$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.0.deb

# Install Elasticsearch, enable and start its service
$ sudo dpkg -i elasticsearch-6.5.0.deb
$ sudo systemctl enable elasticsearch.service
$ sudo systemctl start elasticsearch

# Install IK analysis plugin and restart Elasticsearch
$ sudo ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.5.0/elasticsearch-analysis-ik-6.5.0.zip
$ sudo systemctl restart elasticsearch

Redis database for session cache and book search result cache 🍻

References:

$ sudo apt-get update && sudo apt-get upgrade
$ sudo apt install make gcc libc6-dev tcl

$ wget http://download.redis.io/redis-stable.tar.gz
$ tar xvzf redis-stable.tar.gz
$ cd redis-stable

# Build Redis and try unit tests
$ make install
$ make test

# Start Redis in background
$ redis-server --daemonize yes

Laravel project dependencies

$ curl https://getcomposer.org/installer > composer.phar
$ php composer.phar
$ php composer.phar install

Deploy Guide

Initialization 🔧

First, test if MySQL, Redis and Elasticsearch is running, execute these commands for them respectively:

$ mysql -uusername -ppassword
$ redis-cli

# Elasticsearch listens on port 9200 and provides RESTful API to use
$ curl localhost:9200

Then just change configurations in file .env which should be dumplicated from .env.example, typically you may just change DB_* to your MySQL host, username and password for this project, and leave the values of REDIS_* just the defaults if you didn't change them. ADMIN_PATH is used as a random string for the admin pages' URL.

Remember to give write permission to storage directory, and you can just start to use the system after following commands:

# Generate an app key for the Laravel project
$ php artisan key:generate

# Create database and corresponding test data
$ php artisan migrate:fresh --seed

Since the sync 💬 between MySQL and Elasticseach is only executed when adding or updating book in admin pages, the above direct database operations make no synchronization between them, so you'll need to manually do that. Luckily, there is an API for that, just sign in to admin module and visit api/admin/init-index, then everything shall be in the right position.

Reset all dirty data 💥

You may want to clear all changes after several test operations, only three commands are needed for that:

# Reset database structure and test data
$ php artisan migrate:fresh --seed

# Remove Elasticsearch's index for this project
$ curl -X DELETE "localhost:9200/books_reservation_index" | json_pp

# Clear seach caches stored in Redis
$ redis-cli FLUSHALL

And of course the api/admin/init-index URL should be visited again to recreate indices for these test books.

Made By Kingsley With ❤️