SYSTEM CONFIG
Environment Variables
Invenicum uses environment variables and compile-time constants to configure API connectivity, timeouts, and core application settings. These settings are defined in lib/config/environment.dart.
Overview
The configuration system ensures that the application can adapt to different backend environments without modifying the source code. It combines dynamic variables (via --dart-define) with static constants.
Variable: API_URL
API_URL
Base URL for the backend API server. This is the most critical variable for connectivity.
Type: string
Default: “http://192.168.1.43:3000”
Example of compile-time override:
flutter run —dart-define=API_URL=https://api.production.com
Application Constants
These constants are defined in lib/config/environment.dart:7-31 and cannot be changed at runtime.
General Settings
| Constant | Type | Value | Description |
|---|---|---|---|
| appName | String | ”Invenicum” | App display name |
| appVersion | String | ”1.0.0” | Current version |
| apiVersion | String | ”/api/v1” | API version path |
| baseUrl | String | ”$apiUrl/api/v1” | Computed base URL |
Documentation URLs
docsUrl
stacDocsUrl
Network Timeouts
Connection Timeouts
connectTimeout
int default: “15000”
Timeout in milliseconds (15s) for establishing the initial connection.
receiveTimeout
int default: “45000”
Maximum time (45s) to wait for a response after connection is established.
API Endpoints
Authentication Endpoints (relative to baseUrl)
Login
/auth/login
User authentication
Logout
/auth/logout
Session termination
Refresh Token
/auth/refresh
Token renewal
Storage Keys
Secure Storage Keys
Keys used for persistent secure storage. Do not modify unless coordinating with backend changes.
authTokenKey
Stores the user’s authentication token.
refreshTokenKey
Stores the refresh token for session renewal.
Implementation Guide
Configuration Usage
How to access these settings in your Dart code:
import ‘package:invenicum/lib/config/environment.dart’;
// Use the configured base URL
final apiUrl = Environment.baseUrl;
// Access timeout settings
final timeout = Environment.connectTimeout;
// Get application info
final appName = Environment.appName;
final version = Environment.appVersion;
Build Configurations
Run commands for different environments:
Development
flutter run --dart-define=API_URL=http://localhost:3000Staging
flutter run --dart-define=API_URL=https://staging.api.comProduction
flutter run --dart-define=API_URL=https://api.invenicum.comBest Practices
Local Development
Use your local machine’s IP address instead of localhost when testing on physical devices or emulators to avoid routing issues.
Security
Never commit production API URLs or credentials to version control. Use environment-specific build configurations instead. Environment uses const values for compile-time optimization.
Related Files
Environment Config
lib/config/environment.dart:1-32
API Service
lib/data/services/api_service.dart
Preferences Service
lib/data/services/preferences_service.dart