Skip to content

WYlim1003/CaptureYourLife

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CaptureYourLife - Complete Setup & Development Guide

🎯 Project Overview

CaptureYourLife is an AI-powered mobile app that transforms photos into stickers and avatars using real AI models. Built with Flutter (frontend) + FastAPI (backend) + Firebase + Replicate AI.


πŸ“‹ Prerequisites

Global Requirements

  • Python 3.10+
  • Flutter SDK (>=3.0.0)
  • Dart SDK (>=3.0.0)
  • Git
  • A Replicate API account (https://replicate.com)
  • A Firebase project

API Keys Needed

  1. Replicate API Token - Get from https://replicate.com/account
  2. Firebase Project Credentials - Create at https://firebase.google.com

πŸš€ Backend Setup (FastAPI)

Step 1: Navigate to Backend

cd CaptureYourLife/backend

Step 2: Create Virtual Environment

# Windows
python -m venv venv
venv\Scripts\activate

# macOS/Linux
python3 -m venv venv
source venv/bin/activate

Step 3: Install Dependencies

pip install -r requirements.txt

Step 4: Configure Environment

# Copy example to actual .env
cp .env.example .env

# Edit .env with your values
# - REPLICATE_API_TOKEN: Your Replicate API token
# - FIREBASE_PROJECT_ID: Your Firebase project ID
# - FIREBASE_PRIVATE_KEY: Your Firebase private key (JSON escaped)
# - FIREBASE_CLIENT_EMAIL: Your Firebase client email
# - SECRET_KEY: Generate a random secret key

Step 5: Run Backend Server

python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload

The backend will be available at http://localhost:8000

API Documentation

Once running, visit http://localhost:8000/docs for interactive API docs.


πŸ“± Frontend Setup (Flutter)

Step 1: Navigate to Frontend

cd CaptureYourLife/frontend

Step 2: Install Dependencies

flutter pub get

Step 3: Configure Environment

# Copy example to actual .env
cp .env.example .env

# Edit .env with your Firebase credentials

Step 4: Update Firebase Options

Edit lib/config/firebase_options.dart with your Firebase project details:

static FirebaseOptions get currentPlatform {
  return FirebaseOptions(
    apiKey: 'YOUR_FIREBASE_API_KEY',
    appId: 'YOUR_FIREBASE_APP_ID',
    messagingSenderId: 'YOUR_MESSAGING_SENDER_ID',
    projectId: 'YOUR_PROJECT_ID',
    storageBucket: 'YOUR_STORAGE_BUCKET',
  );
}

Step 5: Run Flutter App

# Run on Android emulator
flutter run -d emulator-5554

# Run on iOS simulator
flutter run -d ios

# Run on connected device
flutter run

πŸ—οΈ Project Structure

CaptureYourLife/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ main.py                 # FastAPI entry point
β”‚   β”‚   β”œβ”€β”€ config.py               # Configuration
β”‚   β”‚   β”œβ”€β”€ models.py               # Pydantic models
β”‚   β”‚   β”œβ”€β”€ dependencies.py         # Firebase & Auth
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.py             # Auth endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ images.py           # Image upload
β”‚   β”‚   β”‚   └── generation.py       # AI generation
β”‚   β”‚   └── services/
β”‚   β”‚       β”œβ”€β”€ ai_service.py       # Replicate API
β”‚   β”‚       └── firebase_service.py # Firebase ops
β”‚   β”œβ”€β”€ requirements.txt
β”‚   β”œβ”€β”€ .env.example
β”‚   └── .gitignore
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ main.dart               # App entry point
β”‚   β”‚   β”œβ”€β”€ config/                 # Configs
β”‚   β”‚   β”‚   β”œβ”€β”€ app_colors.dart
β”‚   β”‚   β”‚   β”œβ”€β”€ api_config.dart
β”‚   β”‚   β”‚   └── firebase_options.dart
β”‚   β”‚   β”œβ”€β”€ pages/                  # App screens
β”‚   β”‚   β”‚   β”œβ”€β”€ home_page.dart
β”‚   β”‚   β”‚   β”œβ”€β”€ camera_page.dart
β”‚   β”‚   β”‚   β”œβ”€β”€ editor_page.dart
β”‚   β”‚   β”‚   β”œβ”€β”€ preview_page.dart
β”‚   β”‚   β”‚   └── gallery_page.dart
β”‚   β”‚   β”œβ”€β”€ components/             # Reusable widgets
β”‚   β”‚   β”‚   β”œβ”€β”€ primary_button.dart
β”‚   β”‚   β”‚   β”œβ”€β”€ loading_spinner.dart
β”‚   β”‚   β”‚   β”œβ”€β”€ image_picker_widget.dart
β”‚   β”‚   β”‚   β”œβ”€β”€ style_selector.dart
β”‚   β”‚   β”‚   └── image_preview.dart
β”‚   β”‚   β”œβ”€β”€ services/               # Business logic
β”‚   β”‚   β”‚   β”œβ”€β”€ api_service.dart
β”‚   β”‚   β”‚   β”œβ”€β”€ auth_service.dart
β”‚   β”‚   β”‚   └── image_service.dart
β”‚   β”‚   β”œβ”€β”€ providers/              # Riverpod state
β”‚   β”‚   β”‚   β”œβ”€β”€ auth_provider.dart
β”‚   β”‚   β”‚   β”œβ”€β”€ image_provider.dart
β”‚   β”‚   β”‚   └── generation_provider.dart
β”‚   β”‚   └── assets/
β”‚   β”‚       β”œβ”€β”€ images/
β”‚   β”‚       └── icons/
β”‚   β”œβ”€β”€ pubspec.yaml
β”‚   β”œβ”€β”€ analysis_options.yaml
β”‚   β”œβ”€β”€ .env.example
β”‚   └── .gitignore
β”‚
└── README.md

πŸ”‘ API Endpoints

Authentication

  • POST /auth/register - Register new user
  • POST /auth/login - Login user

Images

  • POST /images/upload - Upload image
  • GET /images/{image_id} - Get image metadata

Generation

  • POST /generate/sticker - Generate sticker
  • POST /generate/avatar - Generate avatar
  • GET /generate/history - Get user's generation history

πŸ§ͺ Testing

Backend Testing with curl

# Register
curl -X POST "http://localhost:8000/auth/register" \
  -H "Content-Type: application/json" \
  -d '{"email":"test@example.com","password":"test123","username":"testuser"}'

# Login
curl -X POST "http://localhost:8000/auth/login" \
  -H "Content-Type: application/json" \
  -d '{"email":"test@example.com","password":"test123"}'

# Upload Image
curl -X POST "http://localhost:8000/images/upload" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -F "file=@path/to/image.jpg"

# Generate Sticker
curl -X POST "http://localhost:8000/generate/sticker" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"image_id":"YOUR_IMAGE_ID","style":"sticker"}'

