Skip to content

feat(api): initialize prisma core schema#120

Open
David-patrick-chuks wants to merge 1 commit intoMissBlue00:mainfrom
David-patrick-chuks:feat/issue-4-prisma-schema
Open

feat(api): initialize prisma core schema#120
David-patrick-chuks wants to merge 1 commit intoMissBlue00:mainfrom
David-patrick-chuks:feat/issue-4-prisma-schema

Conversation

@David-patrick-chuks
Copy link
Copy Markdown

@David-patrick-chuks David-patrick-chuks commented Mar 25, 2026

Overview

This PR initializes Prisma in apps/api and adds the first authoritative PostgreSQL schema for the API. It introduces the core database models for merchants, payment intents, treasury assets, and webhook endpoints, along with the initial migration and Prisma client setup for the NestJS API.

Related Issue

Closes #4

Changes

⚙️ Prisma Initialization

  • [MODIFY] apps/api/package.json

    • Added Prisma scripts for client generation and migration deployment.
    • Added @prisma/client and prisma dependencies.
  • [ADD] apps/api/src/prisma/prisma.service.ts

    • Added a shared Prisma service for NestJS.
    • Configured Prisma connection lifecycle hooks for module init and shutdown.
  • [ADD] apps/api/src/prisma/prisma.module.ts

    • Added a global Prisma module so the Prisma client can be injected across the API.
  • [MODIFY] apps/api/src/app.module.ts

    • Registered the new Prisma module in the API app.

🗄️ Database Schema

  • [ADD] apps/api/prisma/schema.prisma
    • Added the PostgreSQL Prisma datasource.
    • Defined the Merchant model with UUID id, unique email, password hash, KYC status, and timestamps.
    • Defined the PaymentIntent model with merchant relation, amount, currency, status, and timestamps.
    • Defined the TreasuryAsset model with symbol, total minted, and total reserved.
    • Defined the WebhookEndpoint model with merchant relation, URL, secret, and timestamps.
    • Added enums for KycStatus and PaymentIntentStatus.

🧾 Initial Migration

  • [ADD] apps/api/prisma/migrations/20260325000000_init_core_schema/migration.sql

    • Added the initial SQL migration for the core schema.
    • Created the required enums, tables, indexes, and foreign keys.
  • [ADD] apps/api/prisma/migrations/migration_lock.toml

    • Added Prisma migration lock metadata for PostgreSQL.

🔧 Environment

  • [MODIFY] apps/api/.env.example
    • Updated the database section so DATABASE_URL is clearly part of the active setup.

Verification Results

Acceptance Criteria Status
Prisma is initialized in apps/api
Core Merchant table exists with required fields
Core PaymentIntent table exists with required fields and FK
Core TreasuryAsset table exists with required fields
Core WebhookEndpoint table exists with required fields and FK
Initial migration is present and applies successfully
Prisma client generates successfully
API project builds successfully after integration

How to Test

# 1. Confirm you're on the branch
git branch --show-current

# 2. Install dependencies if needed
pnpm install

# 3. Set a PostgreSQL connection string
export DATABASE_URL="postgresql://user:password@localhost:5432/stellar_pay"

# 4. Validate the Prisma schema
pnpm --filter api exec prisma validate

# 5. Generate the Prisma client
pnpm --filter api exec prisma generate

# 6. Apply the migration
pnpm --filter api exec prisma migrate deploy

# 7. Verify the API still builds
pnpm --filter api build

# 8. Optional: inspect the changed files
git diff -- apps/api/package.json apps/api/.env.example apps/api/src/app.module.ts apps/api/src/prisma apps/api/prisma pnpm-lock.yaml

Screenshots

✅ Prisma schema validates

A screenshot of:

pnpm --filter api exec prisma validate
image

✅ Prisma client generates

A screenshot of:

pnpm --filter api exec prisma generate
image

✅ Migration deploy succeeds

A screenshot of:

pnpm --filter api exec prisma migrate deploy
image

✅ API build passes

A screenshot of:

pnpm --filter api build
image

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 25, 2026

@David-patrick-chuks is attempting to deploy a commit to the missblue00's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 25, 2026

@David-patrick-chuks 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

@MissBlue00
Copy link
Copy Markdown
Owner

@David-patrick-chuks the ci/cd check failed and there are merge conflicts, please resolve

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.

Database: Initialize Prisma and define core PostgreSQL schema

2 participants