How crowafrica/crow-backend works
Purpose and Runtime
Crow Elite is a NestJS/Node.js backend for brand–creator collaborations: identity onboarding, creator discovery, campaigns, applications, contracts, messaging, reviews, and escrow payments. The HTTP server starts in src/main.ts; root composition is src/app.module.ts. Swagger is exposed at /api/docs.
API and Module Boundary
Feature modules follow Nest’s controller → service → persistence pattern. Controllers expose REST endpoints and services own use-case logic:
• src/creators/creators.controller.ts, src/creators/creators.service.ts
• src/campaigns/campaigns.controller.ts, src/campaigns/campaigns.service.ts
• src/applications/applications.controller.ts, src/applications/applications.service.ts
DTOs at feature boundaries validate/shape requests, including campaign creation/search and application or invitation actions.
Identity, Access, and Onboarding
Authentication supports registration, OTP verification, login, role-specific onboarding, JWT sessions, and Google OAuth. src/auth/auth.controller.ts delegates these flows to src/auth/auth.service.ts. Request protection is split between JWT, Google, and role guards in src/auth/guards/jwt-auth.guard.ts, src/auth/guards/google-auth.guard.ts, and src/auth/guards/roles.guard.ts. User identity is propagated through src/common/decorators/current-user.decorator.ts.
Collaboration Lifecycle
Brands create and manage campaigns; creators discover campaigns and apply, while brands can invite creators. The applications module is the lifecycle junction between campaign and creator records, with request contracts in src/applications/dto/apply-campaign.dto.ts and src/applications/dto/invite-creator.dto.ts. Contracts add milestones to accepted work, through src/contracts/contracts.service.ts and src/contracts/dto/create-milestone.dto.ts.
Engagement and Trust
Post-collaboration interactions are modeled as messages and reviews:
• src/messages/messages.controller.ts, src/messages/messages.service.ts
• src/reviews/reviews.controller.ts, src/reviews/reviews.service.ts
These are separate domain modules rather than part of the application workflow service, allowing messaging, reputation, and contract state to evolve independently.
Persistence and External Services
PostgreSQL is the system of record, accessed via the shared Prisma integration in src/prisma/prisma.module.ts and src/prisma/prisma.service.ts; schema and migration history are in prisma/schema.prisma and prisma/migrations/. Cloudinary provides uploaded-file/image storage through src/cloudinary/cloudinary.module.ts and src/cloudinary/cloudinary.service.ts. Email-related delivery is isolated in src/mail/mail.module.ts and src/mail/mail.service.ts.
Payments and Operational Deployment
Escrow funding is exposed as a dedicated payments domain, separated from contracts: src/payments/payments.controller.ts, src/payments/payments.service.ts, and src/payments/dto/fund-escrow.dto.ts. Local infrastructure is represented by docker-compose.yml; Render deployment configuration is in render.yaml. Cross-cutting error normalization is centralized in src/common/filters/all-exceptions.filter.ts.
Main entry points: app.module.ts App module · prisma.service.ts Prisma data access · applications.service.ts Applications & invites · auth.controller.ts Auth API
Components 17
Runtime
- Nest bootstrap · Starts HTTP server and Swagger docs.
src/main.ts - App module · Composes feature and shared modules.
src/app.module.ts - Container & Render deploy · Local Compose infrastructure and Render deployment.
docker-compose.yml
Identity & Access
- Auth API · Registration, OTP, login, onboarding, JWT, and Google OAuth.
src/auth/auth.controller.ts - Access controls · JWT, Google, role enforcement, and current-user propagation.
src/auth/guards/jwt-auth.guard.ts
Collaboration
- Creators · Creator profiles and discovery use cases.
src/creators/creators.service.ts - Campaigns · Brand campaign creation, management, and search.
src/campaigns/campaigns.service.ts - Applications & invites · Junction for creator applications and brand invitations.
src/applications/applications.service.ts - Contracts & milestones · Accepted work contracts and milestone creation.
src/contracts/contracts.service.ts - Escrow payments · Dedicated escrow funding domain.
src/payments/payments.service.ts
Engagement
Platform Services
- Prisma data access · Shared database client integration.
src/prisma/prisma.service.ts - PostgreSQL
prisma/schema.prisma - Cloudinary integration · Uploaded-file and image storage.
src/cloudinary/cloudinary.service.ts - Mail delivery
src/mail/mail.service.ts - Exception normalization
src/common/filters/all-exceptions.filter.ts
Connections 27
- Nest bootstrap → App module: boots
- Nest bootstrap → Exception normalization: installs
- App module → Auth API: composes
- App module → Creators: composes
- App module → Campaigns: composes
- App module → Applications & invites: composes
- App module → Contracts & milestones: composes
- App module → Escrow payments: composes
- App module → Messages: composes
- App module → Reviews: composes
- Auth API → Access controls: uses
- Auth API → Prisma data access: persists identities
- Creators → Prisma data access: reads and writes
- Campaigns → Prisma data access: reads and writes
- Applications & invites → Creators: links creators
- Applications & invites → Campaigns: links campaigns
- Applications & invites → Prisma data access: persists lifecycle
- Contracts & milestones → Applications & invites: follows acceptance
- Contracts & milestones → Prisma data access: persists contracts
- Escrow payments → Contracts & milestones: funds escrow for
- Escrow payments → Prisma data access: persists funding
- Messages → Prisma data access: persists conversations
- Reviews → Prisma data access: persists reputation
- Prisma data access → PostgreSQL: accesses
- Creators → Cloudinary integration: stores uploads
- Auth API → Mail delivery: sends OTP email
- Container & Render deploy → Nest bootstrap: deploys