caixin-feed

command module
v0.0.0-...-4245e31 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2025 License: MIT Imports: 14 Imported by: 0

README

Caixin Feed

A Go-based RSS/JSON feed service that fetches articles from Caixin (财新) and provides them as a JSON feed. The service uses background fetching with SQLite storage for optimal performance and reliability.

Features

  • Background Fetching: Articles are fetched from Caixin API every 15 minutes in the background
  • Database Storage: SQLite database for persistent article storage
  • Fast API: Sub-second response times with cached articles
  • Reliability: Service continues to work even if Caixin API is temporarily down
  • Docker Support: Easy deployment with Docker and Docker Compose
  • JSON Feed: Modern JSON feed format for better compatibility

Live Feed

Visit the live feed at: https://leafduo.com/caixin-feed/feed.json

Quick Start

git clone https://github.com/leafduo/caixin-feed.git
cd caixin-feed
docker-compose up -d

The service will be available at http://localhost:1323/feed.json

Manual Setup
  1. Prerequisites

    • Go 1.24+
    • SQLite3
  2. Installation

    git clone https://github.com/leafduo/caixin-feed.git
    cd caixin-feed
    go mod download
    go build -o caixin-feed main.go
    
  3. Run

    ./caixin-feed
    

Configuration

The service can be configured by modifying constants in main.go:

  • FetchInterval: How often to fetch new articles (default: 15 minutes)
  • MaxArticles: Maximum number of articles to return (default: 100)

API Documentation

Endpoints
GET /feed.json

Returns a JSON feed containing the latest articles from Caixin.

Response Format:

{
  "version": "https://jsonfeed.org/version/1.1",
  "title": "财新首页文章",
  "description": "财新首页文章",
  "home_page_url": "https://leafduo.com/caixin-feed/feed.json",
  "feed_url": "https://leafduo.com/caixin-feed/feed.json",
  "author": {
    "name": "leafduo",
    "email": "leafduo@gmail.com"
  },
  "items": [
    {
      "id": "article_id",
      "title": "Article Title",
      "content_html": "<p>Article summary</p><img src=\"image_url\">",
      "url": "https://article-url",
      "date_published": "2024-01-01T00:00:00Z"
    }
  ]
}

Architecture

The application uses a background fetching pattern with database storage:

  1. Background Fetcher: Runs every 15 minutes to fetch new articles from Caixin API
  2. Database Storage: SQLite database stores articles with metadata
  3. API Endpoint: Serves cached articles from database for fast responses
Database Schema
CREATE TABLE articles (
    id TEXT PRIMARY KEY,
    title TEXT NOT NULL,
    summary TEXT,
    picture_url TEXT,
    published_at DATETIME,
    url TEXT,
    last_seen_at DATETIME,
    last_seen_index INTEGER
);

Deployment

Docker

The application includes a Dockerfile for containerized deployment:

docker build -t caixin-feed .
docker run -p 1323:1323 caixin-feed
Docker Compose

Use the included docker-compose.yml for easy deployment:

docker-compose up -d
GitHub Actions

The repository includes GitHub Actions workflow for automated Docker image building and publishing to GitHub Container Registry.

Development

Project Structure
caixin-feed/
├── main.go              # Main application code
├── go.mod              # Go module dependencies
├── Dockerfile          # Docker configuration
├── docker-compose.yml  # Docker Compose configuration
├── ARCHITECTURE.md     # Detailed architecture documentation
└── .github/workflows/  # GitHub Actions workflows
Dependencies

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

Author

Created by leafduo

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL