A command-line tool that models neural signaling pathways as a directed
graph and persists it in MySQL 8. Nodes are biological entities (e.g.
Estradiol, Tyrosine Hydroxylase, Dopamine, CREB, BDNF); edges are typed,
directed relationships: ACTIVATES, INHIBITS, SYNTHESIZES, MODULATES.
The graph and all traversal algorithms are built from scratch — adjacency list, a hand-built Queue (BFS), and a hand-built Stack / explicit recursion (DFS). The only third-party data dependency is the MySQL JDBC driver.
Built with strict spec-driven development. The source of truth lives in
specs/(spec.md→plan.md→tasks.md) and is published at https://neurograph-seven.vercel.app.
- Add / remove a node (synced to MySQL and the in-memory graph).
- Add / remove a typed, directed edge between two nodes.
- Load the full graph from MySQL into memory on startup.
- Traverse downstream from a node (BFS and DFS).
- Shortest path between two molecules (BFS, unweighted).
- Detect feedback loops (cycles).
- Rank the most influential nodes by reachable-set size (out-degree tiebreak).
Normalized MySQL schema (see schema.sql):
nodes—id, uniquename, optionaldescription,created_at.edge_types— lookup table:ACTIVATES,INHIBITS,SYNTHESIZES,MODULATES.edges—source_id/target_id(FK →nodes,ON DELETE CASCADE),edge_type_id(FK →edge_types), with aUNIQUE(source, target, type)constraint. Cascade + FKs guarantee no orphan edges.
In memory the graph is an adjacency list: Map<String, List<Edge>> where each
Edge is (target, type).
ui (interactive menu) -> service (GraphService) -> db (JDBC repositories)
|
+-> domain (Graph, EdgeType, ds/Queue, ds/Stack, algo/GraphAlgorithms)
The CLI never touches SQL; all persistence is behind GraphService. Every
algorithm is pure and unit-tested against in-memory fixtures.
- Java 17+ (built/tested on JDK 25)
- Maven 3.9+
- MySQL 8 (for running the CLI; not needed to run the unit tests)
docker-compose.yml starts MySQL 8 and auto-loads schema.sql + seed.sql on
first run:
docker compose up -d # MySQL on host port 3307, schema + seed loadedThen point the app at it:
export NEUROGRAPH_DB_HOST=127.0.0.1 NEUROGRAPH_DB_PORT=3307 \
NEUROGRAPH_DB_NAME=neurograph NEUROGRAPH_DB_USER=root \
NEUROGRAPH_DB_PASSWORD=neurograph- Create the schema and seed data:
mysql -u root -p < schema.sql
mysql -u root -p neurograph < seed.sql- Configure the connection. Copy the example and edit, or use env vars:
cp db.properties.example db.properties
# or override at runtime:
# NEUROGRAPH_DB_HOST, NEUROGRAPH_DB_PORT, NEUROGRAPH_DB_NAME,
# NEUROGRAPH_DB_USER, NEUROGRAPH_DB_PASSWORDmvn test # runs the unit suite (no database required)
mvn package # builds target/neurograph.jar (runnable fat JAR)DB integration tests are tagged @Tag("db") and excluded by default so the
suite runs anywhere. To run them against a live MySQL (e.g. the Docker container
above, using a dedicated neurograph_test database):
# create an empty test database with the same schema
docker exec -i neurograph-mysql mysql -uroot -pneurograph -e "CREATE DATABASE IF NOT EXISTS neurograph_test"
# (apply schema.sql tables to neurograph_test as well)
NEUROGRAPH_DB_HOST=127.0.0.1 NEUROGRAPH_DB_PORT=3307 \
NEUROGRAPH_DB_NAME=neurograph_test NEUROGRAPH_DB_USER=root \
NEUROGRAPH_DB_PASSWORD=neurograph \
mvn -Ddb.tests= test(-Ddb.tests= clears the default db tag exclusion so JdbcRepositoryDbTest
runs alongside the offline suite.)
The integration tests cover node/edge round-trips, the unique constraints,
ON DELETE CASCADE (no orphan edges), and the FR3 startup load against real
MySQL. If no database is reachable they are skipped (not failed).
java -jar target/neurograph.jarYou'll get an interactive menu:
=== NeuroGraph ===
1) List nodes 7) Detect feedback loops
2) Add node 8) Rank most influential
3) Remove node 9) Downstream (BFS)
4) Add edge 10) Downstream (DFS)
5) Remove edge 11) Reload from database
6) Shortest path 0) Exit
- List nodes (
1) shows each entity and its outgoing typed edges. - Shortest path (
6) fromEstradioltoCREB→Estradiol -> BDNF -> CREB(2 steps). - Detect feedback loops (
7) reports a cycle such asCREB -> BDNF -> TrkB -> CREB. - Rank most influential (
8) lists nodes by how many entities they can ultimately influence. - Add edge (
4): enter source, target, and a type (ACTIVATES/INHIBITS/SYNTHESIZES/MODULATES).
schema.sql, seed.sql # database
src/main/java/com/neurograph/
App.java # composition root + startup load
domain/ # Graph, Edge, EdgeType, ds/, algo/
service/GraphService.java # memory <-> DB sync
db/ # repositories (interfaces) + jdbc/ impls
ui/Cli.java # interactive menu (no SQL)
src/test/java/com/neurograph/ # JUnit 5 tests + in-memory fixtures/fakes
specs/ # spec.md, plan.md, tasks.md (source of truth)