# hanshans135/shin-her architecture

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

- Interactive diagram: https://gitdiagram.com/hanshans135/shin-her
- Repository: https://github.com/hanshans135/shin-her

## Overview

##### Project type and purpose
- This is a small full-stack web application built with Python/Flask on the backend and server-rendered HTML (Jinja2) with Tailwind CSS/JavaScript on the frontend.
- Purpose: Improve usability of the “欣河” (Xinhe) academic system by scraping data (via BeautifulSoup) and re-presenting it through a cleaner UI. It also automates login via an external captcha-solving service (CapMonster).

##### File structure
- Top-level files:
- app.py – Flask application entrypoint, defines routes/controllers
- get_fun.py – scraping functions (data retrieval from the original Xinhe system)
- login_fun.py – login automation (handles session & captcha)
- config.example.json / config.json – configuration for external URLs, API keys, secrets, ports
- data.json – local JSON “database” to cache or persist scraped data
- requirements.txt – Python dependencies
- templates/ – Jinja2 templates for each page (index, login, scores, attendance, curriculum, etc.)
- No separate “static” folder is shown, but Tailwind CSS & JS likely injected via CDN or inline.

##### README for additional insights
- Backend stack: Python + Flask + Jinja2 + BeautifulSoup
- Frontend: HTML + Tailwind + JS
- External dependencies: original Xinhe URL (“base_url”), CapMonster captcha API

##### Detailed capture of essential elements
- Route definitions (app.py)
- Auth sub-module (login_fun)
- Scraper sub-module (get_fun)
- Configuration loader
- File store
- How data flows from initial user request through authentication, scraping, persistence, templating, and final render.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend
    Browser["User Browser"]:::frontend

    %% Backend Container
    subgraph "Backend (Flask App)"
        App["Flask (app.py)"]:::backend
        Auth["Authentication Module\n(login_fun.py)"]:::module
        Scraper["Data-Scraping Module\n(get_fun.py)"]:::module
        Config["Configuration Loader\n(config.json)"]:::config
        DataStore["Data Store\n(data.json)"]:::db
        subgraph "View Templates (Jinja2)"
            idx["index.html"]:::template
            login["login.html"]:::template
            allscore["all_score.html"]:::template
            score["score.html"]:::template
            attend["attend.html"]:::template
            curriculum["curriculum.html"]:::template
        end
    end

    %% External Services
    Xinhe["Xinhe Academic System"]:::external
    Cap["CapMonster Captcha API"]:::external

    %% Dependencies & Docs
    requirements["requirements.txt"]:::config
    readme["README.md"]:::config
    license["LICENSE"]:::config
    gitignore[".gitignore"]:::config

    %% Flows
    Browser -->|HTTP GET/POST| App
    App -->|loads config| Config
    App -->|calls auth| Auth
    Auth -->|requests captcha solving| Cap
    Auth -->|login POST| Xinhe
    App -->|calls scraping| Scraper
    Scraper -->|HTTP GET/POST| Xinhe
    Scraper -->|returns parsed data| App
    App -->|read/write| DataStore
    App -->|renders view| idx
    App -->|renders view| login
    App -->|renders view| allscore
    App -->|renders view| score
    App -->|renders view| attend
    App -->|renders view| curriculum
    App -->|HTML response| Browser

    %% Click Events
    click App "https://github.com/hanshans135/shin-her/blob/main/app.py"
    click Auth "https://github.com/hanshans135/shin-her/blob/main/login_fun.py"
    click Scraper "https://github.com/hanshans135/shin-her/blob/main/get_fun.py"
    click Config "https://github.com/hanshans135/shin-her/blob/main/config.json"
    click DataStore "https://github.com/hanshans135/shin-her/blob/main/data.json"
    click idx "https://github.com/hanshans135/shin-her/blob/main/templates/index.html"
    click login "https://github.com/hanshans135/shin-her/blob/main/templates/login.html"
    click allscore "https://github.com/hanshans135/shin-her/blob/main/templates/all_score.html"
    click score "https://github.com/hanshans135/shin-her/blob/main/templates/score.html"
    click attend "https://github.com/hanshans135/shin-her/blob/main/templates/attend.html"
    click curriculum "https://github.com/hanshans135/shin-her/blob/main/templates/curriculum.html"
    click requirements "https://github.com/hanshans135/shin-her/blob/main/requirements.txt"
    click readme "https://github.com/hanshans135/shin-her/blob/main/README.md"
    click license "https://github.com/hanshans135/shin-her/tree/main/LICENSE"
    click gitignore "https://github.com/hanshans135/shin-her/blob/main/.gitignore"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef backend fill:#DFFFE0,stroke:#333,stroke-width:1px
    classDef module fill:#FFF8C6,stroke:#333,stroke-width:1px
    classDef config fill:#FFE0B2,stroke:#333,stroke-width:1px
    classDef db fill:#FFD6E7,stroke:#333,stroke-width:1px
    classDef template fill:#E8E8FF,stroke:#333,stroke-width:1px
    classDef external fill:#EEEEEE,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
