# MoFresh Backend API
Backend API for MoFresh, a cold chain management system for Rwanda's agricultural sector.
## Overview
MoFresh Backend is a NestJS-based REST API that manages cold chain operations across three physical sites in Rwanda (Kigali, Musanze, and Rubavu). The system handles product inventory, cold room capacity tracking, order processing, automated invoicing, and payment integration with MTN Mobile Money (MoMo) Sandbox.
## Technology Stack
- **Framework**: NestJS 11.x
- **Language**: TypeScript 5.x
- **Database**: PostgreSQL 15+
- **ORM**: Prisma 6.x
- **Authentication**: JWT with bcrypt
- **Payment Integration**: MTN Mobile Money (MoMo) Sandbox
- **Documentation**: Swagger/OpenAPI
- **Testing**: Jest with Supertest
## Prerequisites
- Node.js 18.x or higher
- npm 9.x or higher
- PostgreSQL 15.x or higher
- Docker and Docker Compose (optional, for containerized development)
## Quick Start
### Automated Setup
Run the automated setup script to configure the entire development environment:
```bash
./setup.sh
```
The script will:
1. Create environment configuration from template
2. Install all dependencies
3. Start PostgreSQL via Docker
4. Generate Prisma Client
5. Run database migrations
6. Seed database with sample data
7. Build the application
### Manual Setup
If you prefer manual setup or need to troubleshoot:
1. Install dependencies:
```bash
npm install
```
2. Configure environment:
```bash
cp .env.example .env
# Edit .env with your configuration
```
3. Set up database:
```bash
npm run prisma:generate
npm run prisma:migrate
npm run prisma:seed
```
4. Start development server:
```bash
npm run start:dev
```
The API will be available at `
localhost`
## Docker Setup
### Development Environment
Start PostgreSQL and the API in containers:
```bash
docker-compose up -d
```
Run migrations inside the container:
```bash
docker-compose exec api npm run prisma:migrate
```
Seed the database:
```bash
docker-compose exec a …