From a97b7e0579e6ac450062b4250166045bff8d7a76 Mon Sep 17 00:00:00 2001 From: Kris McGinnes Date: Fri, 24 Oct 2025 10:14:26 -0500 Subject: [PATCH 1/3] Add samples data folders to gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index e656afe21..4a3725b23 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,8 @@ **/dist/ **/.env.local +# The data persisted from running samples should not end up in the repo +**/samples/**/data/ + # TypeScript build cache manifests *.tsbuildinfo \ No newline at end of file From 09a1b116037ab1a3153607b458318148ec237be0 Mon Sep 17 00:00:00 2001 From: Kris McGinnes Date: Fri, 24 Oct 2025 10:22:28 -0500 Subject: [PATCH 2/3] Add blazegraph sample --- samples/README.md | 6 +++ samples/blazegraph/README.md | 53 +++++++++++++++++++++++++ samples/blazegraph/docker-compose.yml | 35 ++++++++++++++++ samples/blazegraph/init/load-data.sh | 29 ++++++++++++++ samples/blazegraph/init/sample-data.ttl | 42 ++++++++++++++++++++ 5 files changed, 165 insertions(+) create mode 100644 samples/blazegraph/README.md create mode 100644 samples/blazegraph/docker-compose.yml create mode 100755 samples/blazegraph/init/load-data.sh create mode 100644 samples/blazegraph/init/sample-data.ttl diff --git a/samples/README.md b/samples/README.md index 4699fe97a..a84a0eef3 100644 --- a/samples/README.md +++ b/samples/README.md @@ -10,3 +10,9 @@ sample data and shows how to configure Graph Explorer to connect to it automatically with a default connection. [Air Routes](./air_routes/readme.md) + +## Social Network with Blazegraph + +This sample uses Blazegraph as the RDF database pre-loaded with sample social network data and shows how to configure Graph Explorer to connect to it automatically with a default connection. + +[Blazegraph](./blazegraph/readme.md) diff --git a/samples/blazegraph/README.md b/samples/blazegraph/README.md new file mode 100644 index 000000000..a5ec6c167 --- /dev/null +++ b/samples/blazegraph/README.md @@ -0,0 +1,53 @@ +# Blazegraph Sample + +| Database | Query Language | Data Source | +| ------------ | -------------- | ----------- | +| [Blazegraph] | [SPARQL] | Sample RDF | + +[Blazegraph]: https://blazegraph.com/ +[SPARQL]: https://www.w3.org/TR/sparql11-overview/ + +This sample uses Blazegraph as the RDF database pre-loaded with sample social +network data and shows how to configure Graph Explorer to connect to it +automatically with a default connection. + +> [!NOTE] +> The data is not persisted between restarts of the Docker container. + +## Sample Data + +The sample includes a small social network with: + +- 4 people (Alice, Bob, Charlie, Diana) +- 3 organizations (TechCorp, Startup, Nonprofit) +- Relationships showing who knows whom and where people work + +## Prerequisites + +- [Docker](https://docs.docker.com/get-docker/) installed on your machine +- [Docker Compose](https://docs.docker.com/compose/install/) installed on your + machine + +## Running Sample + +1. Clone or download this repository +2. Navigate to the `samples/blazegraph` directory + ``` + cd samples/blazegraph + ``` +3. Run the following command to start both services + ``` + docker compose up + ``` +4. Wait for both services to start (Blazegraph will load sample data + automatically) +5. Open the browser and navigate to: + [http://localhost:8080/explorer](http://localhost:8080/explorer) + +## Stopping the Sample + +To stop the services, press `Ctrl+C` in the terminal or run: + +``` +docker compose down +``` diff --git a/samples/blazegraph/docker-compose.yml b/samples/blazegraph/docker-compose.yml new file mode 100644 index 000000000..71d25740a --- /dev/null +++ b/samples/blazegraph/docker-compose.yml @@ -0,0 +1,35 @@ +version: "3.9" + +services: + database: + image: openkbs/blazegraph:latest + restart: unless-stopped + environment: + - JAVA_OPTS=-Xmx2g + volumes: + - ./init:/init + - ./data:/var/blazegraph + command: + bash -c "java -server -Xmx2g -jar blazegraph.jar & /init/load-data.sh && + wait" + working_dir: /home/developer/blazegraph/ + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:9999/blazegraph"] + interval: 30s + timeout: 5s + retries: 3 + + graph-explorer: + image: public.ecr.aws/neptune/graph-explorer:latest + ports: + - "8090:80" + environment: + - HOST=localhost + - PUBLIC_OR_PROXY_ENDPOINT=http://localhost:8090 + - GRAPH_TYPE=sparql + - USING_PROXY_SERVER=true + - PROXY_SERVER_HTTPS_CONNECTION=false + - GRAPH_CONNECTION_URL=http://database:9999/blazegraph + depends_on: + database: + condition: service_healthy diff --git a/samples/blazegraph/init/load-data.sh b/samples/blazegraph/init/load-data.sh new file mode 100755 index 000000000..a56380594 --- /dev/null +++ b/samples/blazegraph/init/load-data.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -e + +MARKER_FILE="/var/blazegraph/.data_loaded" + +# If the marker file exists, skip loading +if [ -f "$MARKER_FILE" ]; then + echo "Sample data already loaded — skipping." + exit 0 +fi + +# Wait for Blazegraph to become available +echo "Waiting for Blazegraph to start..." +until curl -s http://localhost:9999/blazegraph >/dev/null; do + sleep 2 +done + +echo "Blazegraph is up! Loading sample.ttl..." + +# Load the RDF data into the default namespace (kb) +curl -s -X POST \ + -H 'Content-Type: text/turtle' \ + --data-binary @/init/sample-data.ttl \ + "http://localhost:9999/blazegraph/namespace/kb/sparql" \ + -o /dev/null + +# Create a marker so we know data has been loaded +touch "$MARKER_FILE" +echo "✅ Data loaded successfully and marker file created." diff --git a/samples/blazegraph/init/sample-data.ttl b/samples/blazegraph/init/sample-data.ttl new file mode 100644 index 000000000..d092f7681 --- /dev/null +++ b/samples/blazegraph/init/sample-data.ttl @@ -0,0 +1,42 @@ +@prefix ex: . +@prefix foaf: . +@prefix rdf: . +@prefix rdfs: . + +# People +ex:alice a foaf:Person ; + foaf:name "Alice Johnson" ; + foaf:age 30 ; + foaf:knows ex:bob, ex:charlie ; + foaf:worksFor ex:techcorp . + +ex:bob a foaf:Person ; + foaf:name "Bob Smith" ; + foaf:age 25 ; + foaf:knows ex:alice, ex:diana ; + foaf:worksFor ex:startup . + +ex:charlie a foaf:Person ; + foaf:name "Charlie Brown" ; + foaf:age 35 ; + foaf:knows ex:alice, ex:diana ; + foaf:worksFor ex:techcorp . + +ex:diana a foaf:Person ; + foaf:name "Diana Prince" ; + foaf:age 28 ; + foaf:knows ex:bob, ex:charlie ; + foaf:worksFor ex:nonprofit . + +# Organizations +ex:techcorp a foaf:Organization ; + foaf:name "TechCorp Inc." ; + rdfs:label "Technology Corporation" . + +ex:startup a foaf:Organization ; + foaf:name "Innovative Startup" ; + rdfs:label "Startup Company" . + +ex:nonprofit a foaf:Organization ; + foaf:name "Community Nonprofit" ; + rdfs:label "Non-profit Organization" . From b9f7c168eba2ff609c6ac2772b1c1c14ab9ce69f Mon Sep 17 00:00:00 2001 From: Kris McGinnes Date: Wed, 19 Nov 2025 13:48:52 -0600 Subject: [PATCH 3/3] Fix formatting --- samples/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/samples/README.md b/samples/README.md index a84a0eef3..365d239ce 100644 --- a/samples/README.md +++ b/samples/README.md @@ -13,6 +13,8 @@ automatically with a default connection. ## Social Network with Blazegraph -This sample uses Blazegraph as the RDF database pre-loaded with sample social network data and shows how to configure Graph Explorer to connect to it automatically with a default connection. +This sample uses Blazegraph as the RDF database pre-loaded with sample social +network data and shows how to configure Graph Explorer to connect to it +automatically with a default connection. [Blazegraph](./blazegraph/readme.md)