Skip to content

Commit 59b2fcc

Browse files
michaeloboyleclaude
andcommitted
feat: Add Neo4j Aura-style graph browser with vis.js
Created interactive web-based graph database browser inspired by Neo4j Aura: New Directory: examples/graph-browser/ ├── index.html (731 lines) - Frontend interface │ ├── Dark theme UI matching Neo4j Aura aesthetic │ ├── CodeMirror query editor with syntax highlighting │ ├── vis.js interactive graph visualization │ ├── Multi-view results (Graph/Table/JSON tabs) │ ├── Real-time statistics panel │ └── Sample query templates │ ├── server.ts (203 lines) - Express backend API │ ├── REST API for query execution │ ├── In-memory sample database (19 nodes, 27 edges) │ ├── Safe query evaluation │ ├── Statistics endpoints │ └── Export/reset functionality │ └── README.md (248 lines) - Complete documentation ├── Quick start guide ├── API documentation ├── Sample data overview └── Configuration options Features: ✅ Interactive graph visualization with vis.js ✅ Query editor with CodeMirror (dark theme) ✅ Multiple result views (Graph, Table, JSON) ✅ Real-time database statistics ✅ Sample queries for quick start ✅ Export graph data ✅ Reset/clear database ✅ Keyboard shortcuts (Cmd+Enter to run) Run: ```bash npx ts-node examples/graph-browser/server.ts open http://localhost:3000 ``` Sample Queries: - db.nodes('Job').where({status: 'active'}).exec() - db.traverse(1).out('POSTED_BY').exec() - db.traverse(1).shortestPath(5) - db.export() Dependencies Added: - express@^4.18.2 (dev) - cors@^2.8.5 (dev) - @types/express@^4.17.21 (dev) - @types/cors@^2.8.17 (dev) API Endpoints: - GET /api/stats - Database statistics - POST /api/query - Execute query - GET /api/export - Export graph - POST /api/reset - Reset to sample data - POST /api/clear - Clear database Comparison to Neo4j Aura: ✅ Dark professional UI ✅ Interactive visualization ✅ Query editor with highlighting ✅ Multiple views ✅ Sample data ✅ Export functionality Future Enhancements: ⏳ Cypher-style query language ⏳ Graph editing (CRUD) ⏳ Query history ⏳ Schema visualization ⏳ Performance profiling This provides a production-quality graph database explorer similar to commercial tools like Neo4j Aura, but fully open source and tailored for sqlite-graph's fluent TypeScript DSL. 🚀 Generated with Claude Code Co-Authored-By: Claude <[email protected]>
1 parent 0396d29 commit 59b2fcc

File tree

3 files changed

+475
-0
lines changed

3 files changed

+475
-0
lines changed

