How yuchenxia/llmriskanalyzer works
Project type and purpose
• This is a full-stack web application (“FMEA Assisted by LLM System”) that automates Failure Mode and Effects Analysis by combining a Python/Flask backend with a browser-based frontend.
• The README clarifies its goal: ingest FMEA datasets (CSV), invoke an LLM to generate failure-mode analyses, and display or export results via a simple web UI.
File structure
• Top-level “source_code” directory contains:
• app.py: Flask application entry point (routes, request handling)
• llm.py & agents.py: wrappers and orchestration logic for calling the LLM API
• FEMA_data_model.py & data_model_utilities.py: domain model definitions and helper functions for parsing/serializing FMEA data
• dataset/: raw CSV inputs
• saved_fmea_data.json, output.csv, restored_output.csv, fmea_download.csv: intermediate or final data artifacts
• generation_agent.json: LLM prompt configuration
• static/: client-side JavaScript (UI logic) and CSS
• templates/: Jinja2 HTML templates for the frontend
• requirements.txt lists Python dependencies (Flask, OpenAI client, pandas, etc.)
README for additional insights
• Describes two demo use cases (general FMEA and brake-by-wire)
Main components and interactions
a. Frontend (Browser)
• Static assets (HTML, CSS, JS) served by Flask
• User uploads/selects an FMEA CSV, triggers analysis via AJAX/fetch
b. Backend (Flask app)
• HTTP endpoints (e.g., “/”, “/analyze”, “/download”) implemented in app.py
• Parses incoming CSV using data_model_utilities, builds domain objects via FEMA_data_model
• Routes requests to agents.py which uses llm.py to call an external LLM endpoint
• Collects LLM responses, post-processes them, and writes results to output.csv / JSON
c. Data storage
• Local file system for datasets and outputs (CSV, JSON)
• Optionally swap to a database if volume grows
d. External services
• OpenAI (or similar) LLM REST API for generation
e. User download
• Processed results offered as CSV/JSON for download
Key architectural patterns / design principles
• MVC-style separation:
• Model layer: FEMA_data_model & data_model_utilities
• Controller layer: app.py routes
• View layer: Jinja2 templates + static JS
• Agent pattern: agents.py encapsulates the strategy of prompt prep and response handling
• Single process micro-service: monolithic Flask app, straightforward orchestration
• File-based persistence: simple storage without a full RDBMS