create-automaticgpt-template
Version:
AutomaticGPT - A production-ready Expo template with AI chat, authentication, conversation management, analytics, and sharing features
295 lines (212 loc) • 6.14 kB
Markdown
This guide walks you through setting up the {Feature Name} feature in your Expo template project.
Before setting up this feature, ensure you have:
- ✅ Completed [initial project setup](../SETUP.md)
- ✅ Node.js v18+ installed
- ✅ Expo CLI installed
- ✅ [Required dependency features enabled] (if applicable)
```json
{
"dependencies": {
"required-package": "^1.0.0",
"another-package": "^2.0.0"
}
}
```
```bash
npm install required-package another-package
yarn add required-package another-package
```
Add these variables to your `.env.local` file:
```bash
EXPO_PUBLIC_ENABLE_{FEATURE}=true
{FEATURE}_API_KEY=your_api_key_here
{FEATURE}_SECRET=your_secret_here
EXPO_PUBLIC_{FEATURE}_OPTION=value
EXPO_PUBLIC_{FEATURE}_DEBUG=false
```
1. 🌐 Go to [Service Provider](https://service-provider.com)
2. 📝 Create an account or sign in
3. 🔑 Generate API credentials
4. 💳 Set up billing (if required)
#### API Key Configuration
1. **Get your API key:**
- Navigate to your service dashboard
- Go to Settings > API Keys
- Click "Create New Key"
- Copy the generated key
2. **Add to environment:**
```bash
{FEATURE}_API_KEY=sk-your-actual-api-key-here
```
3. **Verify permissions:**
- Ensure your API key has required permissions
- Test with a simple API call
```typescript
// src/config/features.ts
export const {FEATURE}_CONFIG = {
enabled: process.env.EXPO_PUBLIC_ENABLE_{FEATURE} === 'true',
apiKey: process.env.{FEATURE}_API_KEY,
debug: process.env.EXPO_PUBLIC_{FEATURE}_DEBUG === 'true',
// Additional options
};
```
```typescript
// Custom configuration object
const advancedConfig = {
timeout: 5000,
retryAttempts: 3,
enableLogging: true,
customEndpoint: 'https://api.custom.com',
};
```
This feature is controlled by feature flags in [`src/config/features.ts`](../../src/config/features.ts):
```typescript
export const FEATURES = {
enable{Feature}: process.env.EXPO_PUBLIC_ENABLE_{FEATURE} === 'true',
// Related flags
enableAuth: process.env.EXPO_PUBLIC_ENABLE_AUTH === 'true', // If required
} as const;
```
This feature requires these other features to be enabled:
```bash
EXPO_PUBLIC_ENABLE_AUTH=true
EXPO_PUBLIC_ENABLE_STORAGE=true
EXPO_PUBLIC_ENABLE_ANALYTICS=true
```
```bash
npm run start
```
```typescript
// Test in your app component
import { useFeature } from '@/features/{feature-name}';
export function TestComponent() {
const { isEnabled, status } = useFeature();
return (
<View>
<Text>Feature Enabled: {isEnabled ? 'Yes' : 'No'}</Text>
<Text>Status: {status}</Text>
</View>
);
}
```
```typescript
// Basic functionality test
import { testFeature } from '@/features/{feature-name}';
const runTest = async () => {
try {
const result = await testFeature();
console.log('✅ Feature test passed:', result);
} catch (error) {
console.error('❌ Feature test failed:', error);
}
};
```
**"Feature not enabled" error**
```bash
echo $EXPO_PUBLIC_ENABLE_{FEATURE}
```
**"API key invalid" error**
```bash
echo ${FEATURE}_API_KEY
```
**"Dependencies missing" error**
```bash
rm -rf node_modules package-lock.json
npm install
npx expo start --clear
```
```typescript
// Add to your app to debug configuration
import { config } from '@/config';
console.log('Feature Config:', {
enabled: config.features.enable{Feature},
hasApiKey: !!config.{feature}.apiKey,
environment: config.app.environment,
});
```
```bash
curl -H "Authorization: Bearer ${FEATURE}_API_KEY" \
https://api.service.com/test
```
```bash
cd ios && pod install && cd ..
```
```json
// android/app/build.gradle (if needed)
android {
// Android specific configuration
}
```
```bash
```
- 🔐 **Never commit API keys** to version control
- 🌍 **Use environment variables** for sensitive data
- 🔄 **Rotate API keys** regularly
- 📝 **Follow service provider security guidelines**
```bash
{FEATURE}_API_KEY=sk-real-key-here
const apiKey = 'sk-real-key-here';
```
After setup is complete:
1. 📖 Read the [feature documentation](./README.md)
2. 🎯 Follow the [usage guide](./usage.md)
3. 🔍 Check the [API reference](../api/{feature-name}.md)
4. 🏗️ Start building with the feature!
If you encounter issues:
1. 📖 Check this setup guide thoroughly
2. 🔍 Review the [troubleshooting section](./troubleshooting.md)
3. 🔎 Search existing [GitHub issues](../../issues)
4. 🆕 Create a new issue using the [Setup Help template](../../.github/ISSUE_TEMPLATE/setup_help.md)
---
**Setup Time:** ~10 minutes • **Difficulty:** Beginner