# betastreetomnis/xhs_ai_publisher architecture

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

- Interactive diagram: https://gitdiagram.com/betastreetomnis/xhs_ai_publisher
- Repository: https://github.com/betastreetomnis/xhs_ai_publisher

## Overview

##### Main Components Identification

a) Frontend Layer (easy_ui.py)
- This as a UI component using a rectangle with rounded corners
- Subcomponents for:
- Login Interface
- Content Generation Interface
- Image Preview
- Article Preview

b) API Server Layer (api_server.py)
- As a hexagonal service component
- This serves as the middleware between the UI and the automation layer

c) Automation Layer (write_xiaohongshu.py)
- As a service component
- Integration points with external systems

##### External Systems Integration
Connections to external services:
- Xiaohongshu Platform
- Large Language Model API (for content generation)
- Image Generation/Storage Service

##### Data Flow Representation
- User input → Frontend → API Server
- API Server → Large Language Model
- API Server → Image Service
- Automation Layer → Xiaohongshu Platform

##### Component Details

**┌─────────────────┐**
- Frontend     │
- (easy_ui.py)  │
- ┬────────┘
- ↓
**┌─────────────────┐**
- API Server    │
- (api_server.py) │
- ┬────────┘
- ↓
**┌─────────────────┐    ┌─────────────┐**
- Automation    │ → │  Xiaohongshu │
- Layer        │    │   Platform   │
- ┘    └─────────────┘

##### Additional Elements

a) Data Storage:
- Cookie storage for login sessions
- Temporary image storage

b) External APIs:
- Large Language Model connection
- Image generation service
- Xiaohongshu API endpoints

##### Process Flows
Numbered sequence indicators for key processes:

##### Technical Details to Note
Annotations for:
- Python 3.12 runtime
- Selenium WebDriver integration
- Tkinter UI framework
- Browser automation components

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        UI[Frontend Interface]:::ui
        Login[Login Interface]:::ui
        Content[Content Generation]:::ui
        Preview[Preview System]:::ui
        
        UI --> Login
        UI --> Content
        UI --> Preview
    end
    
    subgraph APIServer
        API[API Server]:::api
        LLM[Language Model Integration]:::api
        IMG[Image Service]:::api
        
        API --> LLM
        API --> IMG
    end
    
    subgraph Automation
        Auto[Automation System]:::automation
        Selenium[Selenium WebDriver]:::automation
        Publisher[Content Publisher]:::automation
        
        Auto --> Selenium
        Auto --> Publisher
    end
    
    subgraph External
        XHS[Xiaohongshu Platform]:::external
        LLMService[LLM API Service]:::external
        ImageService[Image Generation Service]:::external
    end
    
    Frontend --> APIServer
    APIServer --> Automation
    Automation --> XHS
    APIServer --> LLMService
    APIServer --> ImageService
    
    %% Component Mappings
    click UI "https://github.com/BetaStreetOmnis/xhs_ai_publisher/blob/main/easy_ui.py"
    click API "https://github.com/BetaStreetOmnis/xhs_ai_publisher/blob/main/api_server.py"
    click Auto "https://github.com/BetaStreetOmnis/xhs_ai_publisher/blob/main/write_xiaohongshu.py"
    
    %% Styling
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef automation fill:#9b59b6,stroke:#8e44ad,color:white
    classDef external fill:#e67e22,stroke:#d35400,color:white
    
    %% Legend
    subgraph Legend
        L1[Frontend Components]:::ui
        L2[API Components]:::api
        L3[Automation Components]:::automation
        L4[External Services]:::external
    end
```
