Website for visualising the shortest paths between two F1 drivers and their teammates https://sixdegs.maciejpedzi.ch
Go to file
2024-09-01 10:28:20 +02:00
.vscode Ensure project's Typescript SDK version is used 2024-03-07 21:56:26 +01:00
data Add detailed setup and deployment instructions 2024-08-04 15:06:04 +02:00
public Init Astro project 2024-03-07 20:40:03 +01:00
src Log shortest path queries 2024-09-01 10:28:20 +02:00
.gitignore Init Astro project 2024-03-07 20:40:03 +01:00
.markdownlint.json Add detailed setup and deployment instructions 2024-08-04 15:06:04 +02:00
astro.config.mjs Use single quotes in Astro config 2024-04-29 22:14:53 +02:00
compose.yml Move DB credentials back to dedicated env file 2024-07-27 17:53:43 +02:00
Dockerfile Create a Dockerfile and Docker Compose stack 2024-07-27 17:29:14 +02:00
LICENSE Change license to GNU GPLv3 2024-04-29 11:53:32 +02:00
package-lock.json Move more server-redundant deps to devDependencies 2024-08-09 18:45:27 +02:00
package.json Move more server-redundant deps to devDependencies 2024-08-09 18:45:27 +02:00
README.md Add detailed setup and deployment instructions 2024-08-04 15:06:04 +02:00
tsconfig.json Add a TS alias for src directory 2024-04-27 23:52:18 +02:00

Six Degrees of Formula 1

Six Degrees of Formula 1 stores data of drivers and their teammates in a Memgraph database. If two given drivers have competed for the same team in at least one race, there's a link between them.

You can enter the names of two drivers and find out how to get from one to the other using as few connections as possible.

Deployment with Docker

Prerequisites

  • Docker Engine version 27.0.1 or later
  • Docker Compose version 2.29.0 or later

Environment variables

Place the following variables in a .env file in the project's root directory:

PUBLIC_NETWORK=your_docker_network_here
DB_URI=bolt://sixdegs-db:7687
DB_USERNAME=memgraph_username_here
DB_PASSWORD=memgraph_password_here

You can leave the DB_URI variable as-is. If you're deploying this stack for the first time, you probably don't have values for DB_USERNAME or DB_PASSWORD to fill in for placeholders above. Once you've deployed this stack, see the Database preparation section of this README for further instructions.

Specifying PUBLIC_NETWORK is required to put the website behind a reverse proxy, which itself is also containerised and has its own Docker network named your_docker_network_here with all the services it forwards requests to.

You may choose to remove the public network from the Compose file if you don't have that setup.

Build and run

git clone https://github.com/maciejpedzich/six-degs-of-f1.git
# Alternatively: git clone https://git.maciejpedzi.ch/maciejpedzich/six-degs-of-f1.git
cd six-degs-of-f1
docker compose build
docker compose up -d

Deployment without Docker

Prerequisites

  • Node.js version 20.3.0 or later
  • Memgraph version 2.18.0 or later

Make sure you've installed and set up the Memgraph database first. If you haven't, see the Database preparation section of this README for setup details.

Environment variables

Place the following variables in a .env file inside the project's root directory:

DB_URI=bolt://db_host_here:db_port_here
DB_USERNAME=memgraph_username_here
DB_PASSWORD=memgraph_password_here

Build and run

git clone https://github.com/maciejpedzich/six-degs-of-f1.git
# Alternatively: git clone https://git.maciejpedzi.ch/maciejpedzich/six-degs-of-f1.git
cd six-degs-of-f1
npm i
npm run build
node ./dist/server/entry.mjs

Database preparation

Open up your CLI and connect to the database via mgconsole by running this command if you're using Docker:

docker exec -it sixdegs-db mgconsole

If you're not using Docker, use this command instead:

mgconsole --host db_host_here --port db_port_here

Create a new user and set a password:

CREATE USER `memgraph_username_here` IDENTIFIED BY 'memgraph_password_here'; 

Populate the database by executing these queries:

LOAD CSV FROM "https://raw.githubusercontent.com/maciejpedzich/six-degs-of-f1/master/data/drivers.csv" WITH HEADER AS row
CREATE (d:Driver {driverId: ToInteger(row.driverId), forename: row.forename, surname: row.surname});

LOAD CSV FROM "https://raw.githubusercontent.com/maciejpedzich/six-degs-of-f1/master/data/teammates.csv" WITH HEADER AS row
MATCH (d:Driver {driverId: ToInteger(row.driverId)})
MATCH (t:Driver {driverId: ToInteger(row.teammateId)})
CREATE (d)-[:WAS_TEAMMATES_WITH]->(t);

Exit out of mgconsole by pressing Ctrl/Cmd+C.

Replace the filler values for DB_USERNAME and DB_PASSWORD with the username and password of your newly created Memgraph user.

If you're using Docker, restart the Compose stack by running:

docker compose down
docker compose up -d

Astro Commands

All commands are run from the root of the project, from a terminal:

Command Action
npm install Installs dependencies
npm run dev Starts local dev server at localhost:4321
npm run build Build your production site to ./dist/
npm run preview Preview your build locally, before deploying
npm run astro ... Run CLI commands like astro add, astro check
npm run astro -- --help Get help using the Astro CLI