# cruxm-organic/modern-plastics-voice-crm architecture

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

- Interactive diagram: https://gitdiagram.com/cruxm-organic/modern-plastics-voice-crm
- Repository: https://github.com/cruxm-organic/modern-plastics-voice-crm

## Overview

Modern Plastics is a B2B voice-agent CRM with a Streamlit operations interface and FastAPI backend. Users log in, manage leads, inspect local-time calling safety and call history, and review operational metrics; the backend scopes CRM data to authenticated users and also accepts voice-provider webhooks and offers call simulation. The excerpts show the main API and database setup, but omit portions of the UI and webhook implementation, so those relationships are not inferred beyond what is visible.

Main entry points: [`frontend/app.py`](https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/frontend/app.py) (CRM dashboard), [`backend/main.py`](https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/backend/main.py) (Lead routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["CRM interface"]
  node_dashboard["CRM dashboard<br/>[app.py]"]
  node_login["Login and registration<br/>[app.py]"]
  node_lead_ui["Lead management<br/>[app.py]"]
  node_safety_ui["Timezone safety view<br/>[app.py]"]
  node_history_ui["Call history view<br/>[app.py]"]
end

subgraph group_api["CRM backend"]
  node_auth_routes["Authentication routes<br/>[main.py]"]
  node_auth_guard["Session authentication<br/>[main.py]"]
  node_lead_routes["Lead routes<br/>[main.py]"]
  node_timezone["Timezone safety evaluation<br/>[main.py]"]
  node_history_routes["Call history route<br/>[main.py]"]
  node_webhook["Voice webhook<br/>[main.py]"]
  node_simulation["Call simulation<br/>[main.py]"]
end

subgraph group_data["CRM data"]
  node_database[("CRM database<br/>[main.py]")]
end

node_operator(("CRM operator"))
node_voice_provider["ElevenLabs"]

node_operator -->|"uses"| node_dashboard
node_dashboard -->|"presents"| node_login
node_login -->|"requests login"| node_auth_routes
node_lead_ui -->|"fetches and creates"| node_lead_routes
node_safety_ui -->|"requests status"| node_lead_routes
node_history_ui -->|"requests history"| node_history_routes
node_dashboard -->|"renders"| node_lead_ui
node_dashboard -->|"renders"| node_safety_ui
node_dashboard -->|"renders"| node_history_ui
node_auth_routes -->|"reads and writes"| node_database
node_lead_routes -->|"requires user"| node_auth_guard
node_history_routes -->|"requires user"| node_auth_guard
node_lead_routes -->|"reads and writes"| node_database
node_history_routes -->|"reads"| node_database
node_auth_guard -->|"looks up user"| node_database
node_lead_routes -->|"evaluates timezone"| node_timezone
node_simulation -->|"requires user"| node_auth_guard
node_simulation -->|"loads lead"| node_database
node_simulation -->|"calls handler"| node_webhook
node_voice_provider -.->|"submits events"| node_webhook

click node_dashboard "https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/frontend/app.py"
click node_login "https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/frontend/app.py"
click node_lead_ui "https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/frontend/app.py"
click node_safety_ui "https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/frontend/app.py"
click node_history_ui "https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/frontend/app.py"
click node_auth_routes "https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/backend/main.py"
click node_auth_guard "https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/backend/main.py"
click node_lead_routes "https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/backend/main.py"
click node_timezone "https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/backend/main.py"
click node_history_routes "https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/backend/main.py"
click node_webhook "https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/backend/main.py"
click node_simulation "https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/backend/main.py"
click node_database "https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/backend/main.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_dashboard,node_login,node_lead_ui,node_safety_ui,node_history_ui toneBlue
class node_auth_routes,node_auth_guard,node_lead_routes,node_timezone,node_history_routes,node_webhook,node_simulation toneAmber
class node_database toneMint
class node_operator,node_voice_provider toneIndigo
```

## Components

### CRM interface

- [CRM dashboard](https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/frontend/app.py): `frontend/app.py`
- [Login and registration](https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/frontend/app.py): `frontend/app.py`
- [Lead management](https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/frontend/app.py): `frontend/app.py`
- [Timezone safety view](https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/frontend/app.py): `frontend/app.py`
- [Call history view](https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/frontend/app.py): `frontend/app.py`

### CRM backend

- [Authentication routes](https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/backend/main.py): `backend/main.py`
- [Session authentication](https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/backend/main.py): `backend/main.py`
- [Lead routes](https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/backend/main.py): `backend/main.py`
- [Timezone safety evaluation](https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/backend/main.py): `backend/main.py`
- [Call history route](https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/backend/main.py): `backend/main.py`
- [Voice webhook](https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/backend/main.py): `backend/main.py`
- [Call simulation](https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/backend/main.py): `backend/main.py`

### CRM data

- [CRM database](https://github.com/cruxm-organic/modern-plastics-voice-crm/blob/main/backend/main.py): `backend/main.py`

### Other components

- **CRM operator**
- **ElevenLabs**

## Connections

- CRM operator → CRM dashboard: uses
- CRM dashboard → Login and registration: presents (evidence: `frontend/app.py`)
- Login and registration → Authentication routes: requests login (evidence: `frontend/app.py`)
- Lead management → Lead routes: fetches and creates (evidence: `frontend/app.py`)
- Timezone safety view → Lead routes: requests status (evidence: `frontend/app.py`)
- Call history view → Call history route: requests history (evidence: `frontend/app.py`)
- CRM dashboard → Lead management: renders (evidence: `frontend/app.py`)
- CRM dashboard → Timezone safety view: renders (evidence: `frontend/app.py`)
- CRM dashboard → Call history view: renders (evidence: `frontend/app.py`)
- Authentication routes → CRM database: reads and writes (evidence: `backend/main.py`)
- Lead routes → Session authentication: requires user (evidence: `backend/main.py`)
- Call history route → Session authentication: requires user (evidence: `backend/main.py`)
- Lead routes → CRM database: reads and writes (evidence: `backend/main.py`)
- Call history route → CRM database: reads (evidence: `backend/main.py`)
- Session authentication → CRM database: looks up user (evidence: `backend/main.py`)
- Lead routes → Timezone safety evaluation: evaluates timezone (evidence: `backend/main.py`)
- Call simulation → Session authentication: requires user (evidence: `backend/main.py`)
- Call simulation → CRM database: loads lead (evidence: `backend/main.py`)
- Call simulation → Voice webhook: calls handler (evidence: `backend/main.py`)
- ElevenLabs → Voice webhook: submits events
