Configuration & Environment
Relevant source files
The following files were used as context for generating this wiki page:
The Configuration & Environment of the pcstyledev project encompasses the management of API keys, environment variables, local path configurations, and canonical data structures. The system is split between a frontend/backend portfolio application and a specialized CLI tool (projects-cli) used for managing project metadata.
The environment utilizes a dual-loading strategy for configurations, pulling from standard system environment variables and local .env.local files. This ensures that sensitive credentials for external services like Google Gemini, WakaTime, and GitHub are handled securely across different execution contexts, including the Edge Runtime for API routes and local environments for CLI operations.
Environment Variables & API Keys
The system relies on several critical environment variables to interface with external APIs and locate local repository data. These are validated at runtime to ensure system stability.
Core Environment Variables
| Variable | Description | Source File |
|---|---|---|
GEMINI_API_KEY | Key for Google Gemini AI analysis of projects. | projects-cli/src/utils/config.ts |
WAKATIME_API_KEY | Key for fetching coding statistics and status. | api/index.ts |
GITHUB_TOKEN | Token for accessing GitHub GraphQL and REST APIs. | api/index.ts |
GITHUB_USERNAME | The target username for GitHub statistics. | api/index.ts |
PCSTYLE_REPO_PATH | Local path to the repository for CLI operations. | projects-cli/src/utils/config.ts |
Sources: projects-cli/src/utils/config.ts:6-42, api/index.ts:20-25
Local Environment Loading
For CLI operations, a custom loader searches for .env.local files in multiple hierarchical locations:
- The defined
REPO_PATH. - The directory above the CLI source code.
- The current working directory.
Sources: projects-cli/src/utils/config.ts:13-33
API Configuration & Edge Runtime
The backend API is designed for the Vercel Edge Runtime, necessitating specific configuration and environment validation.
The API uses a global validation function validateEnv() to check for WAKATIME_API_KEY, GITHUB_TOKEN, and GITHUB_USERNAME. Specific routes use middleware to block requests if mandatory keys for those services are missing.
Sources: api/index.ts:18-28, api/index.ts:101-115
Canonical Data & Paths
The project maintains a strict "Canonical Stack" configuration to ensure consistency in project metadata. This is stored in data/projects/stack-canonical.json and referenced via absolute paths in the CLI.
Path Resolution
The CLI uses the homedir() utility to establish a default base path for the repository if PCSTYLE_REPO_PATH is not provided.
- Projects Data:
data/projects/projects.json - Stack Config:
data/projects/stack-canonical.json
Sources: projects-cli/src/utils/config.ts:6-10
Stack Configuration Structure
The environment enforces a specific schema for technology stacks to prevent label fragmentation.
| Field | Type | Description |
|---|---|---|
canonical | string[] | The master list of allowed technology labels. |
aliases | Record<string, string> | Mapping of common names to canonical labels (e.g., "NextJS" -> "Next.js"). |
glossary | Array | Descriptive metadata for each canonical entry. |
Sources: data/projects/stack-canonical.json:1-118, projects-cli/src/lib/stack.ts:6-16
AI Analysis Configuration
Project metadata is generated and normalized using Google Gemini. This requires a specific schema configuration to ensure the AI output matches the project's internal data types.
The AI environment is configured with a temperature of 0.3 and uses the gemini-2.5-flash model. It leverages a structured JSON response schema to ensure compatibility with the Project interface defined in the core library.
Sources: projects-cli/src/lib/gemini.ts:25-36, projects-cli/src/lib/gemini.ts:269-278, lib/types.ts:1-21
Conclusion
The Configuration & Environment of pcstyledev is built around high-availability API integration and structured metadata management. By utilizing Edge Runtime for the API and a robust CLI for repository management, the system maintains a consistent environment across development and production, governed by strict canonical definitions and secure environment variable handling.