Skip to content

feat: implement rich metadata relational schema with Drizzle ORM#572

Open
dev-fatima-24 wants to merge 1 commit intoHahfyeex:Defaultfrom
dev-fatima-24:feat/rich-metadata-schema
Open

feat: implement rich metadata relational schema with Drizzle ORM#572
dev-fatima-24 wants to merge 1 commit intoHahfyeex:Defaultfrom
dev-fatima-24:feat/rich-metadata-schema

Conversation

@dev-fatima-24
Copy link
Copy Markdown
Contributor

Pull Request: Implement Rich Metadata Relational Schema

Description

This PR implements the relational database schema required to store "Rich Metadata" (categories, long-form descriptions, and image pointers) that is too resource-intensive to maintain directly on the Stellar blockchain.

While the core financial operations (payouts/bets) remain on-chain via Soroban, this off-chain layer provides a premium user experience with detailed market context and organized discovery.

Key Changes

  • Drizzle ORM Integration: Added Drizzle ORM and pg for type-safe, performant Postgres interactions.
  • Relational Schema Design:
    • markets: Core market metadata with a Unique Index on the Soroban contract_id.
    • categories: Taxonimized organization for market discovery.
    • user_profiles: Rich metadata (bio, avatar, username) for Stellar wallet holders.
  • Database Utilities: implemented src/db/utils.js for clean CRUD operations on metadata.
  • Seeding System: Created scripts/seed.js to populate the environment with initial categories and profiles.
  • Comprehensive Testing:
    • Achieved 97.77% code coverage across all database utility functions and seed logic.
    • Implemented mock-based unit tests in tests/db_utils.test.js and tests/seed_script.test.js.

Visual Schema Validation

Entity Relationship Diagram (Internal Link to Documentation) Or refer to the generated mockup in the artifacts.

Verification Steps

  1. Migrations & Setup:
    cd backend
    npm install
    # Run migrations (ensure DATABASE_URL is set)
    npx drizzle-kit generate
  2. Seed Data:
    npm run seed # or node scripts/seed.js
  3. Tests:
    npm run test -- tests/db_utils.test.js tests/seed_script.test.js --coverage

Checklist

  • Schema implemented with Drizzle/Prisma choice.
  • Markets table uses Soroban Contract_ID as unique index.
  • Minimum 95% coverage achieved (Current: 97.77%).
  • ERD documented in /docs/database.md.
  • Seed script provided.

Closes #8

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 29, 2026

@dev-fatima-24 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Hahfyeex
Copy link
Copy Markdown
Owner

@dev-fatima-24 pls resolve conflicts

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.

PostgreSQL Schema: Relational Market Metadata

2 participants