> ## Documentation Index
> Fetch the complete documentation index at: https://tonic-ai.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Analytics

> Portfolio analytics and dashboard insights

## Overview

The Analytics feature provides comprehensive portfolio analytics, dashboard insights, and reporting capabilities for monitoring credit portfolio performance, risk metrics, and operational statistics.

**Code Reference**: `app/api/routes.py` (analytics endpoints), `client/src/components/Dashboard.tsx`

***

## Key Features

### Portfolio Analytics

* **Portfolio Overview**: Complete portfolio statistics
* **Risk Metrics**: Credit risk metrics and indicators
* **Performance Tracking**: Track portfolio performance over time
* **Trend Analysis**: Analyze trends and patterns

**Code Reference**: `app/api/routes.py` (get\_portfolio\_analytics endpoint)

### Dashboard Analytics

* **Dashboard Statistics**: Key metrics for dashboard display
* **Activity Summary**: User activity and system usage
* **Document Statistics**: Document processing statistics
* **Policy Statistics**: Policy decision statistics

**Code Reference**: `app/api/routes.py` (get\_dashboard\_analytics endpoint)

### Reporting

* **Custom Reports**: Generate custom analytics reports
* **Export Functionality**: Export analytics data
* **Visualization**: Data visualization and charts
* **Scheduled Reports**: Schedule automatic report generation

***

## Analytics Metrics

### Portfolio Metrics

* **Total Portfolio Value**: Sum of all loan commitments
* **Active Loans**: Number of active loans
* **Default Rate**: Percentage of loans in default
* **Average Interest Rate**: Average interest rate across portfolio
* **Geographic Distribution**: Loan distribution by geography

### Risk Metrics

* **Credit Risk Score**: Overall portfolio credit risk
* **Concentration Risk**: Sector and geographic concentration
* **Policy Violations**: Number of policy violations
* **Breach Count**: Number of compliance breaches
* **Recovery Rate**: Loan recovery success rate

### Operational Metrics

* **Document Processing**: Documents processed per period
* **Extraction Accuracy**: Extraction accuracy metrics
* **Policy Decisions**: Policy decision statistics
* **User Activity**: User activity and engagement

### Agent Workflow Metrics

* **LangAlpha Analyses**: Number of quantitative analyses performed
* **DeepResearch Queries**: Number of research queries executed
* **PeopleHub Profiles**: Number of business intelligence profiles generated
* **Workflow Success Rate**: Percentage of successful workflow completions
* **Average Processing Time**: Average time to complete workflows
* **Tool Usage Statistics**: Usage statistics for agent tools (market data, web search, Python REPL, etc.)

**Integration**: Agent workflow metrics are automatically tracked and included in analytics dashboards.

**Code Reference**: `app/services/quantitative_analysis_service.py`, `app/services/deep_research_service.py`, `app/services/digitizer_chatbot_service.py`

***

## API Endpoints

### Get Portfolio Analytics

<Endpoint method="GET" path="/api/analytics/portfolio" />

Get comprehensive portfolio analytics.

**Response**: Portfolio statistics, risk metrics, and performance data

**Code Reference**: `app/api/routes.py` (get\_portfolio\_analytics endpoint)

### Get Dashboard Analytics

<Endpoint method="GET" path="/api/analytics/dashboard" />

Get dashboard statistics and key metrics.

**Response**: Dashboard statistics including activity, documents, and policy decisions

**Code Reference**: `app/api/routes.py` (get\_dashboard\_analytics endpoint)

***

## User Interface

### Dashboard

**Location**: `client/src/components/Dashboard.tsx`

**Features**:

* **Portfolio Overview**: Key portfolio metrics
* **Activity Summary**: Recent activity summary
* **Document Statistics**: Document processing stats
* **Policy Statistics**: Policy decision summary
* **Quick Actions**: Quick access to common actions

**Access**: Navigate to "Dashboard" in sidebar

***

## Best Practices

1. **Regular Monitoring**: Monitor analytics regularly
2. **Trend Analysis**: Analyze trends over time
3. **Risk Assessment**: Use analytics for risk assessment
4. **Performance Tracking**: Track portfolio performance
5. **Report Generation**: Generate regular reports

***

## Agent Workflow Integration

### Agent Dashboard Analytics

The **Agent Dashboard** provides comprehensive analytics for all agent workflows:

* **Unified Statistics**: Overview of all agent results (LangAlpha, DeepResearch, PeopleHub)
* **Usage Analytics**: Track agent usage by type, user, and time period
* **Performance Metrics**: Average processing time, success rates, error rates
* **Result Statistics**: Number of analyses, research queries, and profiles generated

**Access**: Navigate to "Agent Dashboard" in sidebar

**Code Reference**: `client/src/apps/agent-dashboard/AgentDashboard.tsx`

### Agent Results in Analytics

Agent workflow results are automatically integrated into analytics:

* **Deal Analytics**: Agent results linked to deals appear in deal analytics
* **Portfolio Analytics**: Quantitative analyses contribute to portfolio risk metrics
* **Research Analytics**: DeepResearch queries tracked in research analytics
* **Business Intelligence**: PeopleHub profiles included in credit risk assessments

### Report Generation

Agent workflows automatically generate reports that are:

* **Included in Analytics**: Report statistics tracked in analytics dashboards
* **Exportable**: Reports can be exported and included in analytics exports
* **Auditable**: All agent operations logged for audit compliance

**Code Reference**: `app/services/agent_report_service.py`, `app/services/report_formatter.py`

***

## Additional Resources

* [Agent Workflows Feature](/features/agent-workflows) - Complete agent workflow documentation
* [Agent Dashboard](/apps/agent-dashboard) - Unified dashboard for agent results
* [Audit Reports Feature](/features/audit-reports) - Audit report generation
* [Configuration Guide](/getting-started/configuration) - Analytics configuration

***

**Last Updated**: 2025-01-14\
**Code Reference**: `app/api/routes.py`, `client/src/components/Dashboard.tsx`, `client/src/apps/agent-dashboard/AgentDashboard.tsx`
