diff --git a/store-all/api/Dockerfile b/store-all/api/Dockerfile new file mode 100644 index 0000000..207addb --- /dev/null +++ b/store-all/api/Dockerfile @@ -0,0 +1,6 @@ +FROM python:3.9-slim +WORKDIR /usr/src/app +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt +COPY . . +CMD ["python", "app.py"] diff --git a/store-all/api/app.py b/store-all/api/app.py new file mode 100644 index 0000000..68bb8b7 --- /dev/null +++ b/store-all/api/app.py @@ -0,0 +1,30 @@ +from flask import Flask, jsonify, request +from neo4j import GraphDatabase +from pymilvus import connections, Collection + +app = Flask(__name__) + +# Neo4j Connection +neo4j_driver = GraphDatabase.driver("bolt://neo4j:7687", auth=("neo4j", "testpassword")) + +# Milvus Connection +connections.connect("default", host="milvus", port="19530") + +@app.route('/') +def home(): + return jsonify({'message': 'Hello, World!'}) + +@app.route('/neo4j_test') +def neo4j_test(): + with neo4j_driver.session() as session: + result = session.run("MATCH (n) RETURN count(n) AS count") + count = result.single()["count"] + return jsonify({'neo4j_node_count': count}) + +@app.route('/milvus_test') +def milvus_test(): + collections = Collection.list() + return jsonify({'milvus_collections': collections}) + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=5000) diff --git a/store-all/api/requirements.txt b/store-all/api/requirements.txt new file mode 100644 index 0000000..907fa4d --- /dev/null +++ b/store-all/api/requirements.txt @@ -0,0 +1,4 @@ +Flask==2.0.3 +neo4j==4.4.1 +pymilvus==2.0.2 +gunicorn==20.1.0 diff --git a/store-all/docker-compose.yml b/store-all/docker-compose.yml new file mode 100644 index 0000000..25aa22f --- /dev/null +++ b/store-all/docker-compose.yml @@ -0,0 +1,45 @@ +version: '3.8' + +services: + neo4j: + image: neo4j:latest + container_name: neo4j + ports: + - "7474:7474" # HTTP + - "7687:7687" # Bolt + volumes: + - ./neo4j/data:/data + - ./neo4j/logs:/logs + - ./neo4j/import:/var/lib/neo4j/import + - ./neo4j/plugins:/plugins + environment: + NEO4J_AUTH: neo4j/testpassword + + milvus: + image: milvusdb/milvus:v2.0.0 + container_name: milvus + ports: + - "19530:19530" # Milvus default port + volumes: + - ./milvus/db:/var/lib/milvus/db + - ./milvus/conf:/var/lib/milvus/conf + - ./milvus/logs:/var/lib/milvus/logs + environment: + TZ: UTC + + api: + build: ./api + container_name: api + ports: + - "5000:5000" + volumes: + - ./api:/usr/src/app + depends_on: + - neo4j + - milvus + environment: + NEO4J_URI: bolt://neo4j:7687 + NEO4J_USER: neo4j + NEO4J_PASSWORD: testpassword + MILVUS_HOST: milvus + MILVUS_PORT: 19530 diff --git a/store-all/story.md b/store-all/story.md new file mode 100644 index 0000000..dcad1e6 --- /dev/null +++ b/store-all/story.md @@ -0,0 +1,21 @@ + + + +Rich Relationships: Graph databases excel at managing highly interconnected data, allowing you to efficiently model, store, and query complex networks of relationships. + +Performance: They are optimized for traversing complex relationships and can perform deep queries very fast, unlike traditional databases where join-intensive queries can be slow. + +Flexibility: They typically allow for schema-less or schema-flexible data, making them adaptable to evolving data models without significant redesign. + +Intuitive Query Language: Many graph databases use query languages like Cypher (Neo4j), which are powerful yet readable, making complex queries more straightforward to construct and understand. + +Cons: + +Scalability: Horizontal scaling can be challenging with graph databases, as they are inherently designed for deep, computationally intense traversals. + +Specialized Knowledge: The need for understanding specific query languages and graph theory can steepen the learning curve. + +Resource Intensity: Maintaining high-performance levels, especially with very large datasets, can require significant computational resources. + + +Python is widely adopted in the data science community, offering extensive libraries and frameworks for both graph databases (like py2neo for Neo4j) and vector databases (like milvus-py for Milvus). It’s particularly strong in analytics, machine learning, and AI, which aligns well with the use cases of vector databases. \ No newline at end of file