### Frontend Setup and Development Server Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/README.md Commands to install frontend dependencies using pnpm and start the Vite development server. ```powershell cd frontend pnpm install pnpm dev ``` -------------------------------- ### Backend Setup Commands Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/README.md Commands to set up the Python backend environment, including activating a virtual environment and installing development dependencies. ```powershell cd D:\AI-Projects\consumer-duty-evidence-engine .\.venv\Scripts\Activate.ps1 python -m pip install -r backend\requirements\dev.txt ``` -------------------------------- ### Start Django Backend Server Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/architecture/observability.md Command to navigate to the backend directory and start the Django development server. ```powershell cd backend python manage.py runserver ``` -------------------------------- ### Start Docker Compose Services Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/adr/0001-monolith-with-async-workers.md Command to start the database and Redis services using Docker Compose. Redis is used as the message broker and result backend. ```bash docker compose up -d db redis ``` -------------------------------- ### Run Backend Migrations and Server Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/README.md Commands to apply database migrations and start the Django development server. ```powershell cd backend python manage.py migrate python manage.py runserver ``` -------------------------------- ### Idempotency Check Example Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/architecture/ingestion-pipeline.md An example demonstrating how to ensure task idempotency by checking if the output already exists before proceeding with processing. ```python if case.parsed_output_exists: return ``` -------------------------------- ### Django Logging Configuration Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/architecture/observability.md Example of configuring JSON formatted logging in Django settings. ```python LOGGING = { "version": 1, "disable_existing_loggers": False, "formatters": { "json": { "format": "% (message)s" } }, "handlers": { "console": { "class": "logging.StreamHandler", "formatter": "json" } }, "root": { "handlers": ["console"], "level": "INFO" } } ``` -------------------------------- ### Example Structured Log Entry Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/architecture/observability.md Shows a sample structured log entry with all required fields for observability. ```json { "timestamp": "2026-03-28T08:00:00Z", "level": "INFO", "logger": "apps.parsing", "message": "Parsing started", "case_id": "uuid", "correlation_id": "uuid", "stage": "parsing" } ``` -------------------------------- ### Degraded Mode Log Example Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/architecture/observability.md Example of a structured log event indicating that the system is operating in degraded mode due to external dependency issues. ```json { "event_type": "case.assessment.completed", "metadata": { "degraded_mode": true } } ``` -------------------------------- ### Case Extraction Failure Log Example Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/architecture/observability.md Example of a structured log event when a case extraction fails, including the error type and relevant IDs. ```json { "event_type": "case.extraction.failed", "case_id": "uuid", "correlation_id": "uuid", "metadata": { "error": "schema validation failed" } } ``` -------------------------------- ### WebSocket Event Payload Example Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/architecture/state-machine.md Example JSON payload for a WebSocket event triggered by a state transition. This payload includes case identifiers, status information, and timestamps for real-time UI updates and observability. ```json { "case_id": "", "status": "assessment_pending", "review_status": "unassigned", "timestamp": "", "degraded_mode_active": false } ``` -------------------------------- ### Structured LLM Output Example Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/adr/0004-structured-output-first.md Demonstrates a structured JSON output from an AI component, including a claim ID, issue type, confidence score, and a structured explanation. This format is machine-readable and schema-valid. ```json { "claim_id": "uuid", "issue_type": "misleading_information", "confidence": 0.87, "explanation": "Fees are mentioned but not clearly disclosed upfront" } ``` -------------------------------- ### Unstructured LLM Output Example Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/adr/0004-structured-output-first.md Illustrates a typical free-form text output from a language model, which lacks structure and is difficult to process programmatically. ```text "The claim appears misleading because fees are not clearly disclosed." ``` -------------------------------- ### PostgreSQL Environment Variables for Local Development Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/adr/0002-postgresql-primary-store.md Sets essential environment variables for connecting to a local PostgreSQL database instance for the project. Ensure these match your local setup. ```powershell $env:POSTGRES_HOST="localhost" $env:POSTGRES_PORT="55432" $env:POSTGRES_DB="cdee" $env:POSTGRES_USER="cdee" $env:POSTGRES_PASSWORD="cdee" $env:DJANGO_SETTINGS_MODULE="config.settings.local" ``` -------------------------------- ### Example Correlation ID Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/architecture/observability.md Illustrates the structure of a correlation ID object used for tracing cases. ```json { "correlation_id": "case-1234-uuid", "case_id": "uuid", "stage": "parsing" } ``` -------------------------------- ### Run Celery Worker Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/README.md Command to start a Celery worker for asynchronous task processing. ```powershell cd backend celery -A config worker -l info ``` -------------------------------- ### Celery Worker Command Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/architecture/ingestion-pipeline.md Command to start a Celery worker in Windows-compatible mode. Requires specifying the Celery application and logging level. ```bash celery -A config worker -l info -P solo ``` -------------------------------- ### Run Celery Worker Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/adr/0001-monolith-with-async-workers.md Command to start a Celery worker for the application. The `-P solo` pool is used to ensure compatibility with Windows. ```powershell python -m celery -A config worker -l info -P solo ``` -------------------------------- ### WebSocket Update Payload Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/architecture/ingestion-pipeline.md Example JSON payload for WebSocket updates, providing real-time status information about a case transition. Includes case ID, status, and timestamp. ```json { "case_id": "", "status": "parsing", "timestamp": "" } ``` -------------------------------- ### Seed Demo Data Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/README.md Run this command to populate the system with 12 seeded demo cases for various scenarios. ```powershell python infra/scripts/seed_demo_data.py ``` -------------------------------- ### Run Evaluation Suite Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/README.md Execute the synthetic evaluation harness with over 40 cases to assess system performance across different scenarios. ```powershell python infra/scripts/run_eval_suite.py ``` -------------------------------- ### Metrics Overview Endpoint Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/README.md Provides an overview of system metrics. ```APIDOC ## GET /api/metrics/overview/ ### Description Retrieves an overview of system metrics. ### Method GET ### Endpoint /api/metrics/overview/ ``` -------------------------------- ### High-Level System Architecture Diagram Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/architecture/system-overview.md Illustrates the interaction between the React UI, Django API, PostgreSQL, Redis, Celery Worker, WebSockets, Audit Events, and Eval Runner. ```mermaid flowchart LR UI[React UI] --> API[Django DRF API] API --> DB[(PostgreSQL)] API --> REDIS[(Redis)] API --> WS[Channels / WebSockets] API --> CELERY[Celery Worker] CELERY --> DB CELERY --> REDIS API --> AUDIT[Audit Events] API --> EVALS[Eval Runner] ``` -------------------------------- ### Task Orchestration Pattern Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/architecture/ingestion-pipeline.md Demonstrates the pattern of explicit task chaining via enqueueing for pipeline stages. This allows for simpler debugging and better retry control. ```python def parse_artifact_task(case_id): # process extract_case_task.delay(case_id) ``` -------------------------------- ### Swagger UI Endpoint Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/README.md Provides access to the Swagger UI for interactive API documentation. ```APIDOC ## GET /api/docs/ ### Description Provides access to the Swagger UI, an interactive documentation interface for the API. ### Method GET ### Endpoint /api/docs/ ``` -------------------------------- ### Failure Handling in Tasks Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/architecture/ingestion-pipeline.md Illustrates the try/except block used for failure handling within pipeline tasks. It ensures the case status is updated to FAILED upon an exception. ```python try: ... except Exception: case.status = FAILED case.save() ``` -------------------------------- ### Enqueue Parsing Task Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/architecture/ingestion-pipeline.md Initiates the artifact parsing process by enqueuing a Celery task. This is the entry point for processing uploaded artifacts. ```python parse_artifact_task.delay(case_id) ``` -------------------------------- ### Review Status Lifecycle Diagram Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/architecture/state-machine.md Visual representation of the allowed transitions for review tasks, independent of the case status. This diagram outlines the workflow from unassigned tasks to their final closed state. ```mermaid stateDiagram-v2 [*] --> UNASSIGNED UNASSIGNED --> ASSIGNED ASSIGNED --> IN_REVIEW IN_REVIEW --> APPROVED IN_REVIEW --> OVERRIDDEN IN_REVIEW --> ESCALATED APPROVED --> CLOSED OVERRIDDEN --> CLOSED ESCALATED --> CLOSED ``` -------------------------------- ### Recommendation Endpoint Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/README.md Provides access to the recommendation for a specific case. ```APIDOC ## GET /api/cases/{id}/recommendation/ ### Description Retrieves the recommendation for a specific case identified by its ID. ### Method GET ### Endpoint /api/cases/{id}/recommendation/ ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the case. ``` -------------------------------- ### Enable pgvector Extension in PostgreSQL Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/adr/0003-pgvector-limited-retrieval.md This command enables the PostgreSQL 'vector' extension, which is necessary for using pgvector. It's typically run during database initialization or for test environments. ```powershell docker compose exec db psql -U cdee -d template1 -c "CREATE EXTENSION IF NOT EXISTS vector;" ``` -------------------------------- ### Review Tasks Endpoint Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/README.md Provides access to review tasks. ```APIDOC ## GET /api/review-tasks/ ### Description Retrieves a list of review tasks. ### Method GET ### Endpoint /api/review-tasks/ ``` -------------------------------- ### Case Status Lifecycle Diagram Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/architecture/state-machine.md Visual representation of the allowed transitions between different case statuses in the evidence review workflow. This diagram helps understand the progression from initial states to final states like ARCHIVED. ```mermaid stateDiagram-v2 [*] --> NEW NEW --> INGESTION_PENDING NEW --> FAILED INGESTION_PENDING --> PARSING INGESTION_PENDING --> FAILED PARSING --> PARSED PARSING --> FAILED PARSED --> EXTRACTION_PENDING PARSED --> FAILED EXTRACTION_PENDING --> EXTRACTED EXTRACTION_PENDING --> NEEDS_REVIEW EXTRACTION_PENDING --> FAILED EXTRACTED --> MAPPING_PENDING EXTRACTED --> FAILED MAPPING_PENDING --> MAPPED MAPPING_PENDING --> FAILED MAPPED --> ASSESSMENT_PENDING MAPPED --> FAILED ASSESSMENT_PENDING --> ASSESSED ASSESSMENT_PENDING --> NEEDS_REVIEW ASSESSMENT_PENDING --> FAILED ASSESSED --> APPROVED ASSESSED --> NEEDS_REVIEW ASSESSED --> ESCALATED NEEDS_REVIEW --> APPROVED NEEDS_REVIEW --> ESCALATED NEEDS_REVIEW --> ARCHIVED APPROVED --> ARCHIVED ESCALATED --> ARCHIVED FAILED --> INGESTION_PENDING FAILED --> PARSING ARCHIVED --> [*] ``` -------------------------------- ### Logging Celery Tasks with Case IDs Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/architecture/observability.md Use this pattern to include `case_id` and `correlation_id` in every task log for better traceability. Ensure the logger object is properly configured. ```python logger.info( "Extraction completed", extra={ "case_id": case.id, "correlation_id": case.correlation_id, "stage": "extraction" } ) ``` -------------------------------- ### Cases Endpoint Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/README.md Provides access to case-related information. ```APIDOC ## GET /api/cases/ ### Description Retrieves a list of cases. ### Method GET ### Endpoint /api/cases/ ``` -------------------------------- ### API Schema Endpoint Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/README.md Provides access to the OpenAPI schema for the API. ```APIDOC ## GET /api/schema/ ### Description Retrieves the OpenAPI schema definition for the API. ### Method GET ### Endpoint /api/schema/ ``` -------------------------------- ### Evals Runs Endpoint Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/README.md Provides access to evaluation runs. ```APIDOC ## GET /api/evals/runs/ ### Description Retrieves a list of evaluation runs. ### Method GET ### Endpoint /api/evals/runs/ ``` -------------------------------- ### Django Model for Audit Events Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/architecture/observability.md Defines the database model for storing audit events. It includes fields for event type, case association, correlation ID, timestamp, and flexible metadata. ```python class AuditEvent(models.Model): event_type = models.CharField(max_length=255) case = models.ForeignKey("Case", on_delete=models.CASCADE) correlation_id = models.UUIDField() timestamp = models.DateTimeField(auto_now_add=True) metadata = models.JSONField(default=dict) ``` -------------------------------- ### Claims Endpoint Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/README.md Provides access to claims associated with a specific case. ```APIDOC ## GET /api/cases/{id}/claims/ ### Description Retrieves a list of claims for a specific case identified by its ID. ### Method GET ### Endpoint /api/cases/{id}/claims/ ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the case. ``` -------------------------------- ### Audit Event Structure Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/docs/architecture/observability.md This JSON structure represents an audit event, providing a permanent record of system actions. It includes event type, case identifiers, timestamp, and metadata. ```json { "event_type": "case.parsing.completed", "case_id": "uuid", "correlation_id": "uuid", "timestamp": "2026-03-28T08:01:00Z", "metadata": { "duration_ms": 1200 } } ``` -------------------------------- ### Assessments Endpoint Source: https://github.com/cherryaugusta/consumer-duty-evidence-engine/blob/main/README.md Provides access to assessments associated with a specific case. ```APIDOC ## GET /api/cases/{id}/assessments/ ### Description Retrieves a list of assessments for a specific case identified by its ID. ### Method GET ### Endpoint /api/cases/{id}/assessments/ ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the case. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.