> ## Documentation Index
> Fetch the complete documentation index at: https://lopiv2-invenicum-25.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Environment Variables

> Configure Invenicum's environment variables for API connectivity, timeouts, and application settings

## Overview

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`.

## Environment Variables

**API\_URL** `string` (default: [http://192.168.1.43:3000](http://192.168.1.43:3000))

Base URL for the backend API server. This can be overridden at compile time using the `--dart-define` flag.

**Example:**

```bash theme={null}
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"` | Application display name |
| `appVersion` | String | `"1.0.0"` | Current application version |
| `apiVersion` | String | `"/api/v1"` | API version path prefix |
| `baseUrl` | String | `"$apiUrl/api/v1"` | Complete base URL (computed) |

### Documentation URLs

| Constant | Type | Value |
| - | - | - |
| `docsUrl` | String | `"https://docs.invenicum.com"` |
| `stacDocsUrl` | String | `"https://docs.stac.dev/introduction"` |

### Network Timeouts

**connectTimeout** `int` (default: 15000)

Connection timeout in milliseconds (15 seconds). Used when establishing initial connection to the API server.

**receiveTimeout** `int` (default: 45000)

Response timeout in milliseconds (45 seconds). Maximum time to wait for a response after connection is established.

### API Endpoints

Authentication endpoints relative to `baseUrl`:

| Endpoint | Path | Description |
| - | - | - |
| Login | `/auth/login` | User authentication |
| Logout | `/auth/logout` | Session termination |
| Refresh Token | `/auth/refresh` | Token renewal |

### Storage Keys

> [!WARNING]
>
> These keys are used for secure storage. **Do not modify** unless coordinating with backend changes.

| Key | Purpose |
| - | - |
| `authTokenKey` | Stores the user's authentication token |
| `refreshTokenKey` | Stores the refresh token for session renewal |

## Configuration Usage

Access environment configuration in your code:

```dart theme={null}
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

You can create different configurations for development, staging, and production:

```bash Development theme={null}
flutter run --dart-define=API_URL=http://localhost:3000
```

```bash Staging theme={null}
flutter run --dart-define=API_URL=https://staging-api.invenicum.com
```

```bash Production theme={null}
flutter build apk --dart-define=API_URL=https://api.invenicum.com
```

## Best Practices

> [!TIP]
>
> **For Development:** Use your local machine's IP address instead of `localhost` when testing on physical devices or emulators.

> [!WARNING]
>
> **Security:** Never commit production API URLs or credentials to version control. Use environment-specific build configurations instead.

> [!NOTE]
>
> The `Environment` class uses `const` values for compile-time optimization, meaning values cannot be changed at runtime.

## 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`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.