The REST API powering Deen Bridge: authentication, courses, library, community, and USDC payments on Stellar.
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 |
- 🔐 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
| 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 |
- Node.js 20+
- MongoDB (local or Atlas)
- Redis (optional, for caching)
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 devThe API runs at http://localhost:5000.
| 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.
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.
| 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 |
| 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/* |
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
devbranch (mainis 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.
MIT © Deen Bridge
- 🌐 Website: dnb-frontend.vercel.app
- 🐦 X/Twitter: @deen_bridge
- 🏢 Organization: github.com/Deen-Bridge