flow-pie/chamaa.api

Implement DAO-style voting system

Open

#91 创建于 2025年11月9日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)HTML (4 fork)auto 404
help wanted

仓库指标

Star
 (3 star)
PR 合并指标
 (PR 指标待抓取)

描述

Objective

Design and implement a DAO-style voting system for ChamaaChain so group members can create proposals (loan/investment/rule changes) and vote in a transparent, auditable way.

Description

This feature provides on-chain governance for chamas: members create proposals, cast votes, and the system tallies and finalizes outcomes according to group rules (quorum, majority, weighted votes if applicable). Voting records must be immutable and discoverable both on-chain and via the backend API.

Key Tasks

  • Design a Proposal domain model (type, proposer, description, start/end timestamps, quorum, required majority).
  • Add DB tables: proposals, proposal_votes, proposal_status_history.
  • Implement backend endpoints:
    • POST /api/proposals — create proposal
    • GET /api/proposals — list proposals (filter by group/status)
    • GET /api/proposals/:id — proposal details
    • POST /api/proposals/:id/vote — cast vote
    • GET /api/proposals/:id/results — current tally
  • Integrate with smart contract voting (if on-chain) or provide an off-chain canonicalization + on-chain anchor approach (hashing proposal payload and storing anchor on-chain).
  • Add role checks and membership validation (only group members can propose/vote).
  • Add automated jobs to finalize votes at proposal end time and trigger any on-chain action if required.

Acceptance Criteria

  • API endpoints implemented and documented (Swagger/OpenAPI)
  • Proposals and votes persist in DB and are retrievable
  • Vote casting enforces membership and one-vote-per-member rule
  • Finalization logic respects quorum/majority rules
  • If configured to be on-chain, proposal anchor (hash) is stored on-chain and transaction hash recorded
  • Unit and integration tests for proposal lifecycle

Tech Notes / Suggestions

  • Backend: Node.js + NestJS/Express (use middleware for auth & RBAC)
  • DB: PostgreSQL (add proposals + proposal_votes tables)
  • Blockchain: anchor proposals on-chain with a hash + store tx hash in DB (Ethers.js)
  • Add background worker (Bull / Agenda) to finalize proposals at end time

Labels

feature, governance, backend, blockchain

贡献者指南