flow-pie/chamaa.api

Implement DAO-style voting system

Open

#91 aperta il 9 nov 2025

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)HTML (4 fork)auto 404
help wanted

Metriche repository

Star
 (3 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

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

Guida contributor