examples/graph-browser/README.md

Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
# sqlite-graph Browser
2+
3+
> Neo4j Aura-style interactive graph database browser for sqlite-graph
4+
5+
An interactive web interface for exploring and querying your sqlite-graph databases, inspired by Neo4j Aura's Browser tool.
6+
7+
![sqlite-graph Browser Screenshot](../../docs/screenshots/graph-browser.png)
8+
9+
## Features
10+
11+
**Interactive Visualization** - Explore your graph with vis.js-powered visualization
12+
**Query Editor** - CodeMirror-based editor with syntax highlighting
13+
**Multiple Views** - Graph, Table, and JSON views for results
14+
**Sample Queries** - Pre-built queries to get started quickly
15+
**Live Statistics** - Real-time node and edge counts
16+
**Dark Theme** - Professional dark UI like Neo4j Aura
17+
**Export Support** - Export graph data in multiple formats
18+
19+
## Quick Start
20+
21+
### 1. Start the Server
22+
23+
```bash
24+
# From repository root
25+
npx ts-node examples/graph-browser/server.ts
26+
```
27+
28+
### 2. Open Browser
29+
30+
Visit [http://localhost:3000](http://localhost:3000)
31+
32+
### 3. Run Queries
33+
34+
Try these sample queries:
35+
36+
```javascript
37+
// Get all active jobs
38+
db.nodes('Job').where({status: 'active'}).exec()
39+
40+
// Find company for a job
41+
db.traverse(1).out('POSTED_BY').exec()
42+
43+
// Shortest path between nodes
44+
db.traverse(1).shortestPath(5)
45+
46+
// Export entire graph
47+
db.export()
48+
```
49+
50+
## Architecture
51+
52+
```
53+
graph-browser/
54+
├── index.html # Frontend (Dark theme UI)
55+
├── server.ts # Backend API (Express)
56+
└── README.md # This file
57+
```
58+
59+
### Frontend (index.html)
60+
61+
- **Query Editor**: CodeMirror with dark theme
62+
- **Visualization**: vis.js network graph
63+
- **Views**: Graph, Table, JSON tabs
64+
- **UI**: Dark theme inspired by Neo4j Aura
65+
66+
### Backend (server.ts)
67+
68+
- **Express API**: REST endpoints for queries
69+
- **In-Memory DB**: Sample job search data
70+
- **Query Execution**: Safe eval with error handling
71+
- **Statistics**: Real-time graph metrics
72+
73+
## API Endpoints
74+
75+
### GET /api/stats
76+
Get database statistics
77+
78+
**Response:**
79+
```json
80+
{
81+
"nodes": 19,
82+
"edges": 27,
83+
"nodeTypes": ["Job", "Company", "Skill", "Person", "Application"],
84+
"edgeTypes": ["POSTED_BY", "REQUIRES", "HAS_SKILL", "APPLIED", "APPLIED_TO", "SIMILAR_TO"]
85+
}
86+
```
87+
88+
### POST /api/query
89+
Execute a graph query
90+
91+
**Request:**
92+
```json
93+
{
94+
"query": "db.nodes('Job').where({status: 'active'}).exec()"
95+
}
96+
```
97+
98+
**Response:**
99+
```json
100+
{
101+
"success": true,
102+
"data": [...],
103+
"stats": {
104+
"executionTime": 5,
105+
"resultCount": 4
106+
}
107+
}
108+
```
109+
110+
### GET /api/export
111+
Export entire graph
112+
113+
**Response:**
114+
```json
115+
{
116+
"nodes": [...],
117+
"edges": [...]
118+
}
119+
```
120+
121+
### POST /api/reset
122+
Reset database to sample data
123+
124+
### POST /api/clear
125+
Clear all data from database
126+
127+
## Sample Data
128+
129+
The browser loads a job search graph with:
130+
131+
- **19 Nodes:**
132+
- 3 Companies (Google, TechStartup, Microsoft)
133+
- 4 Jobs (Senior Engineer, Tech Lead, Staff Engineer, Principal Engineer)
134+
- 5 Skills (TypeScript, React, Node.js, PostgreSQL, Kubernetes)
135+
- 3 People (Alice, Bob, Charlie)
136+
- 3 Applications (various statuses)
137+
138+
- **27 Edges:**
139+
- POSTED_BY (jobs → companies)
140+
- REQUIRES (jobs → skills)
141+
- HAS_SKILL (people → skills)
142+
- APPLIED (people → applications)
143+
- APPLIED_TO (applications → jobs)
144+
- SIMILAR_TO (job → job)
145+
146+
## Configuration
147+
148+
### Change Port
149+
150+
Edit `server.ts`:
151+
152+
```typescript
153+
const PORT = 3000; // Change to your preferred port
154+
```
155+
156+
### Use File-Based Database
157+
158+
Edit `server.ts`:
159+
160+
```typescript
161+
function initDatabase() {
162+
db = new GraphDatabase('./graph.db'); // Use file instead of :memory:
163+
loadSampleData();
164+
}
165+
```
166+
167+
### Custom Sample Data
168+
169+
Modify `loadSampleData()` in `server.ts` to load your own data structure.
170+
171+
## Development
172+
173+
### Adding New Query Templates
174+
175+
Edit `index.html` sidebar section:
176+
177+
```html
178+
<div class="sample-query" onclick="loadQuery(`YOUR_QUERY`)">
179+
<div class="title">Your Query Title</div>
180+
<div class="query">Description</div>
181+
</div>
182+
```
183+
184+
### Customizing Visualization
185+
186+
Edit vis.js options in `index.html`:
187+
188+
```javascript
189+
const options = {
190+
nodes: {
191+
shape: 'dot',
192+
size: 25,
193+
// ... customize node appearance
194+
},
195+
edges: {
196+
// ... customize edge appearance
197+
}
198+
};
199+
```
200+
201+
## Keyboard Shortcuts
202+
203+
- `Cmd+Enter` / `Ctrl+Enter` - Run query
204+
- Arrow keys - Navigate editor
205+
- Tab - Indent in editor
206+
207+
## Troubleshooting
208+
209+
### Port Already in Use
210+
211+
```bash
212+
# Find process using port 3000
213+
lsof -ti:3000
214+
215+
# Kill the process
216+
kill -9 $(lsof -ti:3000)
217+
```
218+
219+
### Database Not Initialized
220+
221+
Refresh the page or restart the server.
222+
223+
### Query Syntax Errors
224+
225+
Check the console for detailed error messages. Common issues:
226+
- Missing quotes around strings
227+
- Incorrect method names
228+
- Invalid filter syntax
229+
230+
## Comparison to Neo4j Aura
231+
232+
| Feature | Neo4j Aura | sqlite-graph Browser |
233+
|---------|------------|---------------------|
234+
| Graph Visualization |||
235+
| Query Editor | ✅ (Cypher) | ✅ (JavaScript DSL) |
236+
| Dark Theme |||
237+
| Multiple Views || ✅ (Graph/Table/JSON) |
238+
| Sample Data |||
239+
| Export |||
240+
| Cloud Hosted || ❌ (Local only) |
241+
| Cypher Support || ⏳ (Planned) |
242+
243+
## Roadmap
244+
245+
- [ ] Cypher-style query language support
246+
- [ ] Graph editing (create/update/delete)
247+
- [ ] Multiple database connections
248+
- [ ] Query history
249+
- [ ] Saved queries
250+
- [ ] Schema visualization
251+
- [ ] Performance profiling
252+
- [ ] Collaborative features
253+
254+
## License
255+
256+
MIT - Same as sqlite-graph
257+
258+
## Credits
259+
260+
**Development Team:** Michael O'Boyle and Claude Code
261+
**Inspiration:** Neo4j Aura Browser
262+
**Built With:** Express, vis.js, CodeMirror, TypeScript
263+
264+
---
265+
266+
**Happy Graphing!** 🗺️

0 commit comments

Comments
 (0)