Files
unionflow-server-api/unionflow/unionflow-mobile-apps/lib/core/config/environment.dart
dahoud e8ad874015 feat: WebSocket temps réel + Finance Workflow + corrections
- Task #6: WebSocket /ws/dashboard + Kafka events (5 topics)
  * Backend: KafkaEventProducer, KafkaEventConsumer
  * Mobile: WebSocketService (reconnection, heartbeat, typed events)
  * DashboardBloc: Auto-refresh depuis WebSocket events

- Finance Workflow: approbations + budgets (backend + mobile)
  * Backend: entities, services, resources, migrations Flyway V6
  * Mobile: features finance_workflow complète avec BLoC

- Corrections DI: interfaces IRepository partout
  * IProfileRepository, IOrganizationRepository, IMembreRepository
  * GetIt configuré avec @injectable

- Spec-Kit: constitution + templates mis à jour
  * .specify/memory/constitution.md enrichie
  * Templates agent, plan, spec, tasks, checklist

- Nettoyage: fichiers temporaires supprimés

Signed-off-by: lions dev Team
2026-03-15 02:12:17 +00:00

97 lines
3.2 KiB
Dart

/// Environnements de déploiement de l'application
enum Environment { dev, staging, prod }
/// Configuration centralisée par environnement.
/// Les URLs sont injectées via --dart-define=ENV=dev|staging|prod
class AppConfig {
static late final Environment _environment;
static late final String apiBaseUrl;
static late final String keycloakBaseUrl;
static late final String wsBaseUrl;
static late final bool enableDebugMode;
static late final bool enableLogging;
static late final bool enableCrashReporting;
static late final bool enableAnalytics;
/// Initialise la configuration à partir de l'environnement.
/// Appeler dans main() avant runApp().
static void initialize() {
const envString = String.fromEnvironment('ENV', defaultValue: 'dev');
_environment = Environment.values.firstWhere(
(e) => e.name == envString,
orElse: () => Environment.dev,
);
switch (_environment) {
case Environment.dev:
apiBaseUrl = const String.fromEnvironment(
'API_URL',
defaultValue: 'http://localhost:8085',
);
keycloakBaseUrl = const String.fromEnvironment(
'KEYCLOAK_URL',
defaultValue: 'http://localhost:8180',
);
wsBaseUrl = const String.fromEnvironment(
'WS_URL',
defaultValue: 'ws://localhost:8085',
);
enableDebugMode = true;
enableLogging = true;
enableCrashReporting = false;
enableAnalytics = false;
case Environment.staging:
apiBaseUrl = const String.fromEnvironment(
'API_URL',
defaultValue: 'https://api-staging.lions.dev',
);
keycloakBaseUrl = const String.fromEnvironment(
'KEYCLOAK_URL',
defaultValue: 'https://security-staging.lions.dev',
);
wsBaseUrl = const String.fromEnvironment(
'WS_URL',
defaultValue: 'wss://api-staging.lions.dev',
);
enableDebugMode = false;
enableLogging = true;
enableCrashReporting = true;
enableAnalytics = false;
case Environment.prod:
apiBaseUrl = const String.fromEnvironment(
'API_URL',
defaultValue: 'https://api.lions.dev',
);
keycloakBaseUrl = const String.fromEnvironment(
'KEYCLOAK_URL',
defaultValue: 'https://security.lions.dev',
);
wsBaseUrl = const String.fromEnvironment(
'WS_URL',
defaultValue: 'wss://api.lions.dev',
);
enableDebugMode = false;
enableLogging = false;
enableCrashReporting = true;
enableAnalytics = true;
}
}
static Environment get environment => _environment;
static bool get isDev => _environment == Environment.dev;
static bool get isStaging => _environment == Environment.staging;
static bool get isProd => _environment == Environment.prod;
/// URL complète du realm Keycloak
static String get keycloakRealmUrl => '$keycloakBaseUrl/realms/unionflow';
/// URL du endpoint token Keycloak
static String get keycloakTokenUrl =>
'$keycloakRealmUrl/protocol/openid-connect/token';
/// URL du endpoint WebSocket dashboard
static String get wsDashboardUrl => '$wsBaseUrl/ws/dashboard';
}