This document details the technologies, libraries, and tools used in the Knowledge Graph Synthesis System, providing rationale for each choice and highlighting key components.
- Python 3.9+
- Rationale: Extensive library support for NLP, graph processing, and ML tasks
- Benefits: Beginner-friendly syntax, strong type hinting support, widespread adoption
- Limitations: Performance trade-offs compared to compiled languages
- Poetry
- Rationale: Modern dependency management and packaging
- Benefits: Reproducible builds, virtual environment management
- Alternative: pip + requirements.txt for simplicity if preferred
- Git
- Rationale: Industry-standard version control
- Benefits: History tracking, branching, collaboration support
- Tooling: GitHub for hosting and collaboration
-
NLTK
- Purpose: Basic NLP tasks, tokenization, stemming
- Benefits: Mature, well-documented, extensive language support
- Limitations: Slower than some alternatives, not deep-learning based
-
spaCy
- Purpose: Advanced NLP, entity recognition, dependency parsing
- Benefits: Fast, accurate, Python-native design, multilingual support
- Limitations: Model size can be large
-
langdetect
- Purpose: Language detection for multilingual support
- Benefits: Lightweight, reasonably accurate
- Limitations: May struggle with short texts
-
NetworkX
- Purpose: Graph creation, manipulation, and analysis
- Benefits: Pythonic, flexible, extensive algorithms, beginner-friendly
- Limitations: Not optimized for very large graphs
-
PyVis
- Purpose: Interactive graph visualization
- Benefits: Easy integration with NetworkX, interactive features
- Limitations: Limited customization compared to D3.js
-
Community Detection
- Purpose: Finding communities and clusters in graphs
- Options: python-louvain (Louvain method), infomap
-
LangChain
- Purpose: Framework for LLM applications
- Benefits: Standardized interfaces, chain of thought, integration with various providers
- Limitations: Evolving API, sometimes more complex than needed
-
API Clients
- Anthropic API: For Claude models
- OpenAI API: For GPT models
- Google API: For Gemini models
- DeepSeek API: For DeepSeek models
- Ollama SDK: For local models
-
SQLite
- Purpose: Lightweight database for persistence
- Benefits: Zero configuration, file-based, beginner-friendly
- Limitations: Limited concurrency, not suitable for distributed systems
-
JSON files
- Purpose: Storage of graph data and results
- Benefits: Human-readable, widely supported, simple
- Limitations: Not optimized for large datasets
- Streamlit
- Purpose: Simple web interface for interaction
- Benefits: Python-native, fast development, minimal frontend knowledge required
- Limitations: Less customization than full web frameworks
-
Virtual Environments
- Purpose: Isolation of dependencies
- Options: Poetry environments, venv, conda
-
Environment Variables
- Purpose: Configuration and secrets management
- Implementation: python-dotenv for loading from .env files
-
pytest
- Purpose: Unit and integration testing
- Benefits: Simple fixture system, parametrization, good ecosystem
-
pytest-mock
- Purpose: Mocking external dependencies
- Benefits: Simplifies testing of components that use LLM APIs
-
black
- Purpose: Code formatting
- Benefits: Consistent style, reduces formatting debates
-
flake8
- Purpose: Style guide enforcement
- Benefits: Catches common errors, maintains code quality
-
mypy
- Purpose: Static type checking
- Benefits: Catches type errors early, improves code documentation
-
Anthropic API (Claude)
- Purpose: High-quality text generation and reasoning
- Benefits: Strong reasoning capabilities, longer context windows
- Limitations: Cost, API rate limits
-
OpenAI API (GPT)
- Purpose: Alternative text generation and reasoning
- Benefits: Widely used, extensive documentation
- Limitations: Cost, API rate limits
-
Google API (Gemini)
- Purpose: Alternative text generation and reasoning
- Benefits: Competitive capabilities, potential integration with other Google services
- Limitations: Cost, API rate limits
-
DeepSeek API
- Purpose: Alternative text generation and reasoning
- Benefits: Specialized models for certain domains
- Limitations: Emerging platform, less documentation
-
Ollama (Local)
- Purpose: Local model execution
- Benefits: No API costs, privacy, no internet required
- Limitations: Limited by local hardware, potentially lower quality
- Hexagonal Architecture
- Purpose: Separate core logic from external services
- Benefits: Swappable components, testability, clean separation of concerns
- Function-based DI
- Purpose: Provide dependencies to components without tight coupling
- Benefits: Testability, flexibility, simplicity
- Implementation: Simple factory functions rather than complex frameworks
- Bounded Contexts
- Purpose: Organize the system into logical domains
- Benefits: Clearer organization, focused responsibility
- Implementation: Lightweight, focusing on vocabulary and structure
- Facade Pattern
- Purpose: Unified interface for different LLM providers
- Benefits: Easy switching between providers, consistent error handling
- Function-based Interfaces
- Purpose: Clearly defined entry points for modules
- Benefits: Simplicity, maintainability, beginner-friendly
- Result Pattern
- Purpose: Consistent error handling across modules
- Benefits: Predictable error propagation, clear success/failure indicators
- Implementation: Simple result objects with success flag and error details
The technology choices prioritize:
- Beginner-Friendliness: Using well-documented, widely-adopted libraries with gentle learning curves
- Flexibility: Supporting multiple LLM providers and languages
- Maintainability: Clear structure and separation of concerns
- Pragmatism: Favoring simple, straightforward solutions over complex architectures
Alternative stacks were considered, including:
- Neo4j for graph storage: More powerful but introduces additional complexity
- FastAPI for web interface: More flexible but requires more frontend knowledge
- Rust or Go for core components: Better performance but steeper learning curve and less beginner-friendly
- Hugging Face models: Greater flexibility but more complex setup and higher local resource requirements
The chosen stack balances accessibility, flexibility, and power, making it well-suited for the project requirements while remaining approachable for developers with varying experience levels.