Skip to content

Commit 756123d

Browse files
committed
Add blazegraph sample
1 parent 56467bd commit 756123d

File tree

5 files changed

+165
-0
lines changed

5 files changed

+165
-0
lines changed

samples/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@ sample data and shows how to configure Graph Explorer to connect to it
1010
automatically with a default connection.
1111

1212
[Air Routes](./air_routes/readme.md)
13+
14+
## Social Network with Blazegraph
15+
16+
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.
17+
18+
[Blazegraph](./blazegraph/readme.md)

samples/blazegraph/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Blazegraph Sample
2+
3+
| Database | Query Language | Data Source |
4+
| ------------ | -------------- | ----------- |
5+
| [Blazegraph] | [SPARQL] | Sample RDF |
6+
7+
[Blazegraph]: https://blazegraph.com/
8+
[SPARQL]: https://www.w3.org/TR/sparql11-overview/
9+
10+
This sample uses Blazegraph as the RDF database pre-loaded with sample social
11+
network data and shows how to configure Graph Explorer to connect to it
12+
automatically with a default connection.
13+
14+
> [!NOTE]
15+
> The data is not persisted between restarts of the Docker container.
16+
17+
## Sample Data
18+
19+
The sample includes a small social network with:
20+
21+
- 4 people (Alice, Bob, Charlie, Diana)
22+
- 3 organizations (TechCorp, Startup, Nonprofit)
23+
- Relationships showing who knows whom and where people work
24+
25+
## Prerequisites
26+
27+
- [Docker](https://docs.docker.com/get-docker/) installed on your machine
28+
- [Docker Compose](https://docs.docker.com/compose/install/) installed on your
29+
machine
30+
31+
## Running Sample
32+
33+
1. Clone or download this repository
34+
2. Navigate to the `samples/blazegraph` directory
35+
```
36+
cd samples/blazegraph
37+
```
38+
3. Run the following command to start both services
39+
```
40+
docker compose up
41+
```
42+
4. Wait for both services to start (Blazegraph will load sample data
43+
automatically)
44+
5. Open the browser and navigate to:
45+
[http://localhost:8080/explorer](http://localhost:8080/explorer)
46+
47+
## Stopping the Sample
48+
49+
To stop the services, press `Ctrl+C` in the terminal or run:
50+
51+
```
52+
docker compose down
53+
```
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: "3.9"
2+
3+
services:
4+
database:
5+
image: openkbs/blazegraph:latest
6+
restart: unless-stopped
7+
environment:
8+
- JAVA_OPTS=-Xmx2g
9+
volumes:
10+
- ./init:/init
11+
- ./data:/var/blazegraph
12+
command:
13+
bash -c "java -server -Xmx2g -jar blazegraph.jar & /init/load-data.sh &&
14+
wait"
15+
working_dir: /home/developer/blazegraph/
16+
healthcheck:
17+
test: ["CMD", "curl", "-f", "http://localhost:9999/blazegraph"]
18+
interval: 30s
19+
timeout: 5s
20+
retries: 3
21+
22+
graph-explorer:
23+
image: public.ecr.aws/neptune/graph-explorer:latest
24+
ports:
25+
- "8090:80"
26+
environment:
27+
- HOST=localhost
28+
- PUBLIC_OR_PROXY_ENDPOINT=http://localhost:8090
29+
- GRAPH_TYPE=sparql
30+
- USING_PROXY_SERVER=true
31+
- PROXY_SERVER_HTTPS_CONNECTION=false
32+
- GRAPH_CONNECTION_URL=http://database:9999/blazegraph
33+
depends_on:
34+
database:
35+
condition: service_healthy
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
set -e
3+
4+
MARKER_FILE="/var/blazegraph/.data_loaded"
5+
6+
# If the marker file exists, skip loading
7+
if [ -f "$MARKER_FILE" ]; then
8+
echo "Sample data already loaded — skipping."
9+
exit 0
10+
fi
11+
12+
# Wait for Blazegraph to become available
13+
echo "Waiting for Blazegraph to start..."
14+
until curl -s http://localhost:9999/blazegraph >/dev/null; do
15+
sleep 2
16+
done
17+
18+
echo "Blazegraph is up! Loading sample.ttl..."
19+
20+
# Load the RDF data into the default namespace (kb)
21+
curl -s -X POST \
22+
-H 'Content-Type: text/turtle' \
23+
--data-binary @/init/sample-data.ttl \
24+
"http://localhost:9999/blazegraph/namespace/kb/sparql" \
25+
-o /dev/null
26+
27+
# Create a marker so we know data has been loaded
28+
touch "$MARKER_FILE"
29+
echo "✅ Data loaded successfully and marker file created."
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
@prefix ex: <http://example.org/> .
2+
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
3+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
4+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
5+
6+
# People
7+
ex:alice a foaf:Person ;
8+
foaf:name "Alice Johnson" ;
9+
foaf:age 30 ;
10+
foaf:knows ex:bob, ex:charlie ;
11+
foaf:worksFor ex:techcorp .
12+
13+
ex:bob a foaf:Person ;
14+
foaf:name "Bob Smith" ;
15+
foaf:age 25 ;
16+
foaf:knows ex:alice, ex:diana ;
17+
foaf:worksFor ex:startup .
18+
19+
ex:charlie a foaf:Person ;
20+
foaf:name "Charlie Brown" ;
21+
foaf:age 35 ;
22+
foaf:knows ex:alice, ex:diana ;
23+
foaf:worksFor ex:techcorp .
24+
25+
ex:diana a foaf:Person ;
26+
foaf:name "Diana Prince" ;
27+
foaf:age 28 ;
28+
foaf:knows ex:bob, ex:charlie ;
29+
foaf:worksFor ex:nonprofit .
30+
31+
# Organizations
32+
ex:techcorp a foaf:Organization ;
33+
foaf:name "TechCorp Inc." ;
34+
rdfs:label "Technology Corporation" .
35+
36+
ex:startup a foaf:Organization ;
37+
foaf:name "Innovative Startup" ;
38+
rdfs:label "Startup Company" .
39+
40+
ex:nonprofit a foaf:Organization ;
41+
foaf:name "Community Nonprofit" ;
42+
rdfs:label "Non-profit Organization" .

0 commit comments

Comments
 (0)