Thank you for contributing to Six Degrees of Wikipedia!
There are three main pieces you'll need to get set up running locally:
- Mock SQLite database of Wikipedia links
- Backend Python Flask web server
- React + TypeScript frontend website built using Vite
There is some larger set up you'll need to run initially as well as some recurring set up every time you want to run the service.
Note: The following instructions have only been tested on macOS.
The first step is to clone the repo and move into the created directory:
$ git clone git@github.com:jwngr/sdow.git
$ cd sdow/
Several dependencies are required to run the service:
sqlite3
- Data storagenvm
- Manage Node andnpm
versionspyenv
- Manage Python andpip
versionsvirtualenv
- Avoid polluting global environment
The simplest way to download these is via Homebrew:
## Install SQLite.
$ brew install sqlite
## Install nvm (Node + npm).
$ brew install nvm
$ nvm install node
## Install + configure pyenv (Python + pip).
$ brew install xz
$ brew install pyenv
# Also configure pyenv path using instructions in link above.
$ pyenv install 3
## Install + configure virtualenv.
$ python -m pip install --user virtualenv
# Also configure virtualenv path using instructions in link above.
Once the required global dependencies are installed, install the project dependencies and generate a mock local database:
# Run from root of repo.
$ virtualenv env
$ source env/bin/activate
$ pip install -r requirements.txt
$ python scripts/create_mock_databases.py
Every time you want to run the service, you need to source your environment, start the backend Flask app, and the frontend website. You can run the backend and frontend apps in different tabs.
To run the backend, open a new tab and run the following commands from the repo root:
# Run from root of repo.
$ source env/bin/activate
$ cd sdow/
$ export FLASK_APP=server.py FLASK_DEBUG=1
$ flask run
To run the frontend, open a new tab and run the following commands from the repo root:
$ cd website/
$ npm start
The service can be found at http://localhost:3000.
Here are some highlights of the directory structure and notable source files
.github/
- Contribution instructions as well as issue and pull request templatesconfig/
- Configuration files for services like NGINX, Gunicorn, and Supervisorddocs/
- Documentationscripts/
- Scripts to do things like create a new version of the SDOW database, create a mocksdow/
- The Python Flask web serverserver.py
- Main entry point which initializes the Flask web serverdatabase.py
- Defines aDatabase
class which simplifies querying the SDOW SQLite databasebreadth_first_search.py
- The main search algorithm which finds the shortest path between pageshelpers.py
- Miscellaneous helper functions and classes
sketch/
- Sketch logo filessql/
- SQLite table schemaswebsite/
- The frontend React + TypeScript website, built using Vite.pylintrc
- Default configuration forpylint
requirements.txt
- Requirements specification for installing project dependencies viapip
setup.cfg
- Python PEP 8 autoformatting rules