Files
pos-system/microservices/.agent/skills/documentation/references/CONFIGURATION.md
Ho Ngoc Hai 76d75c753b Migrate
2026-05-23 18:37:02 +07:00

3.9 KiB

Configuration Documentation / Tài Liệu Cấu Hình

This reference provides templates and guidelines for documenting service configuration.

Environment Variables Table

## Environment Variables / Biến Môi Trường

### Required Variables / Biến Bắt Buộc

| Variable | Type | Description / Mô Tả | Example |
|----------|------|---------------------|----------|
| `DATABASE_URL` | string | PostgreSQL connection string / Chuỗi kết nối PostgreSQL | `postgresql://user:pass@localhost:5432/db` |
| `REDIS_URL` | string | Redis connection string / Chuỗi kết nối Redis | `redis://localhost:6379` |
| `JWT_SECRET` | string | Secret key for JWT signing / Khóa bí mật ký JWT | `your-256-bit-secret` |
| `RABBITMQ_URL` | string | RabbitMQ connection / Kết nối RabbitMQ | `amqp://user:pass@localhost:5672` |

### Optional Variables / Biến Tùy Chọn

| Variable | Type | Description / Mô Tả | Default |
|----------|------|---------------------|----------|
| `PORT` | integer | Server port / Cổng server | `5000` |
| `LOG_LEVEL` | enum | Logging level: `debug`, `info`, `warn`, `error` | `info` |
| `CORS_ORIGINS` | string | Allowed CORS origins (comma-separated) | `*` |
| `RATE_LIMIT_MAX` | integer | Max requests per window / Số request tối đa | `100` |
| `RATE_LIMIT_WINDOW_MS` | integer | Rate limit window in ms / Cửa sổ giới hạn (ms) | `60000` |
| `CACHE_TTL_SECONDS` | integer | Default cache TTL / TTL cache mặc định | `300` |

Configuration File Example

## Configuration File: `appsettings.json`

\`\`\`json
{
  "Server": {
    "Port": 5000,
    "Environment": "Development",
    "EnableSwagger": true
  },
  "Database": {
    "Host": "localhost",
    "Port": 5432,
    "Name": "goodgo_dev",
    "Username": "postgres",
    "Password": "password",
    "MaxPoolSize": 20,
    "CommandTimeout": 30
  },
  "Redis": {
    "Host": "localhost",
    "Port": 6379,
    "Database": 0,
    "Password": null,
    "ConnectTimeout": 5000,
    "SyncTimeout": 5000
  },
  "Jwt": {
    "Secret": "your-secret-key-min-32-chars",
    "Issuer": "goodgo-platform",
    "Audience": "goodgo-clients",
    "ExpirationMinutes": 60,
    "RefreshTokenExpirationDays": 7
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    },
    "Console": {
      "FormatterName": "json"
    }
  },
  "RateLimiting": {
    "PermitLimit": 100,
    "Window": "00:01:00",
    "QueueLimit": 10
  },
  "Cors": {
    "AllowedOrigins": [
      "http://localhost:3000",
      "https://app.goodgo.vn"
    ],
    "AllowCredentials": true,
    "AllowedHeaders": ["*"],
    "AllowedMethods": ["GET", "POST", "PUT", "DELETE"]
  }
}
\`\`\`

**Notes:**
- **EN**: Never commit secrets to version control. Use environment variables or secret management tools.
- **VI**: Không bao giờ commit secrets vào version control. Dùng biến môi trường hoặc công cụ quản lý secrets.

Docker Compose Configuration

## Docker Compose Configuration

\`\`\`yaml
version: '3.8'

services:
  app:
    build: .
    ports:
      - "5000:5000"
    environment:
      - DATABASE_URL=postgresql://postgres:password@db:5432/goodgo
      - REDIS_URL=redis://redis:6379
      - JWT_SECRET=${JWT_SECRET}
      - LOG_LEVEL=info
    depends_on:
      - db
      - redis
  
  db:
    image: postgres:15
    environment:
      - POSTGRES_DB=goodgo
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=password
    volumes:
      - postgres_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"
  
  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data

volumes:
  postgres_data:
  redis_data:
\`\`\`

**Environment File** (`.env`):
\`\`\`bash
JWT_SECRET=your-production-secret-key-min-32-characters
DATABASE_PASSWORD=your-secure-db-password
\`\`\`

Resources