# valantoni/full-stack-python-template architecture

> Architecture diagram of the GitHub repository valantoni/full-stack-python-template, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/valantoni/full-stack-python-template
- Repository: https://github.com/valantoni/full-stack-python-template

## Overview

##### Project Type and Purpose
- This is a **full-stack Python application** built with **Streamlit** for the UI layer and **Auth0** for authentication.
- It exposes a single entrypoint (`app.py`) that renders dashboards and runs reporting tools, and it integrates with Auth0 (an external Identity Provider) and an SMTP/email module.

##### File Structure
- Top Level
- `app.py` – the Streamlit UI entrypoint, orchestrates page routing and calls into business modules.
- `send_email.py` – wrapper to send alerts via SMTP or an email service.
- `requirements.txt` – dependency manifest.
- `.streamlit/config.toml`, `.streamlit/secrets.toml` – Streamlit config and Auth0 credentials.
- `assets/` – static resources (images, CSS, etc.).
- Business Logic Packages
- `reports/` – modules implementing different report pages (alerts.py, bugs.py, dashboard.py).
- `tools/` – utility functions (history.py, search.py).

##### README for Additional Insights
- The README confirms a Streamlit-first approach with Auth0 as the only external auth dependency.
- No database is mentioned—state is in-memory or via external APIs.
- An “email alerts” feature is present via `send_email.py`.

##### Main Components
a. **User Interface (Streamlit App)**
- Node: app.py + assets/
- Responsibilities: render pages, handle routing, capture user interactions.
b. **Business Logic Layer**
- Node: reports/ (alerts, bugs, dashboard) and tools/ (history, search)
- Responsibilities: compute reports, search history, perform data transformations.
c. **Authentication Service (Auth0)**
- External service node
- Responsibilities: handle login, token issuance, session management.
d. **Email Service**
- Node: send_email.py
- Responsibilities: format and send alert emails to users.

##### Relationships and Data Flows
- User → Streamlit UI: HTTP requests (clicks, form submissions).
- Streamlit UI → Auth0: OAuth2/OpenID Connect redirects for login/auth.
- Post‐login User → Streamlit UI (authorized session).
- Streamlit UI → Business Logic: function calls into reports/ and tools/.
- Business Logic → Email Service: function call inside alerts report to send notifications.
- Optionally, Business Logic could call external APIs or databases (not present here).

##### Architectural Patterns and Principles
- **Separation of Concerns**: UI is isolated in `app.py`, business logic in reports/ and tools/, cross‐cutting email logic in send_email.py.
- **Layered Architecture**:
- Presentation Layer (Streamlit)
- Application Layer (routing & orchestration)
- Domain/Business Layer (reports and tools modules)
- Infrastructure Layer (Auth0, email service)
- **Externalized Configuration** via `.streamlit/secrets.toml` for credentials, keeping code stateless.

##### Detail Without Over-Engineering
- Every module (alerts.py, bugs.py, history.py, etc.) as sub-components of the Business Logic layer.
- `.streamlit/secrets.toml` as the configuration source for Auth0 credentials.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        App["app.py"]:::ui
        Assets["assets/"]:::ui
        Config[".streamlit/config.toml"]:::ui
        Secrets[".streamlit/secrets.toml"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        subgraph Reports
            Alerts["alerts.py"]:::biz
            Bugs["bugs.py"]:::biz
            Dashboard["dashboard.py"]:::biz
        end
        subgraph Tools
            History["history.py"]:::biz
            Search["search.py"]:::biz
        end
    end

    %% Infrastructure / External Services
    subgraph "Infrastructure / External"
        Auth0["Auth0 (External Auth Service)"]:::ext
        SendEmail["send_email.py"]:::biz
        EmailProvider["SMTP Email Provider"]:::ext
    end

    %% User
    User["User"]:::user

    %% Connections
    User -->|"HTTP Request"| App
    App -->|"OAuth2 Redirect"| Auth0
    Auth0 -->|"Token Response"| App
    Config -->|"Streamlit Config"| App
    Secrets -->|"Auth0 Credentials"| App
    Secrets -->|"Auth0 Credentials"| Auth0
    App -->|"Function Call"| Alerts
    App -->|"Function Call"| Bugs
    App -->|"Function Call"| Dashboard
    App -->|"Function Call"| History
    App -->|"Function Call"| Search
    Alerts -->|"Function Call"| SendEmail
    SendEmail -->|"SMTP Email"| EmailProvider

    %% Click Events
    click App "https://github.com/valantoni/full-stack-python-template/blob/master/app.py"
    click Assets "https://github.com/valantoni/full-stack-python-template/tree/master/assets/"
    click Config "https://github.com/valantoni/full-stack-python-template/blob/master/.streamlit/config.toml"
    click Secrets "https://github.com/valantoni/full-stack-python-template/blob/master/.streamlit/secrets.toml"
    click Alerts "https://github.com/valantoni/full-stack-python-template/blob/master/reports/alerts.py"
    click Bugs "https://github.com/valantoni/full-stack-python-template/blob/master/reports/bugs.py"
    click Dashboard "https://github.com/valantoni/full-stack-python-template/blob/master/reports/dashboard.py"
    click History "https://github.com/valantoni/full-stack-python-template/blob/master/tools/history.py"
    click Search "https://github.com/valantoni/full-stack-python-template/blob/master/tools/search.py"
    click SendEmail "https://github.com/valantoni/full-stack-python-template/blob/master/send_email.py"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366d6,stroke-width:2px
    classDef biz fill:#DFFFD0,stroke:#006400,stroke-width:2px
    classDef ext fill:#FFE0B2,stroke:#d2691e,stroke-width:2px
    classDef user fill:#ffffff,stroke:#888,stroke-width:1px,stroke-dasharray: 5 5
```
