Skip to content
/ vote Public

Demo application that implements Ranked Choice Voting in Go using a CQRS architecture

License

Notifications You must be signed in to change notification settings

inklabs/vote

Repository files navigation

Ranked Choice Voting - Go CQRS

This is a demo application that implements Ranked Choice Voting, also known as Instant Runoff Voting, where voters rank candidates in order of preference, and a single winner is selected.

The sole purpose of this project is to demonstrate the capabilities of the (currently private) Go CQRS application framework.

Design

The architecture leverages Command Query Responsibility Segregation (CQRS). Business logic can be written in Commands, Queries, or Listeners.

Actions

Actions are Commands that modify state, or Queries that retrieve data. Commands can be asynchronously processed, with the status and log messages available for later retrieval.

Events

Events are used to remove temporal coupling between modules with separate responsibilities. Commands raise events and Listeners subscribe to them asynchronously.

  • Events
    • ElectionHasCommenced
    • ProposalWasMade
    • VoteWasCast
    • ElectionWasClosedByOwner
    • ElectionWinnerWasSelected

Listeners

Listeners subscribe to Events and execute code asynchronously.

Code Generation

The underlying Go CQRS application framework utilizes code generation to build the APIs and SDKs to execute this application. The Vote App uses go:generate directives to parse the domain and build various APIs. The generated output is not yet included in this project.

APIs

APIs are exposed through HTTP, gRPC, and CLI tooling.

Examples:

SDK

SDKs are auto-generated leveraging the gRPC clients.

Test

go generate .
go test ./...

Run

go run cmd/httpapi/main.go
go run cmd/grpcapi/main.go
go run cmd/cli-local/main.go --help

Test Python

go run cmd/grpcapi/main.go
python3 -m doctest python_test.py

Docker

Create a Docker network so that the containers can talk to each other.

docker network create otel

About

Demo application that implements Ranked Choice Voting in Go using a CQRS architecture

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published