How larsvogt/knowledge-graph-building-blocks works
Project Type and Purpose
• The application’s purpose is to demonstrate how modular knowledge graph components (KGBBs) can guide the creation, management, and exploration of FAIR (findable, accessible, interoperable, and reusable) knowledge graphs.
• The README explains that the prototype uses predefined patterns (graph patterns, input controls, access templates, display templates, and CRUD queries) to structure and process knowledge graphs, all connected through a Neo4j backend.
Analysis of the File Structure and Its Architectural Implications
• Top-Level Files and Directories:
• Files such as app.py, setup.py, code_notes.py, scrap_note.py, and test.py indicate that there’s an executable web server component (likely a Flask application), setup/installation capabilities, and some exploratory or test code.
• The “KGBB” directory includes modules like KGBBFunctions_and_Classes.py and connectNeo4j.py, which encapsulate the business logic and connectivity aspects to Neo4j (using the bolt:// protocol with provided authentication details).
• The “static” folder includes JavaScript (jQuery and custom JS forms), CSS, and font assets, clearly representing the frontend assets.
• The “templates” folder is populated with numerous HTML files, which are likely Jinja2 templates used to render various views corresponding to different semantic unit types (statement units, item units, etc.).
• Architectural Clues:
• The presence of templates and static assets indicates a separation of presentation (client-side) and logic (server-side).
• The specialized modules for Neo4j connectivity show a clear backend that communicates with a graph database.
• The modular grouping of files (e.g., KGBB components, various HTML templates for different semantic unit views, and static assets) suggests that the overall system is organized into several layers: user interface, backend processing, and database integration.
Main Components
a. Frontend / Presentation Layer:
• User's Web Browser: Represents the client that loads the application.
• HTML Templates: All the view files under the “templates” directory that render forms, graphs, and interactive UI components.
• Static Assets: JavaScript files (e.g., form_bioportal_complete.js, jquery-3.6.0.js), CSS styles (like standard.css and font-awesome assets) that define the client-side behavior and styling.
b. Backend / Application Layer:
• Flask Application: Centered around app.py, which drives the requests, renders templates, and handles routing.
• KGBB Modules: Specifically, KGBBFunctions_and_Classes.py and connectNeo4j.py, which contain business logic, domain-specific functionalities for semantic unit processing, and the logic for connecting to and querying the Neo4j database.
• Utility and Setup Scripts: Files like setup.py and code_notes.py support environment preparation and serve as documentation or development notes.
c. Data/Persistence Layer:
• Neo4j Graph Database: As required by the README, Neo4j (Version 4.2.4 or above with APOC plugin) is the primary datastore, accessed via the bolt:// protocol (bolt://localhost:7687) using specified credentials.
d. Documentation and Additional Resources:
• The Vogt_Retreat_2021_extended.pdf provides contextual details on the semantics and vision behind the KGBB concept.
• README serves as the high-level documentation for the system’s purpose, architectural overview, and setup instructions.
Relationships and Data Flow
• How client-side requests (HTTP GET/POST) are sent from the web browser to the Flask server.
• How the Flask application routes these requests to the appropriate business logic in the KGBB modules.
• The responses (rendered HTML pages, JSON responses, etc.) then flow back from the backend to the client.
Key Architectural Patterns and Design Principles
• Separation of Concerns: Clearly segmented layers between presentation (templates, static files), application logic (Flask + KGBB modules), and data persistence (Neo4j).
• Modular Design: Each semantic unit or KGBB is implemented as a separate module/component, which potentially allows for scalability by introducing new types of semantic units without major changes to the overall structure.
• Use of Standard Web Framework Patterns: The combination of a Flask application with Jinja2 templates and a dedicated module to handle database connectivity reflects a fairly standard MVC/MV* pattern.
• Integration of External Technologies: Reliance on Neo4j for graph data storage and the use of third-party libraries (e.g., jQuery, Font Awesome).
Elements
• "Web Client / Browser"
• "Flask Application (app.py)"
• "KGBB Business Logic Modules (KGBBFunctions_and_Classes.py, connectNeo4j.py)"
• "HTML Templates (various files under /templates)"
• "Static Assets (JS, CSS under /static)"
• "Neo4j Database" (with note of connection details: bolt://localhost:7687)
• "Setup & Documentation" (setup.py, README, Vogt_Retreat_2021_extended.pdf)
• User requests and responses between the browser and Flask app.
• Internal interactions from Flask to the KGBB modules.
• Database calls from the KGBB modules (via connectNeo4j.py) to the Neo4j server.
• Labels/Annotations:
• Component with its role (e.g., “Handles user input via forms”, “Contains business logic for managing knowledge graph units”).
• Flows with notes like “HTTP Requests/Responses” and “Graph Queries”.