# blackary/st_pages architecture

> Architecture diagram of the GitHub repository blackary/st_pages, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/blackary/st_pages
- Repository: https://github.com/blackary/st_pages

## Overview

##### Main Components

a) Core Package Components:
- Main Package Module (st_pages)
- Configuration Handler (TOML Parser)
- Page Management System
- Navigation Interface

b) Integration Components:
- Streamlit Framework Integration
- File System Interface
- Configuration Files (.streamlit directory)

**┌─ Application Layer ─────────────────────┐**

- User's Streamlit Application       │

- ┤

- st-pages Package Layer          │
- ┌──────────────┐    ┌──────────────┐│
- Page Manager │←───│ TOML Config  ││
- ┘    │   Parser     ││
- ┌──────────────┐    └──────────────┘│
- Navigation  │                    │
- Controller  │    ┌──────────────┐│
- ┘    │ Page Title   ││
- Handler      ││
- ┘│
- ┤

- Streamlit Framework            │

- ┘

##### Key Elements to Highlight

a) Data Flow:
- How page information is passed to Streamlit's navigation
- How hide_pages functionality affects the navigation

b) Configuration Components:
- .streamlit directory and its TOML files
- Relationship between configuration and page rendering

##### Important Details

a) Integration Points:
- How st-pages interfaces with Streamlit's native navigation
- Where custom page configurations are injected

b) Configuration Flow:
- Demonstrate how TOML files are processed

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Application
        UserApp["User's Streamlit Application"]:::app
        ExampleApp["Example Application"]:::app
        click ExampleApp "https://github.com/blackary/st_pages/blob/main/example_app/streamlit_app.py"
        ExPages["Example Pages"]:::pages
        click ExPages "https://github.com/blackary/st_pages/tree/main/example_app"
    end

    subgraph StPagesPackage["st-pages Package Layer"]
        MainModule["Main Package Module"]:::core
        click MainModule "https://github.com/blackary/st_pages/blob/main/src/st_pages/__init__.py"
        PageManager["Page Manager"]:::core
        NavController["Navigation Controller"]:::core
        TitleHandler["Page Title Handler"]:::core
        IconHandler["Icon Handler"]:::core
        click IconHandler "https://github.com/blackary/st_pages/blob/main/src/st_pages/emoji.json"
    end

    subgraph Configuration
        TOMLParser["TOML Config Parser"]:::config
        ConfigFiles["Configuration Files"]:::config
        click ConfigFiles "https://github.com/blackary/st_pages/blob/main/.streamlit"
        ExampleConfig["Example Configs"]:::config
        click ExampleConfig "https://github.com/blackary/st_pages/blob/main/example_app/.streamlit"
    end

    subgraph Testing
        IntegrationTests["Integration Tests"]:::test
        click IntegrationTests "https://github.com/blackary/st_pages/blob/main/tests/test_frontend.py"
        PageTests["Page Management Tests"]:::test
        click PageTests "https://github.com/blackary/st_pages/blob/main/tests/test_streamlit_pages.py"
        NavTests["Navigation Tests"]:::test
        click NavTests "https://github.com/blackary/st_pages/blob/main/tests/test_edits.py"
    end

    subgraph StreamlitFramework["Streamlit Framework"]
        StreamlitNav["Native Navigation"]:::streamlit
        StreamlitPages["Pages System"]:::streamlit
    end

    %% Relationships
    UserApp --> MainModule
    ExampleApp --> MainModule
    ExampleApp --> ExPages
    MainModule --> PageManager
    MainModule --> NavController
    MainModule --> TitleHandler
    PageManager --> TOMLParser
    NavController --> IconHandler
    TOMLParser --> ConfigFiles
    TOMLParser --> ExampleConfig
    PageManager --> StreamlitNav
    NavController --> StreamlitPages
    
    %% Testing Relationships
    IntegrationTests -.-> MainModule
    PageTests -.-> PageManager
    NavTests -.-> NavController

    %% Styling
    classDef core fill:#2374ab,stroke:#000,stroke-width:1px,color:#fff
    classDef config fill:#57a773,stroke:#000,stroke-width:1px,color:#fff
    classDef streamlit fill:#ff8c42,stroke:#000,stroke-width:1px,color:#fff
    classDef test fill:#708090,stroke:#000,stroke-width:1px,color:#fff
    classDef app fill:#484d6d,stroke:#000,stroke-width:1px,color:#fff
    classDef pages fill:#484d6d,stroke:#000,stroke-width:1px,color:#fff
```
