Busabase
Busabase 是一款開源 (MIT) 資料庫與 AI agent 工作空間——將數據、文件、技能與應用程式整合於一處。您可以選擇本地運行、在網路內部進行自我託管,或使用 Busabase Cloud。
AI 翻譯
尚未偵測到更新。GitHub 發布版本後會顯示在這裡。
製作者的介紹僅有上面的一句話。 更多詳情請閱讀儲存庫 README。 儲存庫 README ↗
正在載入完整 README。
檢視完整 README ↗models.py — SQLAlchemy data model (MPs, FY ledgers, works, societies, inspections)rules_engine.py — the compliance rules engine (10 rules covering financial,
geospatial, negative-list, society, and SLA checks from the guidelines)example_check.py — standalone runnable demo (no server needed)api.py — FastAPI wrapper exposing POST /check-compliancerequirements.txtpip install -r requirements.txt
# Option A: run the standalone demo
python example_check.py
# Option B: run the API
uvicorn api:app --reload
# then POST to http://localhost:8000/check-compliance
# see `example_payload` at the bottom of api.py for the request shape
# interactive docs auto-generated at http://localhost:8000/docs
Start with the API as a microservice. Don't try to merge this logic
into your main app's codebase directly. Run it as a separate FastAPI
service. Your main app (whatever manages work recommendations) calls
POST /check-compliance whenever a work is created or edited, and
gets back APPROVED / NEEDS_REVIEW / BLOCKED plus the per-rule
breakdown. This keeps the compliance logic swappable and testable
independent of your UI/main app.
Persist real ledgers, not in-memory ones. api.py currently takes
a ledger snapshot in the request body so you can test without a DB.
For real use: point it at a real Postgres/SQLite DB using models.py,
look up the MP's actual FinancialYearLedger row by mp_id +
financial_year, and update it transactionally the moment a work is
sanctioned (increment cumulative_sanctioned, repair_renovation_sanctioned,
etc. — see the models.py docstring on why this ledger must hold running
totals rather than being recomputed from scratch each time).
Add rules incrementally, don't try to cover every para on day one.
Start with the ~10 rules already implemented (they cover the highest-
frequency checks: entitlement ceiling, minimum work amount, repair
ceiling, out-of-constituency cap, jurisdiction, negative list, society
eligibility, and two SLA timers). Add SC/ST hard quota enforcement,
calamity relief timelines, and admin expenditure caps next — each is
a new Rule subclass in rules_engine.py, nothing else needs to change.
Never auto-reject on the negative-list rule alone. It's marked
REVIEW severity on purpose. Route anything it flags to a human
reviewer queue in your UI. If you want to reduce false positives,
replace NegativeListRule._keyword_hits with a call to an LLM
classifier that reasons about the actual work description instead
of raw keyword matching — the rest of the engine doesn't need to change.
Log every check. Use the ComplianceCheckLog table in models.py
to persist every RuleResult against the work — this becomes your
audit trail when the CAG/State auditors ask "how was this work checked."
context dict (MP type, allowed districts, calamity flag,
any linked society, written justification if under ₹2.5L)ComplianceEngine().evaluate(work, ledger, context)report.overall_status:
APPROVED → proceed to sanction, update the ledgerNEEDS_REVIEW → hold, route to human reviewer with the flagged rulesBLOCKED → reject automatically, return the failing rule messages
to whoever submitted the recommendation