Flutter Testing

# Run with debug output
flutter run -v

# Run tests
flutter test

# Build APK (Android)
flutter build apk

# Build IPA (iOS)
flutter build ios

🎨 App Flow

  1. Home Page - User sees menu with options
  2. Camera Page - User picks image from camera or gallery
  3. Editor Page - User selects generation type (sticker/avatar) and style
  4. Preview Page - User sees generated result
  5. Gallery Page - User views all past generations

πŸ”§ Environment Variables

Backend (.env)

FIREBASE_PROJECT_ID=your-project-id
FIREBASE_PRIVATE_KEY=your-private-key
FIREBASE_CLIENT_EMAIL=your-email
REPLICATE_API_TOKEN=your-token
APP_NAME=CaptureYourLife
DEBUG=True
SECRET_KEY=your-secret-key

Frontend (.env)

API_BASE_URL=http://localhost:8000
FIREBASE_API_KEY=your-key
FIREBASE_PROJECT_ID=your-project-id

πŸ“± Supported Platforms

  • βœ… Android (API 21+)
  • βœ… iOS (12.0+)
  • βœ… Web (Chrome, Firefox, Safari)
  • βœ… Windows, macOS, Linux

πŸ› Troubleshooting

Backend Issues

  • Port already in use: Change port in main.py or kill process on port 8000
  • Firebase auth error: Check credentials in .env file
  • Replicate API errors: Verify API token is correct and valid

Frontend Issues

  • Image picker not working: Check permissions in AndroidManifest.xml or Info.plist
  • API connection failed: Ensure backend is running and API_BASE_URL is correct
  • Build errors: Run flutter clean && flutter pub get

πŸ“š Key Dependencies

Backend

  • FastAPI - Web framework
  • Firebase Admin SDK - Database & auth
  • Replicate - AI model API
  • Pillow - Image processing
  • Pydantic - Data validation

Frontend

  • Flutter - UI framework
  • Riverpod - State management
  • Dio - HTTP client
  • Image Picker - Camera/Gallery access
  • Firebase - Database & auth

🚒 Deployment

Backend (Production)

  1. Set DEBUG=False in .env
  2. Generate strong SECRET_KEY
  3. Deploy to: Heroku, Railway, Render, or AWS
  4. Update Firebase security rules for production

Frontend

  1. Build release APK: flutter build apk --release
  2. Build release IPA: flutter build ios --release
  3. Submit to Google Play / App Store

πŸ“ Next Steps

  1. βœ… Run backend: python -m uvicorn app.main:app --reload
  2. βœ… Run frontend: flutter run
  3. βœ… Test auth flow (register/login)
  4. βœ… Test image upload & generation
  5. βœ… Test UI navigation
  6. πŸ”„ Customize colors in lib/config/app_colors.dart
  7. πŸ”„ Add more generation styles in ai_service.py
  8. πŸ”„ Implement social media sharing

πŸ“ž Support

For issues or questions:

  1. Check the troubleshooting section
  2. Review API docs at http://localhost:8000/docs
  3. Check Flutter logs: flutter logs
  4. Review backend logs in terminal

Happy Creating! πŸŽ‰

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors