Skip to content

Repository files navigation

🕌 Deen Bridge — Backend API

The REST API powering Deen Bridge: authentication, courses, library, community, and USDC payments on Stellar.

CI License: MIT PRs Welcome Stellar

Live API · Web App · Report a Bug · Contribute


About

This is the API service for Deen Bridge, a platform for authentic Islamic education. It handles users and roles, courses, the digital book library, community spaces, reels, notifications, and — at its core — non-custodial USDC payments on the Stellar network: the API builds an unsigned payment transaction, the buyer signs it in their own wallet, and the API verifies the payment on-chain before granting access. Creators receive USDC directly to their wallets.

The platform is composed of three services:

Repository Role Live
dnb-frontend Next.js web application dnb-frontend.vercel.app
dnb-backend (this repo) REST API — auth, content, Stellar payments dnb-backend-api.onrender.com
dnb-ai FastAPI service for the AI assistant dnb-ai.onrender.com

✨ Features

  • 🔐 JWT Authentication — access + refresh tokens, role-based access (student / mentor / admin)
  • 🎓 Course Management — create, enroll, review, and track courses
  • 📚 Digital Library — upload, purchase, and read Islamic books
  • Stellar Payments — USDC payment initialize → sign → submit → on-chain verify flow
  • 👛 Wallet Management — connect Freighter, xBull, or Albedo; balance and trustline checks
  • 💬 Real-time — Socket.io messaging and notifications
  • ☁️ Media — Cloudinary uploads for avatars, covers, books, and reels
  • 🛡️ Hardened — helmet, rate limiting, sanitization (mongo-sanitize, hpp, xss), CORS

🛠️ Tech Stack

Layer Technology
Runtime Node.js 20 · Express 5 (ESM)
Database MongoDB · Mongoose 8 · Redis (caching)
Blockchain @stellar/stellar-sdk v16 · Horizon
Auth JWT (access + refresh)
Media & Realtime Cloudinary · Multer · Socket.io
Observability Winston logging

🚀 Getting Started

Prerequisites

  • Node.js 20+
  • MongoDB (local or Atlas)
  • Redis (optional, for caching)

Setup

git clone https://github.com/Deen-Bridge/dnb-backend.git
cd dnb-backend
npm install
cp .env.example .env   # then fill in your values
npm run dev

The API runs at http://localhost:5000.

Key Environment Variables

Variable Description
PORT Server port (default 5000)
MONGO_URI MongoDB connection string
JWT_SECRET Secret for signing tokens (32+ chars)
STELLAR_NETWORK testnet or mainnet
CLOUDINARY_* Cloudinary credentials for media uploads
QUEUE_DRIVER mongo (durable production default) or inline (tests/CI)
JOBS_ENABLED Start background workers; defaults to true
JOBS_DASHBOARD_TOKEN Bearer token protecting /admin/jobs
STELLAR_PLATFORM_PUBLIC_KEY Public key published in stellar.toml ACCOUNTS[]

See .env.example for the full list.

Background jobs

Slow email and Stellar verification work uses the thin src/jobs/queue.js abstraction. The production mongo driver persists jobs in the mandatory MongoDB deployment, so work and idempotency keys survive restarts without making optional Redis a new requirement. The inline driver uses the same handlers in tests and CI. Jobs retry with exponential backoff and jitter, terminal failures are queryable at /admin/jobs/dead, and the token-protected dashboard is available at /admin/jobs.

Scripts

Command Purpose
npm run dev Start with hot reload
npm start Start in production mode
npm test Run the Jest + Supertest suite
npm run seed Seed sample data

🔗 API Overview

Area Base Route
SEP-1 Metadata /.well-known/stellar.toml
Auth & Users /api/auth, /api/users
Courses & Books /api/courses, /api/books
Spaces & Reels /api/spaces, /api/reels
Stellar Wallet /api/stellar/wallet/*
Stellar Payments /api/stellar/payment/*

Machine-readable spec

The full OpenAPI 3.1 contract for every mounted route lives in openapi.yaml. Open it in any OpenAPI viewer (Swagger Editor, Redoc, Stoplight) or point a client generator at it. It documents auth requirements, path and query parameters, request bodies, response schemas and status codes, reusable schemas for the core models, the standard error shape, and the endpoints whose response envelope is still non-standard.

🌊 Contributing & Drips Wave

This repository participates in the Stellar Drips Wave bounty program — contributors earn Points (and real rewards) for resolving this repo's issues during a Wave, with complexity tiers set in the Drips Wave app.

  • All pull requests target the dev branch (main is releases only)
  • CI (tests) must pass before review
  • One contributor per issue — comment to claim it first

Read CONTRIBUTING.md for the full workflow, coding standards, and Wave rules.

📜 License

MIT © Deen Bridge

🔗 Links

Releases

Packages

Contributors

Languages