# Appendix

### Environment Variable Reference

| Variable | Type | Required | Description |
|----------|------|----------|-------------|
| ENV | string | Yes | Environment (DEVELOPMENT/PRODUCTION) |
| API_PORT | number | Yes | Server port (default: 3610) |
| BASE_DOMAIN | string | Yes | API base URL |
| DB_HOST | string | Yes | PostgreSQL host |
| DB_PORT | number | Yes | PostgreSQL port |
| DB_USER | string | Yes | PostgreSQL username |
| DB_PASSWORD | string | Yes | PostgreSQL password |
| DB | string | Yes | PostgreSQL database name |
| MONGO_DB | string | Yes | MongoDB connection string |
| REDIS_HOST | string | Yes | Redis host |
| REDIS_PORT | number | Yes | Redis port |
| REDIS_PASSWORD | string | No | Redis password |
| JWT_SECRET | string | Yes | JWT signing secret |
| XENDIT_SECRET_KEY | string | Yes | Xendit API secret key |
| XENDIT_CALLBACK_TOKEN | string | Yes | Xendit webhook token |
| GOSEND_CLIENT_ID | string | Yes | GoSend API client ID |
| GOSEND_KEY | string | Yes | GoSend API key |
| GOSEND_ADDRESS | string | Yes | GoSend API base URL |
| MINIO_ENDPOINT | string | Yes | Minio server endpoint |
| MINIO_PORT | number | Yes | Minio server port |
| MINIO_ACCESS_KEY | string | Yes | Minio access key |
| MINIO_SECRET_KEY | string | Yes | Minio secret key |
| EMAIL_HOST | string | Yes | SMTP host |
| EMAIL_PORT | number | Yes | SMTP port |
| EMAIL_USER | string | Yes | SMTP username |
| EMAIL_PASSWORD | string | Yes | SMTP password |

### Database Schema Overview

#### Key PostgreSQL Tables

- **store**: Store information and settings
- **user_info**: User profiles and authentication
- **product**: Product catalog
- **product_variant**: Product variations (size, color, etc.)
- **store_order**: Order records
- **store_order_details**: Line items in orders
- **cart**: Shopping cart items
- **address_list**: Delivery addresses
- **balance_mutation**: Financial transactions
- **affiliate_account**: Affiliate user accounts
- **affiliate_commissions**: Commission records
- **affiliate_invitations**: Referral relationships
- **review**: Product reviews
- **voucher**: Discount codes
- **virtual_account**: Payment virtual accounts
- **xendit_invoice**: Payment invoices
- **bank_info**: Bank account information
- **payout_record**: Payout history

#### Key MongoDB Collections

- **store_chat**: Chat messages
- **store_chat_room**: Chat room metadata
- **affiliate_category**: Affiliate product categories
- **affiliate_clicks**: Click tracking for affiliate links
- **affiliate_links**: Generated affiliate links
- **order_info_cached**: Cached order data
- **shipping_info_cached**: Cached shipping calculations
- **price_info_cached**: Cached price calculations

### API Response Status Codes

| Code | Meaning | Usage |
|------|---------|-------|
| 200 | OK | Successful request |
| 201 | Created | Resource created successfully |
| 400 | Bad Request | Invalid request parameters |
| 401 | Unauthorized | Authentication required |
| 403 | Forbidden | Insufficient permissions |
| 404 | Not Found | Resource not found |
| 422 | Unprocessable Entity | Validation errors |
| 500 | Internal Server Error | Server error |
| 503 | Service Unavailable | Service temporarily unavailable |