Skip to content

Add comprehensive examples and integration guide for third-party SDK consumers #30

Description

@Just-Bamford

Summary

The @anonvote/crypto package is feature-complete but has no guide
for third-party developers on how to integrate it or build on top of
AnonVote. The README has API reference but no examples showing real
workflows (create ballot, generate tokens, encrypt votes, verify
results). Without this, a new developer downloading the package has
no clear path to using it productively. Comprehensive examples and an
integration guide unlock the Milestone 3 ecosystem goal.

Background

The js/README.md has a Usage section with a small code snippet but
no end-to-end example. There is no guide on how to:

  • Generate a ballot encryption key
  • Create tokens for voters
  • Encrypt and decrypt votes
  • Verify results on-chain
  • Handle errors

Scope

Documentation

  • Create js/INTEGRATION_GUIDE.md with:

    • Step-by-step walkthrough of a complete ballot lifecycle (create
      ballot → generate key → issue tokens → encrypt votes → tally)
    • Code examples for each step using the SDK
    • Error handling examples (catching AnonVoteCryptoError)
    • Common pitfalls and how to avoid them (e.g., key storage, token
      security)
    • FAQ section covering: key rotation, token reuse, encryption
      performance, type safety
  • Create js/examples/ directory with working code samples:

    • examples/basic-ballot.ts — create a ballot and encrypt a vote
    • examples/token-generation.ts — generate and hash tokens
    • examples/error-handling.ts — catch and handle errors
    • examples/type-usage.ts — using exported types
  • Add a "Getting Started" section to js/README.md that links to the
    integration guide and examples

  • Add TypeDoc comments to all exported functions showing example usage

Tests

  • Verify all code examples in examples/ directory compile and run
  • Add a test that runs all examples to ensure they don't break on
    future changes

Relevant Files

  • js/INTEGRATION_GUIDE.md (new)
  • js/examples/ (new directory with samples)
  • js/README.md (add Getting Started)
  • js/src/crypto.ts (add TypeDoc examples)
  • js/tests/examples.test.ts (new, runs examples)

Acceptance Criteria

  • INTEGRATION_GUIDE.md created with lifecycle walkthrough
  • At least 4 working code examples in examples/ directory
  • All examples compile without errors
  • All TypeDoc comments include usage examples
  • README updated with "Getting Started" section
  • Integration guide covers error handling and common pitfalls
  • Tests verify examples work and don't break on changes

Out of Scope

  • Video tutorials — written guides only
  • Framework-specific examples (React, Vue, etc.) — framework-agnostic only

Note for Contributors

This is your chance to show developers how to use AnonVote. Make
examples realistic and production-grade. A developer reading this
guide should feel confident building an integration. Include error
handling, not just happy paths.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26documentationImprovements or additions to documentationenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions