Skip to content

Conversation

Copy link

Copilot AI commented Dec 7, 2025

Implements rule-based AI system for automatic bill categorization, monthly expense forecasting, financial health analysis, and spending pattern detection.

Core Features

Bill Classification (POST /api/v1/ai/classify)

  • Auto-categorizes bills via keyword matching (Chinese/English) + amount heuristics
  • 10+ expense categories, 4+ income categories
  • Returns confidence-scored suggestions

Expense Prediction (GET /api/v1/ai/predict)

  • 6-month rolling window statistical forecasting
  • Per-category breakdown with trend analysis
  • 24h result caching

Financial Analysis (POST /api/v1/ai/analyze)

  • Savings rate, spending trends, top categories
  • Personalized insights based on thresholds (e.g., overspending warnings)

Pattern Detection (GET /api/v1/ai/patterns)

  • Identifies regular vs irregular expenses by frequency analysis

Implementation

domain/ai_analysis.go              # Interfaces & models
repository/ai_analysis_repository.go  # MongoDB aggregations
usecase/ai_analysis_usecase.go     # Rule engine + statistical algorithms
controller/ai_analysis_controller.go  # HTTP handlers

Key Algorithm: Classification uses weighted keyword matching + amount ranges. Prediction applies trend multiplier to historical averages. All processing local, no external dependencies.

Example Usage:

# Classify bill
curl -X POST /api/v1/ai/classify -d '{"description":"肯德基午餐","amount":45.5}'
# Returns: {"suggestions":[{"category":"餐饮","confidence":0.85}],"type":0}

# Get predictions
curl "/api/v1/ai/predict?book_id=XXX&period=2024-02"

Testing

  • 12 unit tests covering classification accuracy, trend detection, edge cases (zero division, empty data)
  • CodeQL: 0 vulnerabilities

Documentation

  • AI_IMPLEMENTATION_SUMMARY.md - Technical overview
  • RECOMMENDATIONS.md - Usage guide addressing original requirement
  • server/docs/AI_ANALYSIS_API.md - API reference
  • server/docs/AI_FEATURES_CN.md - 中文说明
  • server/docs/ANDROID_INTEGRATION.md - Client integration examples

Design Note: Rule-based approach provides immediate value without training data. Architecture supports future ML model drop-in replacement via interface abstraction.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 192.168.8.6
    • Triggering command: /tmp/go-build3311262496/b472/pkg.test /tmp/go-build3311262496/b472/pkg.test -test.testlogfile=/tmp/go-build3311262496/b472/testlog.txt -test.paniconexit0 -test.timeout=10m0s -dumpdir /tmp/go-build3311262496/b441/ -dumpbase _x001.c -dumpbase-ext .c -m64 -mtune=generic (packet block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

基于当前项目,添加AI 分析分类账单和预测。
基于支付宝,微信,银行账单和现金归账。规划个人财务。你有什么建议


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 6 commits December 7, 2025 17:41
Co-authored-by: ahaodev <10151414+ahaodev@users.noreply.github.com>
…d financial insights

Co-authored-by: ahaodev <10151414+ahaodev@users.noreply.github.com>
Co-authored-by: ahaodev <10151414+ahaodev@users.noreply.github.com>
…e case tests

Co-authored-by: ahaodev <10151414+ahaodev@users.noreply.github.com>
…re sessions

Co-authored-by: ahaodev <10151414+ahaodev@users.noreply.github.com>
Co-authored-by: ahaodev <10151414+ahaodev@users.noreply.github.com>
Copilot AI changed the title [WIP] Add AI analysis for bill categorization and forecasting Add AI-powered bill classification, expense prediction, and financial analysis Dec 7, 2025
Copilot AI requested a review from ahaodev December 7, 2025 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants