Skip to content

Conversation

@Chesblaw
Copy link

Feature: Distributions Backend

This PR introduces a complete backend implementation for the Distributions system, enabling batch badge distributions, persistent storage, and retrieval endpoints.

✨ New Features

Batch Distribution Endpoint

  • Each user maintains an independent, on-chain ScoreProfile.

  • New REST endpoint::

POST /distributions

Query Capabilities

  • Retrieve all items for a given distribution:
GET /distributions/:distributionId

Technical Implementation

  • Rust + SQLx Backend
  • PostgreSQL storage

Files Added

src/application/commands/create_distribution.rs
distribution_dto.rs
src/domain/entities/distribution.rs
src/domain/repositories/distribution_repository.rs
src/infrastructure/repositories/postgres_distribution_repository.rs
migrations/4_add_distributions.sql

Files Modified

Backend router/handler to wire distribution endpoints

Usage Example

{
  "items": [
    {
      "address": "0xAbc123...",
      "badge_name": "EarlyContributor",
      "metadata": { "campaign": "beta" }
    }
  ],
  "metadata": { "triggered_by": "system" }
}


✅ Checklist

  • Rust compilation passes
  • SQLx compile-time checks validated
  • Database migrations run cleanly
  • Endpoints tested and functional
  • Domain models aligned with schema

Copy link
Contributor

@joelamouche joelamouche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the submission @Chesblaw ! Overall looks great, even though I would need to dig deeper into the implementation details.

However, before I do that, I think that something wasn't clear when in the task description: the distribution id is know before registering it into our backend (and therefore you should generate it in our backend).

The flow goes this way:

  1. create list of users that should get batches
  2. distribute badges to user using (foundry) script: this is where the distribution id is created (and optionally registered onchain to avoid duplicate distribution)
  3. register distirbution in the backend for accountability

Thanks in advance!

@Chesblaw
Copy link
Author

@joelamouche gotchu

@joelamouche
Copy link
Contributor

@Chesblaw How's the task going?

@joelamouche
Copy link
Contributor

Any progress on this @Chesblaw ? Would be a shame to throw away a great PR

@Chesblaw
Copy link
Author

Hey @joelamouche i'm sorry for the late i will update you within a few days.

@joelamouche
Copy link
Contributor

Okay sounds good :)

@tusharshah21
Copy link
Collaborator

Any update mate @Chesblaw?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants