Configuration Files
Chapi uses two main configuration files:appsettings.json
Application-wide settings including OAuth and app configuration
user.api.settings.json
User-specific API keys and preferences stored in AppData
Application Settings
Location:~/workspace/source/Chapi/appsettings.json
This file contains application-wide configuration that applies to all users.
App Configuration
Default Git repository URL for base templates or resources.Example:
https://gitlab.com/net-core2/api-base.gitGitHub repository URL for checking application updates.Example:
https://github.com/JPChanel/chapi-assistantGit Authentication Settings
See Git Authentication for detailed OAuth configuration.GitHub OAuth application credentials and settings
GitLab OAuth application credentials and settings
Example appsettings.json
appsettings.json
User Settings
Location:%AppData%/Chapi/user.api.settings.json
This file stores user-specific settings including API keys and preferences.
AI Provider Settings
See AI Providers for detailed AI configuration.Google AI API key for Gemini models
OpenAI API key for GPT models
Anthropic API key for Claude models
Your preferred AI provider. Options:
Gemini, OpenAI, ClaudeProxy Settings
Enable proxy for network connections
Proxy server URL (e.g.,
http://proxy.company.com:8080)Proxy authentication username
Proxy authentication password
GitHub Integration
Stored GitHub OAuth access token (managed by the application)
GitHub username (cached from authentication)
GitHub display name (cached from authentication)
GitHub avatar URL (cached from authentication)
Example user.api.settings.json
user.api.settings.json
Settings Management
TheUserSettingsService class handles loading and saving user settings:
UserSettingsService.cs
Features
Auto-Creation
Automatically creates
%AppData%/Chapi directory on first runGraceful Fallback
Returns default settings if file doesn’t exist or is corrupted
JSON Formatting
Saves settings with indentation for readability
Type Safety
Strongly-typed settings model with defaults
Configuration Priority
Chapi uses the following priority for settings:Environment-Specific Configuration
For development vs. production environments, you can use:Development
appsettings.Development.json
Production
appsettings.Production.json
.NET automatically merges environment-specific configuration files based on the
ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT variable.Accessing Settings in Code
Dependency Injection
Direct Access
Best Practices
Security
Never commit API keys or secrets to version control
Validation
Validate settings on load and provide meaningful error messages
Defaults
Always provide sensible default values
Documentation
Document all configuration options with examples
Security Recommendations
-
Use User Secrets for development:
-
Use Environment Variables for production:
- Encrypt Sensitive Data at rest using Windows DPAPI or similar
- Restrict File Permissions on configuration files
Troubleshooting
Settings not persisting
Settings not persisting
Possible causes:
- Insufficient permissions to write to
%AppData%/Chapi - File is locked by another process
- Disk space issues
- Check folder permissions
- Close other instances of the application
- Verify available disk space
Settings reset to defaults
Settings reset to defaults
Possible causes:
- Corrupted JSON in settings file
- File encoding issues
- Validate JSON syntax using a JSON validator
- Ensure file is UTF-8 encoded
- Restore from backup or recreate manually
Configuration not loading
Configuration not loading
Possible causes:
- Incorrect file path
- Missing configuration section
- Deserialization errors
- Verify file locations match expected paths
- Check console/logs for deserialization errors
- Compare with example configurations
Related Configuration
Git Authentication
Configure GitHub and GitLab OAuth
AI Providers
Configure Gemini, OpenAI, and Claude
Source Code Reference
- Settings Service:
~/workspace/source/Chapi/Infrastructure/Persistence/Settings/UserSettings.cs - App Configuration:
~/workspace/source/Chapi/appsettings.json - Git Auth Config:
~/workspace/source/Chapi/Infrastructure/Configuration/GitAuthConfig.cs