# Tech4Biz Channel Partner Onboarding & Secure Asset Management

An enterprise-grade, secure, multi-tenant portal designed for onboarding channel partners, managing digital assets, and orchestrating NDA/MSA legal workflows.

---

## 🛠️ Technology Stack
*   **Frontend**: React (Vite, TypeScript, Tailwind CSS, Axios)
*   **Backend**: Node.js (Express, TypeScript, Prisma ORM, JWT, Helmet)
*   **Databases**: PostgreSQL (Relational metadata storage)
*   **Object Storage**: MinIO (Private, S3-compatible asset storage container)

---

## 🚀 Quick Start (Development)

### Prerequisites
*   Ensure **Docker** and **Node.js** are installed and running.
*   The startup scripts automatically detect and terminate any processes occupying backend/frontend ports to prevent crash loops.

### Step 1: Start Backend, Database, & Storage
From the project root:
```bash
./run-backend.sh
```
This script will:
1. Spin up the Postgres and MinIO containers.
2. Generate environment variables.
3. Align the database schemas via Prisma.
4. Run database seeders (Admin/Partner mock accounts).
5. **Automatically seed the MinIO bucket with static documents.**
6. Free port `5000` (if in use) and launch the backend server.

### Step 2: Start Frontend App
From the project root:
```bash
./run-frontend.sh
```
This script will resolve dependencies, free port `5173` (if in use), and launch the Vite development server on [http://localhost:5173](http://localhost:5173).

---

## 📂 MinIO Seeding & Data Transfer

### How Asset Seeding Works
To ensure that digital assets (like product guides and NDA templates) are transferred when cloning the repository:
1. Standard assets are committed to the **`minio-seed/`** directory in the repository root (not ignored by Git).
2. During server start (via `./run-backend.sh`), the backend runs the S3 seeder command:
   ```bash
   npx ts-node src/seed-minio.ts
   ```
3. The script initializes the `secure-assets` bucket in MinIO and uploads any files found in the local `/minio-seed/` folder to the bucket, preserving exact filenames, MIME types, and sizes.

### Manual Seeding / Restore Command
If you ever reset your MinIO volume and need to re-populate the S3 bucket with the committed repository assets, run the following commands:
```bash
cd Channel-Backend
npx ts-node src/seed-minio.ts
```

---

## 🔑 Default Credentials & Admin Ports

### Web Interfaces
*   **Frontend Dashboard**: [http://localhost:5173](http://localhost:5173)
*   **MinIO Console Dashboard**: [http://localhost:9090](http://localhost:9090)

### Login Credentials
| System | User/ID | Password/Secret |
| :--- | :--- | :--- |
| **Admin Account** | `admin@tech4biz.com` | `Password123` |
| **Partner (Approved)** | `active-partner@partner.com` | `Password123` |
| **Partner (Pending NDA)** | `pending-onboarding@partner.com` | `Password123` |
| **MinIO Console** | `minio_admin` | `minio_password_2026` |
| **JWT Secrets** | *Auto-generated in `.env`* | `super-secret-jwt-key-2026-world-class` |
