Environment Configuration
Relevant source files
The following files were used as context for generating this wiki page:
The environment configuration for the GeNCorE Command Center is a critical system that manages authentication, GitHub API integration, and repository targeting. It ensures that the application can securely communicate with GitHub to manage AI agents while protecting the dashboard from unauthorized access via local and production-level environment variables.
Configuration is primarily handled through server-side environment variables, ensuring that sensitive data like the GITHUB_TOKEN and ADMIN_TOKEN never reach the client-side frontend. The system supports different configurations for development (via .env.local) and production (via Vercel Environment Variables).
Sources: README.md:52-70, middleware.ts:31-50
Core Configuration Variables
The application relies on four primary environment variables to define its operational context and security perimeter.
| Variable | Scope | Description |
|---|---|---|
GITHUB_TOKEN | Server-side | Personal Access Token (PAT) with repo scope for GitHub API access. |
ADMIN_TOKEN | Server-side | Master password used to generate secure session cookies for dashboard access. |
NEXT_PUBLIC_REPO_OWNER | Universal | The GitHub organization or user account owning the target repository. |
NEXT_PUBLIC_REPO_NAME | Universal | The specific repository name (e.g., GentelmeN-CorE). |
Sources: README.md:58-63, app/api/task/route.ts:4-7
Authentication & Security Logic
The system employs a multi-layered security approach. Access to both the UI and the API routes is gated by a middleware layer that validates a hashed session token against the configured ADMIN_TOKEN.
Session Verification Flow
The following diagram illustrates how the environment configuration influences the request lifecycle through the middleware.
The diagram shows the logic used to protect routes based on the presence of the ADMIN_TOKEN environment variable.
Sources: middleware.ts:16-60
Token Hashing
Rather than storing the raw ADMIN_TOKEN in the browser, the system uses a HMAC-SHA256 hash of the token combined with a static payload (gencore:session:v1). This ensures that even if a cookie is intercepted, the master token remains hidden.
const PAYLOAD = 'gencore:session:v1'
export async function hashAdminToken(adminToken: string): Promise<string> {
const enc = new TextEncoder()
const key = await crypto.subtle.importKey(
'raw',
enc.encode(adminToken),
{ name: 'HMAC', hash: 'SHA-256' },
false,
['sign']
)
const sig = await crypto.subtle.sign('HMAC', key, enc.encode(PAYLOAD))
return Array.from(new Uint8Array(sig))
.map((b) => b.toString(16).padStart(2, '0'))
.join('')
}
Sources: lib/auth.ts:9-25, README.md:95-98
GitHub API Integration
Environment variables define the target for all GitHub REST API v3 operations. If GITHUB_TOKEN is missing, API routes are designed to fail with a 500 error to prevent silent failures or unauthenticated attempts.
Configuration Data Flow
The configuration variables are injected into the API endpoints to construct valid GitHub API URLs.
The diagram represents the dependency of API routes on environment configuration for successful GitHub interaction.
Sources: app/api/task/route.ts:4-60, app/api/prs/route.ts:3-15
Default Values and Fallbacks
To ensure stability, the application provides fallback values for repository targeting if the environment variables are not explicitly set in the environment.
- Default Owner:
marekdkropiewnicki-dotcom - Default Repo:
GentelmeN-CorE
Sources: app/api/merge/route.ts:4-6, app/api/review/route.ts:4-6
Local Development Setup
For local development, the configuration is managed via a .env.local file. This file is excluded from version control to protect credentials.
- Initialization: Copy
.env.exampleto.env.local. - Configuration: Provide a GitHub PAT and a custom
ADMIN_TOKEN. - Execution: Running
npm run devloads these variables into the Next.js environment.
Sources: README.md:74-81
Conclusion
The Environment Configuration system serves as the backbone of GeNCorE's security and connectivity. By centralizing sensitive credentials in server-side variables and utilizing HMAC-based hashing for session management, the system provides a secure command center for AI agent management without exposing critical GitHub access tokens.
Sources: README.md:94-104