Skip to content

ClawFighter/ChinaMonitor

Repository files navigation

China Monitor

Real-time China-focused intelligence dashboard β€” aggregating news, weather forecasts, and stock market data in a unified interface.

China Monitor Dashboard

🌟 Features

  • Live News Aggregation - Curated China-related news from Google News + SCMP (6 items per batch, rotates every 30s)
  • Weather Forecasts - 3-day forecasts for 34 Chinese provinces (9 cities per batch, rotates every 30s)
  • Real-time Stock Prices - A-Shares, H-Shares, and T-Shares via TradingView widgets
  • Cross Rates - G7 & BRICS currency exchange rates (CNY, HKD, TWD, USD focus)
  • Beijing Time Display - Current time in China (UTC+8)
  • Dark/Light Theme - Auto-switch based on local time (7:00-19:00) or manual toggle
  • Responsive Design - Desktop-optimized with mobile warnings

πŸ–₯️ Live Demo

Visit chinamonitor.app

πŸ› οΈ Tech Stack

Frontend

  • Framework: Vanilla TypeScript + Vite
  • Fonts: DSEG7/DSEG14/DSEG Weather (digital tube style)
  • Icons: Font Awesome 6.5.0
  • Build Tool: Vite 6.4.1

Backend APIs

  • Runtime: Node.js
  • News API: Express + RSS Parser (Port 3100)
  • Weather API: Express + better-sqlite3 (Port 3101)
  • Database: SQLite

Data Sources

  • News: Google News + SCMP (South China Morning Post)
  • Weather: wttr.in + NMC (National Meteorological Center of China)
  • Stocks & Forex: TradingView Widgets
  • Live Video: YouTube Embedded Player

πŸ“ Project Structure

china-monitor/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.ts                 # Main entry point
β”‚   β”œβ”€β”€ styles.css              # Global styles
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ client.ts           # API client
β”‚   β”‚   └── health-check.ts     # Health check
β”‚   β”œβ”€β”€ ui/
β”‚   β”‚   β”œβ”€β”€ clock.ts            # Clock display
β”‚   β”‚   β”œβ”€β”€ theme.ts            # Theme switching
β”‚   β”‚   β”œβ”€β”€ live-news.ts        # News list
β”‚   β”‚   β”œβ”€β”€ weather-forecast.ts # Weather forecast (batch rotation)
β”‚   β”‚   β”œβ”€β”€ header-weather.ts   # Header weather (IP-based)
β”‚   β”‚   β”œβ”€β”€ stock-ticker.ts     # Stock ticker
β”‚   β”‚   β”œβ”€β”€ cross-rates.ts      # Forex cross rates
β”‚   β”‚   β”œβ”€β”€ youtube-player.ts   # YouTube player
β”‚   β”‚   β”œβ”€β”€ footer.ts           # Footer
β”‚   β”‚   β”œβ”€β”€ view-counter.ts     # View counter
β”‚   β”‚   └── mobile-warning.ts   # Mobile warning
β”‚   └── utils/
β”‚       └── images.ts           # Image utilities
β”œβ”€β”€ news-api/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ server.js           # News API server
β”‚   β”‚   └── cache.js            # RSS cache
β”‚   └── hourly-fetch.sh         # Hourly fetch cron
β”œβ”€β”€ weather-nmc/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ api-server.js       # Weather API server
β”‚   β”‚   └── fetcher.js          # Weather fetcher
β”‚   └── fetch-weather.sh        # Weather fetch cron
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ index.html              # Main page
β”‚   β”œβ”€β”€ about.html              # About page
β”‚   β”œβ”€β”€ maintenance.html        # Maintenance page
β”‚   β”œβ”€β”€ robots.txt              # SEO robots
β”‚   β”œβ”€β”€ sitemap.xml             # SEO sitemap
β”‚   └── fonts/                  # DSEG fonts
β”œβ”€β”€ dist/                       # Build output
β”œβ”€β”€ db/                         # SQLite database
β”œβ”€β”€ start.sh                    # Start services
β”œβ”€β”€ stop.sh                     # Stop services
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
└── vite.config.ts

πŸš€ Getting Started

Prerequisites

  • Node.js 18+
  • npm or yarn

Installation

# Clone the repository
git clone https://github.com/ClawFighter/ChinaMonitor.git
cd china-monitor

# Install dependencies
npm install

# Download DSEG fonts (required for digital display)
bash download-fonts.sh

Development

# Start development server (Vite)
npm run dev

# In separate terminals, start backend APIs:
cd news-api && node src/server.js
cd ../weather-nmc && node src/api-server.js

Open http://localhost:7890

Production Build

# Build for production
npm run build

# Serve production build
npm run preview

Service Management

# Start all services (production)
bash start.sh

# Stop all services
bash stop.sh

βš™οΈ Configuration

Cron Jobs

# News: Fetch every hour
0 * * * * /path/to/china-monitor/news-api/hourly-fetch.sh

# Weather: Fetch every 6 hours (0:00, 6:00, 12:00, 18:00)
0 */6 * * * /path/to/china-monitor/weather-nmc/fetch-weather.sh

Theme Switching

  • Auto: 7:00-19:00 local time β†’ Light theme, otherwise Dark theme
  • Manual: Click theme toggle button in header

Weather Batch Rotation

Weather forecasts rotate every 30 seconds (9 cities per batch):

  • Batch 1: Cities 1-9
  • Batch 2: Cities 10-18
  • Batch 3: Cities 19-27
  • Batch 4: Cities 28-34
  • Then loops back to Batch 1

πŸ“Š API Endpoints

News API (Port 3100)

GET /api/news?limit=50
GET /api/news/category/:category
GET /api/news/region/:region
GET /health

Weather API (Port 3101)

GET /api/weather?limit=100
GET /health

🎨 Typography

This project uses DSEG Fonts by keshikan.net:

  • DSEG7: Numeric displays (clock, temperature)
  • DSEG14: Titles and headers
  • DSEG Weather: Weather icons (numeric codes 1-9)

Download from: https://www.keshikan.net/fonts-e.html

πŸ“„ License

AGPL-3.0 β€” see LICENSE for details.

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ™ Acknowledgments

πŸ“§ Contact

For questions or feedback: bizcwen@gmail.com


Built with ❀️ for real-time China monitoring

About

Real-time China-focused intelligence dashboard

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors