seraph

A TypeScript-based, fluent query builder for Neo4j, designed for type-safe and intuitive Cypher query construction.

OTHER License

Stars
4

Seraph

Seraph is an open-source, TypeScript-based query builder for Neo4j that simplifies the construction of Cypher queries through a fluent API. Designed with Domain-Driven Design (DDD) principles, Seraph offers a type-safe and intuitive way to build queries, making it easier for developers to work with Neo4j.

Features

  • Fluent API: Easily build complex Neo4j queries using a chainable, fluent interface.
  • Type Safety: Leverages TypeScript for robust type-checking, reducing errors and improving developer productivity.
  • Modular Design: Built with DDD principles, ensuring clear separation of concerns and a maintainable codebase.
  • Extensible: Designed to be extended with custom functions, relationships, and more advanced Cypher query patterns.

Getting Started

Prerequisites

  • Node.js (version 14 or above)
  • Neo4j database (version 4.x or above)
  • npm or yarn for package management

Installation

To install Seraph, you can use npm:

npm install seraph4j

Or with yarn:

yarn add seraph4j

Usage

Here is a basic example of how to use Seraph to create a simple query:

Creating Nodes

import { QueryBuilder, Node } from 'seraph4j';

const personNode = new Node('Person', { name: 'Alice', age: 30 });
const query = new QueryBuilder()
  .createNode(personNode)
  .build();

console.log(query); 
// Outputs: CREATE (n:Person {name: Alice, age: 30})

Creating Relationships

import { QueryBuilder, Relationship } from 'seraph4j';

const relationship = new Relationship('FRIEND', 'n', 'm');
const query = new QueryBuilder()
  .createRelationship(relationship)
  .build();

console.log(query); 
// Outputs: CREATE (n)-[:FRIEND]->(m)

Project Structure

The project follows Domain-Driven Design principles, structured as follows:

  • src/core/: Core application logic (query builders).
  • src/domain/: Domain models like Nodes and Relationships.
  • src/infrastructure/: Infrastructure-specific code, such as database interactions.
  • src/types/: TypeScript types and interfaces.
  • src/utils/: Utility functions.
  • tests/: Unit and integration tests.

Running Tests

Seraph uses Jest for testing. To run tests, use the following command:

npm test

This will execute all unit and integration tests, ensuring the integrity of the core functionality.

Contributing

Contributions are welcome! Here’s how you can contribute:

  1. Fork the repository.
  2. Create a new feature branch (git checkout -b feature/your-feature-name).
  3. Commit your changes (git commit -m 'Add your feature').
  4. Push to the branch (git push origin feature/your-feature-name).
  5. Open a Pull Request.

Code of Conduct

Please read the Code of Conduct to understand the expectations for participants' behavior in the community.

Contribution Guidelines

Please read CONTRIBUTING.md for details on the process for submitting pull requests and the coding style we use.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Related Projects