🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| .claude-flow/metrics | ||
| .github/workflows | ||
| .hive-mind | ||
| .husky | ||
| @mana-auth-mobile | ||
| apps | ||
| context | ||
| docs | ||
| packages/shared-types | ||
| patches | ||
| scripts | ||
| .env.example | ||
| .eslintrc.js | ||
| .gitignore | ||
| .npmrc | ||
| .prettierignore | ||
| .prettierrc | ||
| app.json | ||
| APPLE_REVIEW_FIXES.md | ||
| CHARACTER_SHARING_IMPLEMENTATION.md | ||
| CLAUDE.md | ||
| eas.json | ||
| IMAGE_MODEL_SELECTION_README.md | ||
| MAERCHENZAUBER_DATABASE_DOCUMENTATION.md | ||
| MANA_CORE_ARCHITECTURE.md | ||
| MANA_CORE_INTEGRATION_CHECKLIST.md | ||
| MANA_CORE_INTEGRATION_GUIDE.md | ||
| MANA_CORE_README.md | ||
| netlify.toml | ||
| package.json | ||
| QA_REPORT_STORY_TEXT_EDITING.md | ||
| README.md | ||
| STORY_TEXT_EDITING_TEST_PLAN.md | ||
| TILL_STARTING_MANUAL.md | ||
| tsconfig.json | ||
| UNIVERSAL_LINKS_SETUP.md | ||
Storyteller Project
A magical storytelling application that creates personalized children's stories with AI-generated characters and illustrations.
🚀 Quick Start
Prerequisites
- Node.js 18+ and pnpm 9+
- Install pnpm:
npm install -g pnpm - Supabase account and project
- Mana Core account for authentication
- AI API keys (Azure OpenAI, Gemini, Replicate)
Local Development Setup
-
Clone the repository
git clone <repository-url> cd storyteller-project -
Install dependencies
pnpm install -
Environment Configuration
Create
.envfiles in both backend and mobile apps:Backend (
apps/backend/.env):# Server Configuration NODE_ENV=development PORT=3002 # Mana Core Configuration MANA_SERVICE_URL=https://mana-core-middleware-dev-55965480161.europe-west3.run.app APP_ID=6c12c767-1f96-461c-b2df-93d5f9c0f063 SERVICE_KEY=your-service-key SIGNUP_REDIRECT_URL=http://localhost:8081 # Supabase Configuration MAERCHENZAUBER_SUPABASE_URL=your-supabase-url MAERCHENZAUBER_SUPABASE_ANON_KEY=your-supabase-anon-key MAERCHENZAUBER_SUPABASE_SERVICE_ROLE_KEY=your-service-role-key # AI Services MAERCHENZAUBER_AZURE_OPENAI_ENDPOINT=your-azure-endpoint MAERCHENZAUBER_AZURE_OPENAI_KEY=your-azure-key MAERCHENZAUBER_GOOGLE_GENAI_API_KEY=your-gemini-key MAERCHENZAUBER_REPLICATE_API_KEY=your-replicate-token # Storage MAERCHENZAUBER_STORAGE_BUCKET=maerchenzauberMobile (
apps/mobile/.env):# For local development EXPO_PUBLIC_STORYTELLER_BACKEND_URL=http://localhost:3002 # For production # EXPO_PUBLIC_STORYTELLER_BACKEND_URL=https://storyteller-backend-111768794939.europe-west3.run.app # Required for expo-router EXPO_ROUTER_APP_ROOT=app -
Start the services
You'll need two terminal windows:
Terminal 1 - Backend:
cd apps/backend npm run devThe backend will start on http://localhost:3002
Terminal 2 - Mobile:
cd apps/mobile npm run devThe Expo development server will start on http://localhost:8081
-
Access the application
- iOS Simulator: Press
iin the Expo terminal - Android Emulator: Press
ain the Expo terminal - Physical device: Scan the QR code with Expo Go app
- Web browser: Press
w(experimental)
- iOS Simulator: Press
📱 Testing on Physical Devices
iOS Physical Device
-
Find your computer's IP address:
ifconfig | grep "inet " | grep -v 127.0.0.1 -
Update
apps/mobile/.env:EXPO_PUBLIC_STORYTELLER_BACKEND_URL=http://YOUR_IP_ADDRESS:3002 -
Restart the mobile app and scan the QR code with Expo Go
Android Physical Device
- Make sure your device and computer are on the same network
- Follow the same steps as iOS
🏗️ Project Structure
storyteller-project/
├── apps/
│ ├── backend/ # NestJS backend API
│ │ ├── src/
│ │ │ ├── auth/ # Authentication proxy
│ │ │ ├── character/# Character management
│ │ │ ├── story/ # Story generation
│ │ │ ├── core/ # Core services & prompts
│ │ │ ├── health/ # Health checks
│ │ │ ├── credits/ # Credits management
│ │ │ ├── settings/ # User settings
│ │ │ └── supabase/ # Database integration
│ │ └── ...
│ ├── mobile/ # React Native Expo app
│ │ ├── app/ # App routes (expo-router)
│ │ ├── src/ # Source code
│ │ │ ├── components/
│ │ │ ├── services/
│ │ │ ├── hooks/
│ │ │ └── utils/
│ │ └── ...
│ ├── landing/ # Astro landing page
│ └── web/ # SvelteKit web app
├── packages/
│ └── shared-types/ # Shared TypeScript types
└── turbo.json # Turborepo configuration
🛠️ Available Scripts
Root Level (Turborepo)
pnpm run dev- Start all services in development modepnpm run build- Build all applicationspnpm run clean- Clean all node_modules and build artifactspnpm run type-check- Run TypeScript checks on all packagespnpm run lint- Lint all packagespnpm run format- Format code with Prettier
Backend (apps/backend/)
pnpm run dev- Start in watch mode (port 3002)pnpm run build- Build for productionpnpm run start:prod- Start production buildpnpm run test- Run testspnpm run test:watch- Run tests in watch modepnpm run test:cov- Run tests with coveragepnpm run lint- Lint backend code
Mobile (apps/mobile/)
pnpm run dev- Start Expo development serverpnpm run ios- Run on iOS simulatorpnpm run android- Run on Android emulatorpnpm run web- Run in web browserpnpm run build- Create production buildpnpm run preview- Preview production build
Landing Page (apps/landing/)
pnpm run dev- Start Astro dev serverpnpm run build- Build static sitepnpm run preview- Preview production build
Web App (apps/web/)
pnpm run dev- Start SvelteKit dev serverpnpm run build- Build production bundlepnpm run preview- Preview production build
🔧 Troubleshooting
Backend Issues
Backend won't start:
- Check if port 3002 is available:
lsof -i :3002 - Kill existing process:
kill -9 $(lsof -t -i:3002) - Verify all environment variables are set correctly
- Check database connections (Supabase, Mana Core)
SupabaseProvider dependency error:
- Ensure CommonModule is imported in AppModule
- Check that all modules are properly exported
Mobile App Issues
Can't connect to backend:
- Ensure backend is running on port 3002
- Check
EXPO_PUBLIC_STORYTELLER_BACKEND_URLin.env - For physical devices, use computer's IP address instead of localhost
- Check firewall settings allow connections on port 3002
Metro bundler issues:
- Clear cache:
npx expo start -c - Reset Metro bundler:
npx expo start --clear - Delete node_modules and reinstall:
rm -rf node_modules && npm install
Expo development server issues:
- Kill existing Expo processes:
pkill -f "expo start" - Check port 8081 availability:
lsof -i :8081 - Try different port:
npx expo start --port 8082
Landing Page Issues
Build errors with @rolldown/pluginutils:
cd apps/landing
npm install @rolldown/pluginutils
General Issues
TypeScript errors:
- Build all packages:
pnpm run buildfrom root - Check types:
pnpm run type-check - Ensure VSCode uses workspace TypeScript version
Dependency issues:
- Clear all caches:
pnpm run clean - Reinstall:
rm -rf node_modules pnpm-lock.yaml && pnpm install - Update dependencies:
pnpm update
📊 Health Monitoring
Backend Health Check
# Full health check
curl http://localhost:3002/health | jq
# Readiness check (for deployments)
curl http://localhost:3002/health/ready | jq
# Liveness check (for container orchestration)
curl http://localhost:3002/health/live | jq
Expected healthy response:
{
"status": "healthy",
"timestamp": "2025-01-09T21:16:58.017Z",
"duration": 213,
"services": [
{
"name": "supabase",
"status": "healthy",
"responseTime": 146
},
{
"name": "mana-service",
"status": "healthy",
"responseTime": 67
},
{
"name": "ai-services",
"status": "healthy",
"responseTime": 0,
"metadata": {
"gemini": "configured",
"replicate": "configured"
}
}
],
"version": "0.0.1",
"environment": "development"
}
🚢 Deployment
Backend Deployment (Google Cloud Run)
-
Build Docker image:
cd apps/backend docker build -t storyteller-backend . -
Test locally:
docker run -p 3002:3002 --env-file .env storyteller-backend -
Deploy to Cloud Run:
gcloud builds submit --tag gcr.io/PROJECT_ID/storyteller-backend gcloud run deploy storyteller-backend \ --image gcr.io/PROJECT_ID/storyteller-backend \ --region europe-west3 \ --platform managed \ --allow-unauthenticated \ --set-env-vars-from-file .env.production
Mobile Deployment (EAS Build)
-
Configure EAS:
cd apps/mobile eas build:configure -
Build for iOS:
eas build --platform ios --profile production -
Build for Android:
eas build --platform android --profile production -
Submit to stores:
eas submit --platform ios eas submit --platform android
🔐 Security
- Never commit
.envfiles - Use environment-specific configurations
- Rotate API keys regularly
- Use least-privilege principle for service accounts
- Enable CORS only for trusted origins
- Implement rate limiting in production
📝 API Documentation
The backend exposes the following main endpoints:
Authentication
POST /auth/signin- Sign in with email/passwordPOST /auth/signup- Create new accountPOST /auth/google-signin- Sign in with GooglePOST /auth/apple-signin- Sign in with ApplePOST /auth/refresh- Refresh access tokenPOST /auth/logout- Log out user
Characters
GET /character- Get user's charactersGET /character/:id- Get specific characterPOST /character/generate-images- Generate character imagesPOST /character/generate-animal- Generate animal characterPUT /character/:id- Update characterDELETE /character/:id- Delete character
Stories
GET /story- Get user's storiesGET /story/:id- Get specific storyPOST /story- Create new storyPOST /story/animal- Create animal storyPUT /story/:id- Update storyDELETE /story/:id- Delete story
Settings
GET /settings/user- Get user settingsPUT /settings/user- Update user settingsGET /settings/app- Get app configurationGET /settings/features- Get feature flagsGET /settings/creators- Get available creatorsGET /settings/languages- Get supported languagesGET /settings/themes- Get available themes
Credits
GET /credits/balance- Get credit balanceGET /credits/history- Get transaction historyPOST /credits/check- Check credit availabilityPOST /credits/consume- Consume creditsGET /credits/packages- Get available packages
🤝 Contributing
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes
- Run tests:
npm run test - Lint code:
npm run lint - Format code:
npm run format - Commit:
git commit -m 'Add amazing feature' - Push:
git push origin feature/amazing-feature - Open a Pull Request
📧 Support
For issues and questions, please contact the development team or create an issue in the repository.
📄 License
Private repository - All rights reserved