# zahar-pr/speech-analytics architecture

> Architecture diagram of the GitHub repository zahar-pr/speech-analytics, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zahar-pr/speech-analytics
- Repository: https://github.com/zahar-pr/speech-analytics

## Overview

##### Project type and purpose
- This is a two-part, full-stack integration application:
a. A C#/.NET 9.0 “front” component that likely hosts a minimal Web API or UI.
b. A Python-based “amo-integration” service that orchestrates calls to external systems (amoCRM, GigaChat, PBX, SberSpeech).
- Purpose: accept requests from the Frontend, transform and route them to external services via dedicated Python service modules, then return or log the combined response.

##### File structure
- Top level:
- README.md (empty)
- amo-integration/
- front/
- logs/
- amo-integration/:
- main.py – entry point for orchestration logic
- conf/ – prompt templates and certificates (russian.pem)
- models/ – Pydantic or domain models for each external system (amo.py, gigachat.py, pbx.py, speech.py)
- services/ – connectors/clients for each external system (amo.py, gigachat.py, pbx.py, sberspeech.py)
- utils/ – common utilities (e.g., logging setup)
- requirements.txt – Python dependencies
- front/:
- front.sln & front.csproj – .NET solution and project files targeting .NET 9.0
- Program.cs – minimal-API host configuration
- appsettings.json(+Development) – configuration for the .NET app
- logs/: centralized file logs.log capturing runtime events

##### (empty) README
- No explicit architecture section; rely on directory naming and file roles to infer layers and data flows.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (.NET Minimal API)"
        direction TB
        F_prog["Program.cs"]:::frontend
        F_proj["front.csproj"]:::frontend
        F_settings["appsettings.json"]:::frontend
        F_dev["appsettings.Development.json"]:::frontend
        F_sln["front.sln"]:::frontend
    end

    %% Integration Service Layer
    subgraph "Integration Service (Python)"
        direction TB
        A_main["main.py"]:::backend

        subgraph "Models Layer"
            direction TB
            M_amo["amo.py"]:::backend
            M_gig["gigachat.py"]:::backend
            M_pbx["pbx.py"]:::backend
            M_sp["speech.py"]:::backend
        end

        subgraph "Services Layer"
            direction TB
            S_amo["amo.py"]:::backend
            S_gig["gigachat.py"]:::backend
            S_pbx["pbx.py"]:::backend
            S_sber["sberspeech.py"]:::backend
        end

        subgraph "Utilities"
            direction TB
            U_log["setup_logger.py"]:::backend
        end

        subgraph "Dependencies"
            direction TB
            Req["requirements.txt"]:::backend
            Env["env-template"]:::backend
        end
    end

    %% Configuration Store
    subgraph "Configuration Store"
        direction TB
        C_prompt["prompt.txt"]:::config
        C_cert["russian.pem"]:::config
    end

    %% External Systems
    subgraph "External Systems"
        direction TB
        Ext_amoCRM["amoCRM API"]:::external
        Ext_giga["GigaChat API"]:::external
        Ext_pbx["PBX System"]:::external
        Ext_sber["SberSpeech API"]:::external
    end

    %% Logging Sink
    Logging["logs.log"]:::log

    %% Data Flows
    F_prog -->|"HTTP/REST"| A_main
    A_main -->|uses| M_amo
    A_main -->|uses| M_gig
    A_main -->|uses| M_pbx
    A_main -->|uses| M_sp

    A_main -->|orchestrates| S_amo
    A_main -->|orchestrates| S_gig
    A_main -->|orchestrates| S_pbx
    A_main -->|orchestrates| S_sber

    S_amo -->|"HTTP"| Ext_amoCRM
    S_gig -->|"HTTP"| Ext_giga
    S_pbx -->|"Protocol"| Ext_pbx
    S_sber -->|"HTTP"| Ext_sber

    C_prompt -->|loaded by| A_main
    C_cert -->|loaded by| A_main

    Req -->|dependencies for| A_main
    Env -->|template for| A_main

    A_main -->|logs via| U_log
    U_log -->|writes to| Logging

    %% Click Events
    click F_prog "https://github.com/zahar-pr/speech-analytics/blob/main/front/front/Program.cs"
    click F_proj "https://github.com/zahar-pr/speech-analytics/blob/main/front/front/front.csproj"
    click F_settings "https://github.com/zahar-pr/speech-analytics/blob/main/front/front/appsettings.json"
    click F_dev "https://github.com/zahar-pr/speech-analytics/blob/main/front/front/appsettings.Development.json"
    click F_sln "https://github.com/zahar-pr/speech-analytics/blob/main/front/front.sln"

    click A_main "https://github.com/zahar-pr/speech-analytics/blob/main/amo-integration/main.py"

    click C_prompt "https://github.com/zahar-pr/speech-analytics/blob/main/amo-integration/conf/prompt.txt"
    click C_cert "https://github.com/zahar-pr/speech-analytics/blob/main/amo-integration/conf/russian.pem"

    click M_amo "https://github.com/zahar-pr/speech-analytics/blob/main/amo-integration/models/amo.py"
    click M_gig "https://github.com/zahar-pr/speech-analytics/blob/main/amo-integration/models/gigachat.py"
    click M_pbx "https://github.com/zahar-pr/speech-analytics/blob/main/amo-integration/models/pbx.py"
    click M_sp "https://github.com/zahar-pr/speech-analytics/blob/main/amo-integration/models/speech.py"

    click S_amo "https://github.com/zahar-pr/speech-analytics/blob/main/amo-integration/services/amo.py"
    click S_gig "https://github.com/zahar-pr/speech-analytics/blob/main/amo-integration/services/gigachat.py"
    click S_pbx "https://github.com/zahar-pr/speech-analytics/blob/main/amo-integration/services/pbx.py"
    click S_sber "https://github.com/zahar-pr/speech-analytics/blob/main/amo-integration/services/sberspeech.py"

    click U_log "https://github.com/zahar-pr/speech-analytics/blob/main/amo-integration/utils/setup_logger.py"

    click Req "https://github.com/zahar-pr/speech-analytics/blob/main/amo-integration/requirements.txt"
    click Env "https://github.com/zahar-pr/speech-analytics/tree/main/amo-integration/env-template"

    click Logging "https://github.com/zahar-pr/speech-analytics/blob/main/logs/logs.log"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0288D1,stroke-width:1px;
    classDef backend fill:#E0F2F1,stroke:#00796B,stroke-width:1px;
    classDef external fill:#FFE0B2,stroke:#FB8C00,stroke-width:1px;
    classDef config fill:#F5F5F5,stroke:#9E9E9E,stroke-width:1px;
    classDef log fill:#EEEEEE,stroke:#616161,stroke-width:1px;
```
