# ericdelucas/esc_semestre4_pi architecture

> Architecture diagram of the GitHub repository ericdelucas/esc_semestre4_pi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ericdelucas/esc_semestre4_pi
- Repository: https://github.com/ericdelucas/esc_semestre4_pi

## Overview

PI4 is a CTI financial-analysis dashboard with role-based access, scenario and custom-data analysis, reporting, audit and an AI assistant. The main workflow runs from login through dataset loading and scenario selection to persona-specific indicators and views; users can also upload data, request reports, or ask contextual questions. The graph uses the supplied excerpts and SOURCE INDEX for relationships; several important subsystems are indexed but their internal calls were not shown, so those links are omitted rather than inferred.

Main entry points: [`PI4/Frontend/app.py`](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/app.py) (Dashboard app), [`PI4/Backend/metrics/financial_kpis.py`](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/metrics/financial_kpis.py) (Financial KPIs), [`PI4/Backend/data_loader/csv_reader.py`](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/data_loader/csv_reader.py) (CTI data loading), [`PI4/Backend/main.py`](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/main.py) (Backend API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard experience"]
  node_app["Dashboard app<br/>[app.py]"]
  node_bootstrap["Dashboard context<br/>[bootstrap.py]"]
  node_navigation["Page navigation<br/>[navigation.py]"]
  node_persona_views["Persona views<br/>[ceo.py]"]
  node_report_view["Report view<br/>[report.py]"]
end

subgraph group_analysis["Data and analysis"]
  node_data_input["Custom data input<br/>[data_input.py]"]
  node_report_service["Custom reports"]
  node_data_loader["CTI data loading<br/>[csv_reader.py]"]
  node_upload_normalizer["Upload normalization"]
  node_dashboard_pipeline["Dashboard pipeline"]
  node_financial_metrics["Financial KPIs<br/>[financial_kpis.py]"]
  node_column_resolver["Column resolution<br/>[column_resolver.py]"]
  node_audit["Data audit<br/>[runner.py]"]
end

subgraph group_assistant["AI assistant"]
  node_chat_panel["Assistant panel<br/>[panel.py]"]
  node_chat_context["Assistant context<br/>[context.py]"]
  node_rag_engine["RAG retrieval<br/>[engine.py]"]
  node_rag_documents["RAG documents<br/>[documents.py]"]
  node_rag_answers["Answer generation<br/>[answers.py]"]
  node_backend_rag["Backend RAG adapter<br/>[rag_engine.py]"]
end

subgraph group_operations["Access and operations"]
  node_auth_ui["Login and roles<br/>[auth.py]"]
  node_api_client["API client<br/>[api_client.py]"]
  node_backend_api["Backend API<br/>[main.py]"]
  node_auth_service["Auth service<br/>[auth.py]"]
  node_auth_store[("User and access store<br/>[models.py]")]
  node_risk_alerts["Risk alerts<br/>[risk_alerts.py]"]
  node_email_service["Email delivery<br/>[email_service.py]"]
end

node_user(("Dashboard user"))
node_smtp(("SMTP service"))

node_user -->|"uses"| node_app
node_app -->|"checks access"| node_auth_ui
node_app -->|"loads context"| node_bootstrap
node_app -->|"accepts uploads"| node_data_input
node_app -->|"renders pages"| node_navigation
node_app -->|"renders assistant"| node_chat_panel
node_auth_ui -->|"sends login requests"| node_api_client
node_navigation -->|"routes to"| node_report_view
node_report_view -->|"requests report"| node_report_service
node_data_input -.->|"normalizes upload"| node_upload_normalizer
node_upload_normalizer -->|"uses CSV reader"| node_data_loader
node_upload_normalizer -->|"resolves columns"| node_column_resolver
node_dashboard_pipeline -->|"loads data"| node_data_loader
node_dashboard_pipeline -->|"calculates indicators"| node_financial_metrics
node_financial_metrics -->|"uses magnitude"| node_data_loader
node_financial_metrics -->|"resolves columns"| node_column_resolver
node_chat_panel -->|"builds context"| node_chat_context
node_chat_context -->|"creates engine"| node_rag_engine
node_rag_engine -->|"retrieves documents"| node_rag_documents
node_rag_engine -->|"builds answers"| node_rag_answers
node_backend_rag -->|"loads CTI data"| node_data_loader
node_backend_rag -->|"builds ranking"| node_financial_metrics
node_backend_api -->|"handles authentication"| node_auth_service
node_backend_api -->|"dispatches alerts"| node_risk_alerts
node_backend_api -->|"dispatches email"| node_email_service
node_auth_service -->|"reads and logs"| node_auth_store
node_risk_alerts -->|"sends alerts"| node_email_service
node_email_service -.->|"sends mail"| node_smtp

click node_app "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/app.py"
click node_auth_ui "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/controllers/auth.py"
click node_api_client "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/models/api_client.py"
click node_data_input "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/controllers/data_input.py"
click node_bootstrap "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/controllers/bootstrap.py"
click node_navigation "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/controllers/navigation.py"
click node_persona_views "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/views/persona_tabs/ceo.py"
click node_report_view "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/views/report.py"
click node_report_service "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/services/custom_report_service.py"
click node_data_loader "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/data_loader/csv_reader.py"
click node_upload_normalizer "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/data_loader/upload_normalizer.py"
click node_dashboard_pipeline "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/services/dashboard_pipeline.py"
click node_financial_metrics "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/metrics/financial_kpis.py"
click node_column_resolver "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/metrics/column_resolver.py"
click node_audit "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/audit/runner.py"
click node_chat_panel "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/views/ai_assistant/panel.py"
click node_chat_context "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/views/ai_assistant/context.py"
click node_rag_engine "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/models/rag_engine/engine.py"
click node_rag_documents "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/models/rag_engine/documents.py"
click node_rag_answers "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/models/rag_engine/answers.py"
click node_backend_rag "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/rag_engine.py"
click node_backend_api "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/main.py"
click node_auth_service "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/db/auth.py"
click node_auth_store "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/db/models.py"
click node_risk_alerts "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/services/risk_alerts.py"
click node_email_service "https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/services/email_service.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_bootstrap,node_navigation,node_persona_views,node_report_view,node_user toneBlue
class node_data_input,node_report_service,node_data_loader,node_upload_normalizer,node_dashboard_pipeline,node_financial_metrics,node_column_resolver,node_audit toneAmber
class node_chat_panel,node_chat_context,node_rag_engine,node_rag_documents,node_rag_answers,node_backend_rag toneMint
class node_auth_ui,node_api_client,node_backend_api,node_auth_service,node_auth_store,node_risk_alerts,node_email_service toneRose
class node_smtp toneIndigo
```

## Components

### Dashboard experience

- [Dashboard app](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/app.py): `PI4/Frontend/app.py`
- [Dashboard context](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/controllers/bootstrap.py): `PI4/Frontend/src/controllers/bootstrap.py`
- [Page navigation](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/controllers/navigation.py): `PI4/Frontend/src/controllers/navigation.py`
- [Persona views](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/views/persona_tabs/ceo.py): `PI4/Frontend/src/views/persona_tabs/ceo.py`
- [Report view](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/views/report.py): `PI4/Frontend/src/views/report.py`

### Data and analysis

- [Custom data input](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/controllers/data_input.py): `PI4/Frontend/src/controllers/data_input.py`
- [Custom reports](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/services/custom_report_service.py): `PI4/Backend/services/custom_report_service.py`
- [CTI data loading](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/data_loader/csv_reader.py): `PI4/Backend/data_loader/csv_reader.py`
- [Upload normalization](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/data_loader/upload_normalizer.py): `PI4/Backend/data_loader/upload_normalizer.py`
- [Dashboard pipeline](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/services/dashboard_pipeline.py): `PI4/Backend/services/dashboard_pipeline.py`
- [Financial KPIs](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/metrics/financial_kpis.py): `PI4/Backend/metrics/financial_kpis.py`
- [Column resolution](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/metrics/column_resolver.py): `PI4/Backend/metrics/column_resolver.py`
- [Data audit](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/audit/runner.py): `PI4/Backend/audit/runner.py`

### AI assistant

- [Assistant panel](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/views/ai_assistant/panel.py): `PI4/Frontend/src/views/ai_assistant/panel.py`
- [Assistant context](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/views/ai_assistant/context.py): `PI4/Frontend/src/views/ai_assistant/context.py`
- [RAG retrieval](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/models/rag_engine/engine.py): `PI4/Frontend/src/models/rag_engine/engine.py`
- [RAG documents](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/models/rag_engine/documents.py): `PI4/Frontend/src/models/rag_engine/documents.py`
- [Answer generation](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/models/rag_engine/answers.py): `PI4/Frontend/src/models/rag_engine/answers.py`
- [Backend RAG adapter](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/rag_engine.py): `PI4/Backend/rag_engine.py`

### Access and operations

- [Login and roles](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/controllers/auth.py): `PI4/Frontend/src/controllers/auth.py`
- [API client](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Frontend/src/models/api_client.py): `PI4/Frontend/src/models/api_client.py`
- [Backend API](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/main.py): `PI4/Backend/main.py`
- [Auth service](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/db/auth.py): `PI4/Backend/db/auth.py`
- [User and access store](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/db/models.py): `PI4/Backend/db/models.py`
- [Risk alerts](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/services/risk_alerts.py): `PI4/Backend/services/risk_alerts.py`
- [Email delivery](https://github.com/ericdelucas/esc_semestre4_pi/blob/main/PI4/Backend/services/email_service.py): `PI4/Backend/services/email_service.py`

### Other components

- **Dashboard user**
- **SMTP service**

## Connections

- Dashboard user → Dashboard app: uses (evidence: `PI4/Frontend/app.py`)
- Dashboard app → Login and roles: checks access (evidence: `PI4/Frontend/app.py`)
- Dashboard app → Dashboard context: loads context (evidence: `PI4/Frontend/app.py`)
- Dashboard app → Custom data input: accepts uploads (evidence: `PI4/Frontend/app.py`)
- Dashboard app → Page navigation: renders pages (evidence: `PI4/Frontend/app.py`)
- Dashboard app → Assistant panel: renders assistant (evidence: `PI4/Frontend/app.py`)
- Login and roles → API client: sends login requests (evidence: `PI4/Frontend/src/controllers/auth.py`)
- Page navigation → Report view: routes to (evidence: `PI4/Frontend/src/views/report.py`)
- Report view → Custom reports: requests report (evidence: `PI4/Frontend/src/views/report.py`)
- Custom data input → Upload normalization: normalizes upload
- Upload normalization → CTI data loading: uses CSV reader (evidence: `PI4/Backend/data_loader/upload_normalizer.py`)
- Upload normalization → Column resolution: resolves columns (evidence: `PI4/Backend/data_loader/upload_normalizer.py`)
- Dashboard pipeline → CTI data loading: loads data (evidence: `PI4/Backend/services/dashboard_pipeline.py`)
- Dashboard pipeline → Financial KPIs: calculates indicators (evidence: `PI4/Backend/services/dashboard_pipeline.py`)
- Financial KPIs → CTI data loading: uses magnitude (evidence: `PI4/Backend/metrics/financial_kpis.py`)
- Financial KPIs → Column resolution: resolves columns (evidence: `PI4/Backend/metrics/financial_kpis.py`)
- Assistant panel → Assistant context: builds context (evidence: `PI4/Frontend/src/views/ai_assistant/panel.py`)
- Assistant context → RAG retrieval: creates engine (evidence: `PI4/Frontend/src/views/ai_assistant/context.py`)
- RAG retrieval → RAG documents: retrieves documents (evidence: `PI4/Frontend/src/models/rag_engine/engine.py`)
- RAG retrieval → Answer generation: builds answers (evidence: `PI4/Frontend/src/models/rag_engine/engine.py`)
- Backend RAG adapter → CTI data loading: loads CTI data (evidence: `PI4/Backend/rag_engine.py`)
- Backend RAG adapter → Financial KPIs: builds ranking (evidence: `PI4/Backend/rag_engine.py`)
- Backend API → Auth service: handles authentication (evidence: `PI4/Backend/main.py`)
- Backend API → Risk alerts: dispatches alerts (evidence: `PI4/Backend/main.py`)
- Backend API → Email delivery: dispatches email (evidence: `PI4/Backend/main.py`)
- Auth service → User and access store: reads and logs (evidence: `PI4/Backend/db/auth.py`)
- Risk alerts → Email delivery: sends alerts (evidence: `PI4/Backend/services/risk_alerts.py`)
- Email delivery → SMTP service: sends mail
