Development Setup Guide
Overviewβ
This guide provides step-by-step instructions for setting up the Toto ecosystem development environment.
π Project-Specific Setup: For detailed setup instructions for individual projects, see:
- Toto App Setup Guide - Main application setup
- Toto Backoffice Setup Guide - Backoffice setup
- Development Guide - Comprehensive development guide
Prerequisitesβ
Required Softwareβ
- Node.js: Version 18.0.0 or higher
- npm: Version 9.0.0 or higher (comes with Node.js)
- Git: Version 2.30.0 or higher
- Firebase CLI: Version 12.0.0 or higher
- Code Editor: VS Code recommended with extensions
System Requirementsβ
- RAM: Minimum 8GB, recommended 16GB
- Storage: Minimum 10GB free space
- OS: Windows 10+, macOS 10.15+, or Ubuntu 18.04+
Initial Setupβ
1. Clone Repositoryβ
git clone https://github.com/DataTom7/toto.git
cd toto
2. Install Dependenciesβ
# Install root dependencies
npm install
# Install dependencies for each project
cd toto-bo && npm install
cd ../toto-landing && npm install
cd ../toto-investors && npm install
cd ../toto-app && npm install
cd ../toto-ai-hub && npm install
cd ..
π Project-Specific Setup: For detailed setup instructions for individual projects, see:
- Toto App Setup Guide - Main application setup
- Toto Backoffice Setup Guide - Backoffice setup
3. Firebase Configurationβ
# Login to Firebase
firebase login
# Set up projects (if not already configured)
firebase projects:list
firebase use <project-id>
Environment Configurationβ
1. Create Environment Filesβ
# toto-bo
cp toto-bo/.env.example toto-bo/.env.local
# toto-landing
cp toto-landing/.env.example toto-landing/.env.local
# toto-investors
cp toto-investors/.env.example toto-investors/.env.local
2. Configure Environment Variablesβ
toto-bo (.env.local)β
# NextAuth Configuration
NEXTAUTH_SECRET=your_nextauth_secret_here
NEXTAUTH_URL=http://localhost:5000
# Firebase Configuration
NEXT_PUBLIC_FIREBASE_API_KEY=your_firebase_api_key
FIREBASE_WEB_API_KEY=your_firebase_web_api_key
FIREBASE_PROJECT_ID=your_project_id
FIREBASE_PRIVATE_KEY=your_private_key
FIREBASE_CLIENT_EMAIL=your_client_email
toto-landing (.env.local)β
# Google Analytics
NEXT_PUBLIC_GA_ID=G-9NMXQTSQT6
# Firebase Configuration
NEXT_PUBLIC_FIREBASE_API_KEY=your_firebase_api_key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_auth_domain
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_storage_bucket
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id
toto-investors (.env.local)β
# Google Analytics
NEXT_PUBLIC_GA_ID=G-7ZYW5LDG0T
# Firebase Configuration
NEXT_PUBLIC_FIREBASE_API_KEY=your_firebase_api_key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_auth_domain
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_storage_bucket
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id
Development Serversβ
1. Start Development Serversβ
toto-bo (Port 5000)β
cd toto-bo
npm run dev
URL: http://localhost:5000
toto-landing (Port 9001)β
cd toto-landing
npm run dev -- -p 9001
URL: http://localhost:9001
toto-investors (Port 9002)β
cd toto-investors
npm run dev -- -p 9002
URL: http://localhost:9002
2. Verify All Serversβ
Open your browser and verify:
http://localhost:5000- Backoffice (toto-bo)http://localhost:9001- Donor landing (toto-landing)http://localhost:9002- Investor landing (toto-investors)
Database Setupβ
1. Firestore Configurationβ
# Navigate to Firebase Console
# https://console.firebase.google.com
# Create collections:
# - users (for user management)
# - cases (for pet rescue cases)
2. Security Rulesβ
// Firestore security rules for investors collection
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /investors/{investorId} {
allow read, write: if request.auth != null &&
(request.auth.token.role == 'admin' ||
request.auth.token.role == 'staff');
}
}
}
3. Indexesβ
Create the following Firestore indexes:
investorscollection:email(unique)investorscollection:status+createdAt(composite)investorscollection:type+createdAt(composite)
Development Workflowβ
1. Code Structureβ
toto/
βββ toto-bo/ # Backoffice application
β βββ src/
β β βββ app/ # Next.js app router
β β βββ components/ # React components
β β βββ lib/ # Utilities and services
β β βββ types/ # TypeScript interfaces
β βββ server.js # Custom server
βββ toto-landing/ # Donor landing page
β βββ src/
β β βββ app/ # Next.js app router
β β βββ components/ # React components
β β βββ lib/ # Utilities
βββ toto-investors/ # Investor landing page
β βββ src/
β β βββ app/ # Next.js app router
β β βββ components/ # React components
β β βββ lib/ # Utilities
βββ toto-docs/ # Documentation
2. Development Commandsβ
Buildingβ
# toto-bo
cd toto-bo && npm run build
# toto-landing
cd toto-landing && npm run build
# toto-investors
cd toto-investors && npm run build
Testingβ
# Run tests (if configured)
npm test
# Run linting
npm run lint
# Run type checking
npm run type-check
Development Toolsβ
# Start all servers concurrently
npm run dev:all
# Build all projects
npm run build:all
# Deploy to development
npm run deploy:dev
π Related Resourcesβ
- Toto App Setup - Main application setup
- Toto Backoffice Setup - Backoffice setup
- Development Guide - Comprehensive development guide
- Testing Guide - Testing documentation
- Seeding System - Database seeding
Common Issues & Solutionsβ
1. Port Conflictsβ
# Check what's using a port
netstat -ano | findstr :5000
# Kill process using port
taskkill /PID <process_id> /F
2. Firebase Authentication Issuesβ
# Re-authenticate Firebase
firebase logout
firebase login
# Check project configuration
firebase projects:list
firebase use <project-id>
3. Environment Variable Issuesβ
# Verify environment files exist
ls -la .env*
# Check variable loading
echo $NEXTAUTH_SECRET
4. Database Connection Issuesβ
# Verify Firestore rules
firebase deploy --only firestore:rules
# Check security rules in Firebase Console
# https://console.firebase.google.com/project/<project-id>/firestore/rules
Performance Optimizationβ
1. Development Performanceβ
# Use development mode
NODE_ENV=development npm run dev
# Enable Fast Refresh
FAST_REFRESH=true npm run dev
# Optimize TypeScript compilation
npm run dev -- --turbo
2. Build Optimizationβ
# Analyze bundle size
npm run build -- --analyze
# Optimize images
npm run build -- --optimize-images
# Enable compression
npm run build -- --compress
Deployment Preparationβ
1. Environment Variablesβ
# Production environment
cp .env.local .env.production
# Update production values
NEXTAUTH_URL=https://bo.betoto.pet
NEXT_PUBLIC_FIREBASE_API_KEY=prod_key
2. Build Verificationβ
# Build all projects
npm run build:all
# Verify build outputs
ls -la toto-bo/.next
ls -la toto-landing/.next
ls -la toto-investors/.next
3. Firebase Configurationβ
# Update firebase.json for production
firebase use production
# Deploy to production
firebase deploy
Development Best Practicesβ
1. Code Qualityβ
- Use TypeScript for all new code
- Follow ESLint rules
- Write meaningful commit messages
- Test components before committing
2. Git Workflowβ
# Create feature branch
git checkout -b feature/new-feature
# Make changes and commit
git add .
git commit -m "feat: add new feature"
# Push and create PR
git push origin feature/new-feature
3. Component Developmentβ
- Use functional components with hooks
- Implement proper TypeScript interfaces
- Follow component naming conventions
- Use proper error boundaries
4. API Developmentβ
- Implement proper error handling
- Use consistent response formats
- Add input validation
- Implement rate limiting
Monitoring & Debuggingβ
1. Development Toolsβ
- React DevTools: Browser extension for React debugging
- Redux DevTools: For state management debugging
- Network Tab: Monitor API calls
- Console: Check for errors and warnings
2. Loggingβ
// Add logging to components
console.log('Component rendered:', props);
// Add logging to API endpoints
console.log('API called:', request.body);
// Add error logging
console.error('Error occurred:', error);
3. Performance Monitoringβ
// Measure component render time
console.time('Component render');
// ... component logic
console.timeEnd('Component render');
// Monitor API response times
const start = performance.now();
const response = await fetch('/api/investors');
const end = performance.now();
console.log(`API call took ${end - start}ms`);
Support & Resourcesβ
1. Documentationβ
2. External Resourcesβ
3. Team Supportβ
- Development Team: Through toto-bo system
- Technical Issues: GitHub repository issues
- Feature Requests: Project management system
Last Updated: January 2024
Version: 2.0.0
Status: Production Ready