# clarencechl/ai-four-pillars-of-destiny-assistant architecture

> Architecture diagram of the GitHub repository clarencechl/ai-four-pillars-of-destiny-assistant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/clarencechl/ai-four-pillars-of-destiny-assistant
- Repository: https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant

## Overview

##### Project type and purpose
- This is a WeChat Mini-Program (“八字分析助手小程序”) that runs entirely on the client (微信小程序原生开发).
- Purpose: collect user birth information, compute a Bazi (“八字”) chart locally, then send it to an external AI service (DeepSeek API) for analysis and personalized recommendations.

##### File structure
- Top-level:
- miniprogram/ – all front-end code
– pages/ (index, input, analysis, chat)
– utils/ (bazi.js, api.js)
– app.js, app.json, app.wxss
- project.config.json / project.private.config.json – WeChat IDE config
- README.md, LICENSE
- No server-side code; backend is an external API (DeepSeek).
- The utils folder encapsulates all business logic: Bazi calculation and API calls.

##### README for additional insights
- Confirms use of:
- WXML + WXSS + JavaScript (WeChat native)
- DeepSeek API invoked via utils/api.js
- Bazi calculation in utils/bazi.js
- Features: conversational chat page, real-time analysis, no persistent storage.

- Pages (Index/Input/Analysis/Chat)
- Utils (Bazi Calculator, API Client)
- User → Pages (input flows)
- Pages → Bazi Calculator → API Client → External API → back
- UI components (e.g., light blue)
- Business logic modules (e.g., light green)
- External services (e.g., gray)
- Rectangles for modules/pages

##### Final recommendations
- Configuration files at the edge (app.json) if relevant
- Essential parts—don’t worry about micro-details; focus on the logical flow from user input to AI output.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Container
    CONTAINER["WeChat Mini-Program Container"]:::external

    %% Pages
    subgraph "Pages"
        INDEX["Index Page\n(index.js + WXML + WXSS)"]:::ui
        INPUT["Input Page\n(input.js + WXML + WXSS + JSON)"]:::ui
        ANALYSIS["Analysis Page\n(analysis.js + WXML + WXSS)"]:::ui
        CHAT["Chat Page\n(chat.js + WXML + WXSS)"]:::ui
    end

    %% Utils
    subgraph "Utils"
        BAZI["Bazi Calculator\nutils/bazi.js"]:::logic
        API["DeepSeek API Wrapper\nutils/api.js"]:::logic
        LUNAR["Lunar Calendar Utility\nutils/lunar.js"]:::logic
    end

    %% App Configuration
    subgraph "App Config"
        APPJS["app.js"]:::logic
        APPJSON["app.json"]:::logic
    end

    %% External Service
    DEEP["DeepSeek AI Analysis Service\n(REST API)"]:::external

    %% User
    USER["User (WeChat Client)"]:::external

    %% Connections
    USER -->|"opens Mini-Program"| CONTAINER
    CONTAINER --> INDEX
    INDEX -->|"navigate to"| INPUT
    INPUT -->|"compute BaZi chart"| BAZI
    BAZI -->|"package Bazi JSON"| API
    API -->|"POST Bazi JSON"| DEEP
    DEEP -->|"returns analysis result"| API
    API -->|"send analysis data"| ANALYSIS
    ANALYSIS -->|"user chats"| CHAT

    %% Initialization Flows
    APPJS --> INDEX
    APPJS --> INPUT
    APPJS --> ANALYSIS
    APPJS --> CHAT
    APPJSON --> APPJS

    %% Click Events
    click CONTAINER "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/tree/main/AI Bazi Astrology Analysis/miniprogram/"
    click INDEX "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/blob/main/AI Bazi Astrology Analysis/miniprogram/pages/index/index.js"
    click INDEX "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/blob/main/AI Bazi Astrology Analysis/miniprogram/pages/index/index.wxml"
    click INDEX "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/blob/main/AI Bazi Astrology Analysis/miniprogram/pages/index/index.wxss"
    click INPUT "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/blob/main/AI Bazi Astrology Analysis/miniprogram/pages/input/input.js"
    click INPUT "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/blob/main/AI Bazi Astrology Analysis/miniprogram/pages/input/input.wxml"
    click INPUT "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/blob/main/AI Bazi Astrology Analysis/miniprogram/pages/input/input.wxss"
    click INPUT "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/blob/main/AI Bazi Astrology Analysis/miniprogram/pages/input/input.json"
    click ANALYSIS "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/blob/main/AI Bazi Astrology Analysis/miniprogram/pages/analysis/analysis.js"
    click ANALYSIS "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/blob/main/AI Bazi Astrology Analysis/miniprogram/pages/analysis/analysis.wxml"
    click ANALYSIS "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/blob/main/AI Bazi Astrology Analysis/miniprogram/pages/analysis/analysis.wxss"
    click CHAT "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/blob/main/AI Bazi Astrology Analysis/miniprogram/pages/chat/chat.js"
    click CHAT "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/blob/main/AI Bazi Astrology Analysis/miniprogram/pages/chat/chat.wxml"
    click CHAT "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/blob/main/AI Bazi Astrology Analysis/miniprogram/pages/chat/chat.wxss"
    click BAZI "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/blob/main/AI Bazi Astrology Analysis/miniprogram/utils/bazi.js"
    click API "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/blob/main/AI Bazi Astrology Analysis/miniprogram/utils/api.js"
    click LUNAR "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/blob/main/AI Bazi Astrology Analysis/miniprogram/utils/lunar.js"
    click APPJS "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/blob/main/AI Bazi Astrology Analysis/miniprogram/app.js"
    click APPJSON "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/blob/main/AI Bazi Astrology Analysis/miniprogram/app.json"
    click projectConfig "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/blob/main/AI Bazi Astrology Analysis/project.config.json"
    click projectPrivate "https://github.com/clarencechl/ai-four-pillars-of-destiny-assistant/blob/main/AI Bazi Astrology Analysis/project.private.config.json"

    %% Styles
    classDef ui fill:#E0F7FA,stroke:#0288D1,stroke-width:1px;
    classDef logic fill:#E8F5E9,stroke:#388E3C,stroke-width:1px;
    classDef external fill:#E0E0E0,stroke:#616161,stroke-width:1px;
```
