Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ 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)
53 changes: 53 additions & 0 deletions samples/blazegraph/README.md
Original file line number Diff line number Diff line change
@@ -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
```
35 changes: 35 additions & 0 deletions samples/blazegraph/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions samples/blazegraph/init/load-data.sh
Original file line number Diff line number Diff line change
@@ -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."
42 changes: 42 additions & 0 deletions samples/blazegraph/init/sample-data.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@prefix ex: <http://example.org/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

# 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" .