Self-hosted Neo4j with Graph Data Science (GDS) library, AI chatbot, and static documentation site on Cloudflare.
- Neo4j 5 Community Edition with Graph Data Science (GDS) library
- AI Chatbot powered by Cloudflare Workers and AI SDK
- Static Documentation Site built with Lumadoc
- APOC plugin for extended functionality
- Long-lived container deployment optimized for Cloudflare
- Docker Compose setup for local development
- Complete CI/CD pipeline for all components
- Docker and Docker Compose (for Neo4j)
- Node.js 20+ (for Worker and Site)
- GitHub Actions secrets configured:
CLOUDFLARE_ACCOUNT_ID: Your Cloudflare Account IDCLOUDFLARE_API_TOKEN: Cloudflare API token with:- Container registry permissions
- Workers deployment permissions
- Pages deployment permissions
- Go to your repository settings:
https://github.com/Captain-App/liteip-graph/settings/secrets/actions - Add the following secrets:
CLOUDFLARE_ACCOUNT_ID: Your Cloudflare Account ID (found in Cloudflare dashboard)CLOUDFLARE_API_TOKEN: A Cloudflare API token with:Account:Cloudflare Workers:EditpermissionZone:Zone:Readpermission (if using zones)Account:Workers Scripts:Editpermission
- Enable Workers for Platforms in your Cloudflare dashboard
- Create a namespace for your containers (if needed)
- Ensure your API token has container registry access
# Copy environment file
cp env.example .env
# Edit .env with your Neo4j credentials
# Then start Neo4j
docker-compose up -d
# Check logs
docker-compose logs -f neo4j
# Access Neo4j Browser
open http://localhost:7474# Build the container
docker build -t liteip-graph .
# Run the container
docker run -d \
--name liteip-graph-neo4j \
-p 7474:7474 \
-p 7687:7687 \
-e NEO4J_AUTH=neo4j/your-password \
liteip-graph- HTTP: http://localhost:7474 (Neo4j Browser)
- Bolt: bolt://localhost:7687 (Application connections)
Default credentials:
- Username:
neo4j - Password:
change-password(change this in production!)
After starting the container, verify that GDS is installed and working:
# Using cypher-shell
cypher-shell -u neo4j -p change-password
# In the Cypher shell, run:
CALL gds.version() YIELD version RETURN version;
# List available GDS procedures:
CALL gds.list() YIELD name, description RETURN name, description;Or in Neo4j Browser (http://localhost:7474):
CALL gds.version() YIELD version RETURN version;The project includes a Cloudflare Worker with an AI chatbot using Cloudflare's AI SDK.
cd worker
npm install
npm run devcd worker
npm run deployThe worker provides a REST API endpoint for chat interactions. See worker/src/index.ts for implementation details.
The project includes a static documentation site built with Lumadoc.
cd site
npm install
npm run devcd site
npm run build
# Deploy dist/ to Cloudflare PagesThe GitHub Actions workflow automatically:
- Neo4j Container: Builds and pushes Docker images with Neo4j + GDS to Cloudflare Container Registry
- AI Chatbot Worker: Deploys the Cloudflare Worker with AI SDK
- Static Site: Builds and deploys the Lumadoc static site to Cloudflare Pages
All components deploy on pushes to main or develop branches.
This setup includes Neo4j Graph Data Science library (Community Edition), which provides:
- Graph Algorithms: PageRank, Centrality, Community Detection, Similarity, Path Finding
- Graph Embeddings: Node2Vec, FastRP, GraphSAGE
- Machine Learning: Link Prediction, Node Classification
- Graph Projections: In-memory graph projections for fast algorithm execution
Example usage:
// Create a graph projection
CALL gds.graph.project(
'myGraph',
'Node',
'RELATES_TO'
);
// Run PageRank algorithm
CALL gds.pageRank.stream('myGraph')
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).name AS name, score
ORDER BY score DESC;.
├── .github/
│ └── workflows/
│ └── ci-cd.yml # GitHub Actions CI/CD workflow
├── worker/ # Cloudflare Worker (AI Chatbot)
│ ├── src/
│ │ └── index.ts # Worker entry point
│ ├── wrangler.toml # Worker configuration
│ └── package.json # Worker dependencies
├── site/ # Lumadoc static site
│ ├── src/ # Markdown source files
│ ├── lumadoc.config.ts # Lumadoc configuration
│ └── package.json # Site dependencies
├── Dockerfile # Neo4j container definition
├── docker-compose.yml # Local development setup
├── neo4j.conf # Neo4j configuration
├── env.example # Environment variables template
├── .dockerignore # Files to exclude from Docker build
├── .gitignore # Git ignore rules
└── README.md # This file
The neo4j.conf file contains custom Neo4j settings:
- Memory allocation (heap and page cache) - increased for GDS operations
- Network bindings
- Security settings
- APOC and GDS plugin configuration
- GDS-specific memory settings
See env.example for available environment variables:
NEO4J_AUTH: Neo4j authentication (format:username/password)NEO4J_PLUGINS: JSON array of plugins (includesapocandgraph-data-science)NEO4J_gds_enterprise__license__accept: Set toyesto accept GDS licenseNEO4J_gds_edition: Set tocommunityfor Community Edition features
GDS requires additional memory for graph algorithm execution:
- Heap: 1-4GB (configurable via
NEO4J_dbms_memory_heap_max__size) - Page Cache: 2GB+ (configurable via
NEO4J_dbms_memory_pagecache_size) - GDS Off-Heap: 2GB+ (configurable via
gds.memory.off_heap.max_sizeinneo4j.conf)
Adjust these settings based on your graph size and algorithm requirements.
- Memory Configuration: Update
neo4j.confwith production-appropriate memory settings based on your graph size - Security: Set strong passwords via
NEO4J_AUTHenvironment variable - Persistent Storage: Configure persistent volumes for data, logs, and imports in Cloudflare
- GDS License: Ensure
NEO4J_gds_enterprise__license__accept=yesis set (required for GDS) - Monitoring: Set up monitoring for Neo4j and GDS operations
- Backup: Configure backup strategies for Neo4j data
- Deployment: Configure Cloudflare deployment commands in the GitHub Actions workflow
- Ensure your Cloudflare container runtime has sufficient memory (4GB+ recommended for GDS)
- Configure persistent volumes for Neo4j data directory
- Set up health checks using the GDS health check in
docker-compose.yml - Monitor GDS memory usage and adjust
gds.memory.off_heap.max_sizeas needed
- Update Neo4j credentials in production deployments
- Configure persistent storage volumes for data persistence on Cloudflare
- Set up backup strategies for Neo4j data
- Add application code that uses Neo4j and GDS algorithms
- Configure Cloudflare deployment commands in the CI/CD workflow
- Test GDS algorithms with your graph data
- Monitor performance and adjust memory settings as needed