This project implements a public demo of Cr5 with cr5-lib. The project contains frontend and backend components.
The frontend design is inspired by the public demo of WikiPDA.
Instead of using pure HTML / CSS, the frontend component is implemented with React and TypeScript. The style is implemented by a wrapper of the original bootstrap, namely react-bootstrap.
This project was bootstrapped with Create React App.
Hence, it is highly recommended to run / build the project with yarn. Since yarn includes breaking changes between v1 and v2, please note that we use v1 in our project.
# make sure that you have node installed
npm install --global yarn
cd frontend
yarn installBy default, the frontend uses the backend at: http://localhost:5005.
To override the setting, use environment variable REACT_APP_HOST_URL.
REACT_APP_HOST_URL=some_different_host yarn startREACT_APP_HOST_URL=some_different_host yarn buildIf you prefer to use an isolated environment instead of installing yarn locally, we recommend using the official node image.
cd frontend
docker pull node:lts
# Mount current directory into folder and set port forwarding between host machine and container
docker run -v `pwd`:`pwd` -w `pwd` -p 3000:3000 -it node:lts /bin/bash
# Install the required node modules (required only once)
yarn install
# Start the server locally. You can access the web page from the host machine at: localhost:3000
yarn start
# Build the production files
yarn build
The backend component is implemented with flask framework with several features:
- Rate limiter. By default the limit is
2 per second. To override the default value, set the environment variableRATE_LIMITto other values. - Swagger docs. Assuming the API is running on
localhost:5005, the Swagger documentation can be accessed at:localhost:5005/apidocs
In addition to the dependencies of cr5-lib, the backend requires:
Flask, for providing the basic frameworkFlask-Cors, for providing support for CORSFlask-Inputs, for validating input data by JSON schemaFlask-Limiter, for rate limitingflasgger, for providing API docs
export LEVEL_DB_DIR=/path/to/leveldb/files
export SEARCH_INDEXES_DIR=/path/to/search_indexes/filesexport APP_HOST=some_other_ip
export APP_PORT=some_other_port_number
export RATE_LIMIT=some_other_rate_limit_policypython app.pyUse the Dockerfile which creates an environment named cr5-demo.
Note that, in the script below, we assume there will be a root of data directory, namely /path/to/the/root/of/data/directory. The detailed layout is specified here. Only subdirectories level_db and search_indexes are needed since the API runs in a memory-efficient manner.
cd backend
# Inside backend directory, build the docker image
docker build -t cr5-demo:latest .
docker run -it -p 5005:5005 -v /path/to/the/root/of/data/directory:/data cr5-demo:latest
# Inside docker container
python app.py
Now you can visit the API docs at localhost:5005/apidocs and make requests to the API.
Our public demo is currently deployed here.