A multi-channel digital payment platform for cooperatives to collect, track, and manage rent-related payments β all integrated with local payment gateways and IremboPay.
# Copay Backend Server
A production-grade NestJS backend for the Cooperative Payment System (Copay) built with Domain-Driven Design (DDD) and Clean Architecture principles.
## π Features
- **Multi-tenancy**: Each cooperative operates as an isolated tenant
- **Role-based Access Control**: Super Admin, Organization Admin, and Tenant roles
- **JWT Authentication**: Secure phone number + 4-digit PIN authentication
- **Fastify**: High-performance web framework
- **MongoDB with Prisma**: Modern database ORM with type safety
- **Swagger Documentation**: Auto-generated API documentation
- **Rate Limiting**: Built-in throttling protection
- **Caching**: Redis-based caching for improved performance
- **Validation**: Comprehensive input validation with DTOs
- **Clean Architecture**: DDD modules with separation of concerns
## ποΈ Architecture
```
src/
βββ config/ # Configuration files and validation
βββ modules/ # Feature modules (DDD structure)
β βββ auth/ # Authentication & JWT
β βββ user/ # User management & RBAC
β βββ ... # Other business modules
βββ shared/ # Shared utilities, guards, decorators
βββ prisma/ # Database service and configuration
βββ main.ts # Application bootstrap with Fastify
```
## π Prerequisites
- Node.js (v18+)
- MongoDB database
- Redis (optional, for caching)
## π οΈ Installation
1. **Clone the repository**
```bash
git clone
cd copay-backend-server
```
2. **Install dependencies**
```bash
npm install
```
3. **Setup environment variables**
```bash
cp .env.example .env
```
Update the `.env` file with your database URL and configuration:
```env
DATABASE_URL="mongodb+srv://username:password@
cluster.mongodb.net"
JWT_SECRET="your-super-secret-jwt-key"
# ... other configuration
```
4. **Generate Prisma client**
```bash
npm run prisma:generate
```
5. **Seed the database** (optional)
```bash
npm run prisma:seed
```
## π Running the Application
```bash
# D β¦