How ashishpatel26/consent-ai works
Project Type and Purpose
• This is a full-stack, single-page application built with Streamlit that acts as both a UI and basic back-end for managing consent-related cases and providing AI-powered risk assessments.
• Its main purpose is to allow users to add, update, delete, and view cases, while using an SVM-based AI model to predict risk levels based on textual case descriptions.
Analyzing the File Structure
• Top-level files include:
• Consent_Management_System_with_AI_Case_Analysis.ipynb: Likely used for exploration or demonstration.
• README.md: Contains the project overview, features, and detailed usage instructions.
• consentai-1742893099136.mp4: A demo video for the application.
• The “app” folder contains:
• consentAI.py: The core Python module for the application that implements AI assessment and case management functions.
• There are no separate directories for frontend and backend because Streamlit seamlessly integrates UI and backend logic into one application.
Key Components Identified
a. User Interface (UI) Layer:
• Built using Streamlit. This handles all user interactions such as navigation (sidebar for case view, add, update, delete, train model) and displaying outputs.
b. Business Logic / Case Management Module:
• Implemented in the “consentAI.py” module to orchestrate case operations (add, update, delete, viewing) and interact with the AI model.
• Maintains case data using an in-memory list of dictionaries with fields such as id, description, category, consent status, etc.
c. AI Model Component:
• Uses scikit-learn’s Support Vector Machine (SVM) for risk assessment.
• The text input is processed using TfidfVectorizer to generate numerical features.
• Functions include train_model() for model training, assess_case() for case risk prediction, and retraining the model after data changes.
d. Data Component:
• The case data structure is a list of dictionaries representing individual cases with details such as description, date, risk level, and resolution.
Relationships and Interactions Between Components
• The UI (Streamlit front-end) directly interacts with the Business Logic, invoking functions implemented in consentAI.py.
• When a user adds, updates, or deletes a case via the UI, the corresponding function in the business logic performs the operation on the in-memory data store.
• After any modification to the data, the AI Model component is triggered to retrain the SVM, ensuring predictions remain accurate.
• The assess_case function is called when a user inputs new case descriptions for risk assessment; the data flows from the UI into the AI module, and the resulting risk levels and probabilities are sent back to the UI.
Architectural Patterns and Design Principles
• The application follows a straightforward layered architecture, separating the presentation (Streamlit UI) from the logic (case management and AI assessment).
• It uses a modular approach with a distinct separation of functions (e.g., data handling versus AI prediction).
• Although it doesn’t implement heavy microservices or database abstraction, the design emphasizes clear division of responsibilities that can be easily extended.