How deivisito2911/expert_systems works
Project Type and Purpose
• This is a standalone Python “Expert System” application. Its goal is to load a knowledge base (JSON files), apply rule‐based inference, and identify the phylum of species (or any other domain provided via the JSON schema). It provides a command‐line and simple GUI/HTML interface for querying, adding rules, and updating the knowledge base.
Architectural Overview
• Layered, modular monolith:
a. Presentation Layer: CLI and simple HTML/Tkinter front end
b. Application/Logic Layer: The expert‐general engine, rule management, and action handlers
c. Data Layer: JSON‐based knowledge base files
Main Components
• main.py (Orchestrator)
• Initializes the application, loads configuration, and launches the UI/menu.
• Presentation Layer
• src/cli.py – Generic CLI scaffolding
• src/interfaz/menu.py, consultarbase.py, insertarbase.py, guardarbase.py – Menu options and user prompts
• src/interfaz/presentacion.html – Optional HTML/Tkinter template (requires customtkinter & pillow)
• Application/Logic Layer
• src/experto_general/entry.py – Entry point into the inference engine
• src/experto_general/engine.py – Core forward‐chaining/backward‐chaining logic
• src/experto_general/base.py – Knowledge base abstraction layer
• src/experto_general/property.py, response.py – Data structures for facts and results
• src/acciones.py – Domain‐specific action handlers (e.g., adding new rules or facts)
• Data Layer
• src/Base_De_Conocimiento/Phylum.json (and copies) – JSON files describing rules and facts
• src/example.json – Sample schema for user customization
Relationships and Data Flows
• Startup: main.py → loads JSON (Data Layer) → initializes Engine & Base (Application Layer)
• User Interaction: Presentation Layer (menu/CLI) → calls Engine via entry.py
• Inference: Engine reads facts/rules from Base → applies logic → returns response objects
• Persistence: If user adds or modifies rules/facts, Presentation Layer → calls acciones.py → updates JSON files
Architectural Patterns and Principles
• Layered Architecture: Clear separation (Presentation / Business Logic / Data)
• Modularity: Each package (experto_general, interfaz, Base_De_Conocimiento) encapsulates a concern
• Extensibility: New domains beyond “Phylum” can be added by supplying a JSON that follows example.json schema
Technologies & Frameworks
• Language: Python 3.x
• CLI: built-in argparse or custom in cli.py
• GUI: customtkinter + pillow (optional) rendering of presentacion.html
• Data Serialization: JSON