How leyber91/ai_canvas works
Core Components
• Frontend: Represent the client-side aspects, including the HTML, CSS, and JavaScript folders (note the many JavaScript subdirectories for handling API communication, conversation panels, dialogs, graph managers, UI components, workflows, and theme management). Highlight that Cytoscape.js is used for graph visualization.
• API Controllers (e.g., chat_controller, execute_controller, graph_controller, etc.) which expose endpoints for node operations.
• Domain Services (e.g., chat_service, edge_service, graph_service, model_service, node_service) handling business logic.
• Infrastructure layer: This includes database interactions (via SQLAlchemy), AI provider integrations (Ollama and Groq through ai_providers), and possibly some external API coupling.
• Core and Utility components: Configurations, exception handling, streaming utilities, and similar constructs.
• External Services: Represent the external dependencies such as:
• Ollama (running locally) and its real-time response streaming.
• Groq API, which is an external service integrated via environment configurations.
Relationships and Interactions
• From the Frontend (UI) to the Backend APIs (which are defined within the “app/api/controllers”).
• How the backend calls domain services, which in turn utilize the infrastructure (database repositories and AI provider interfaces).
• Workflow execution: Demonstrate how nodes are connected in a directed acyclic graph. Include an element for the graph analysis using NetworkX (for topological sorting and cycle detection) as well as the sequential workflow execution logic.
• That the real-time streaming is handled over a WebSocket or similar channels (Flask-SocketIO).
Architectural Patterns & Design Principles
• MVC/MVT Influences: The API (controllers), domain models, and templating (in backend/templates and static assets) can be mapped to a similar pattern.
• Modular Design: Indicate that both the client-side (organized in modules, core components, and UI managers) and server-side (dividing responsibilities among controllers, services, and infrastructure) follow modular design.