Environment Configuration
Relevant source files
The following files were used as context for generating this wiki page:
The Environment Configuration for the Outmanage Backend system encompasses the initialization of the Express application, database connectivity via Prisma ORM, and the management of environmental variables. It ensures that the system operates within specific regional parameters, such as the Asia/Jakarta timezone, and maintains security through CORS policies and AI service integrations.
This configuration is critical for synchronizing development and production environments, managing file storage paths, and ensuring that external services like Google Gemini AI are properly authenticated for vehicle plate verification.
System Runtime and Initialization
The application initializes by loading environment variables via dotenv.config() and setting up the Express server. A key architectural requirement is the enforcement of the Asia/Jakarta (GMT+7) timezone for all operations, which is achieved through both runtime cross-env scripts and manual date adjustments in the code.
Sources: src/index.ts:1-15, package.json:6-12, CLAUDE.md:104-106
Core Initialization Flow
The following diagram illustrates how the server boots up and configures its primary middleware and database connections.
The system relies on specific environment-level settings to handle cross-origin requests and database persistence.
Sources: src/index.ts:17-45, src/index.ts:110-120
Environment Variables
The system uses a .env file for local development and environment-specific files (e.g., .env.prod) for containerized deployments. These variables control database access, server ports, and external API keys.
| Variable | Type | Description |
|---|---|---|
PORT | Integer | The port the Express server listens on (Default: 3000) |
DATABASE_URL | String | Connection string for MySQL (e.g., mysql://user:pass@host:3306/db) |
NODE_ENV | String | Operation mode (development or production) |
GEMINI_API_KEY | String | API key for Google Gemini AI plate verification |
TZ | String | System timezone, strictly set to Asia/Jakarta |
Sources: src/index.ts:15-16, README.md:14-16, README.md:144-150, package.json:7-12
Database Configuration
The system utilizes MySQL as the primary data store, managed through the Prisma ORM. The configuration involves a schema definition and migration workflows to ensure data consistency across environments.
The database schema defines strictly typed relationships for RBAC (Role-Based Access Control) and logistics entities.
Sources: prisma/schema.prisma:1-50, CLAUDE.md:21-30
Database Lifecycle Commands
Developers interact with the database environment using the following Prisma commands:
npx prisma migrate dev: Applies schema changes to the development database.npx prisma generate: Updates the Prisma Client types after schema modifications.npm run seed: Populates the database with initial roles, permissions, and administrative users.
Sources: README.md:20-35, CLAUDE.md:14-18
Storage and Static Files
The fileService.ts handles the configuration of physical storage paths based on the environment. It distinguishes between local development paths and production paths on a VPS.
// File path configuration logic
const isProd = process.env.NODE_ENV === 'production';
const PUBLIC_DIR = isProd
? '/var/www/sajpoutbound.com/public'
: path.join(process.cwd(), 'src', 'public');
const PLATE_PHOTOS_DIR = path.join(PUBLIC_DIR, 'plate-photos');
Sources: src/services/fileService.ts:12-18
Static Asset Mapping
The server exposes these directories via the /public route:
- Plate Photos:
/public/plate-photos/ - SPMB PDFs:
/public/spmb/ - Nota Timbangan PDFs:
/public/nota-timbangan/
Sources: src/index.ts:45, CLAUDE.md:73-77
Security and CORS
Security is configured at the middleware level in src/index.ts. The system employs a custom JWT authentication header (x-outmanage-token) rather than the standard Authorization bearer token for many operations.
CORS Allowed Origins
The environment is configured to accept requests only from specific trusted domains:
https://www.sajpoutbound.comhttps://outmanage.vercel.apphttp://localhost:5173(Development)https://benzeta.shop
Sources: src/index.ts:19-35, comprehensive-swagger-api.json:20-25, CLAUDE.md:46-50
Conclusion
The environment configuration of the Outmanage Backend provides a robust foundation for logistics management. By centralizing timezone management, database orchestration through Prisma, and environment-aware file services, the system maintains high technical accuracy and operational consistency across varied deployment targets.