Transform ordinary objects into extraordinary tales with AI-powered mystical lore generation
Lore Generator is an iOS app that uses computer vision and AI to create fantasy-style backstories for any object you photograph. Point your camera at everyday items and discover their hidden mystical origins!
- ๐ธ Camera Integration: Take photos directly or choose from photo library
- ๐ฎ AI-Powered Lore: Generate fantasy backstories using LLaVA vision-language model
- ๐ฑ Beautiful UI: Fantasy-themed interface with scroll and star iconography
- ๐พ Local Storage: Save and browse your collection of enchanted objects
- ๐ Privacy-First: All data stored locally on your device
- SwiftUI interface with modern iOS design patterns
- Core Data for local storage of lore objects
- PhotosPicker and UIImagePickerController for image capture
- Fantasy-themed UI with custom styling and animations
- HTTP API communication with local LLaVA server
- Multipart form uploads for image processing
- JSON response parsing for lore text
- Graceful error handling with fallback mock responses
The Lore Generator API is a lightweight proxy service that orchestrates AI-powered lore generation through a multi-step process:
The iOS app sends a multipart/form-data POST request containing a JPEG image to:
http://YOUR_SERVER_IP:3001/generate-lore
The proxy receives the image and forwards it to a locally hosted LLaVA server:
http://YOUR_SERVER_IP:11434/api/generate
- Image is converted to base64 format
- Sent with prompt: "Describe this image in vivid, creative detail."
- LLaVA responds with a detailed caption
The caption is then processed through a fantasy lore prompt:
"Generate a fantasy item lore based on this description: [caption]"
- Produces stylized fantasy-style stories and item descriptions
- Creates mystical backstories for ordinary objects
The final lore is returned to the iOS app as JSON:
{
"lore": "In the heart of the Elderwood Forest, this ancient artifact..."
}- Backend Framework: FastAPI (Python)
- Image Captioning: LLaVA (Locally hosted vision-language model)
- Lore Generation: LLM (Qwen-1.5, LLaMA, or other GGUF-compatible models)
- Networking: URLSession in Swift with multipart/form-data
- Image Processing: Base64 encoding for API communication
- Language: Swift 5.9+
- Framework: SwiftUI + UIKit bridges
- Database: Core Data
- Networking: URLSession with async/await
- Image Processing: UIImage + JPEG compression
- Deployment: iOS 16.0+
ContentView.swift- Main interface and navigationLoreService.swift- Network service for API communicationImagePicker.swift- Camera and photo library integrationLoreDisplayView.swift- Fantasy-themed lore presentationPersistence.swift- Core Data stack management
LoreObject {
id: UUID
imageData: Data
loreText: String
objectName: String?
timestamp: Date
}- Xcode 15.0+
- iOS 16.0+ device or simulator
- LLaVA server running at specified IP (for real AI generation)
- Clone the repository
- Configure Server IP: Replace
YOUR_SERVER_IPin these files with your actual server IP:Lore Generator/LoreService.swift(line 12)Lore Generator/Lore-Generator-Info.plist(in NSExceptionDomains)
- Open
Lore Generator.xcodeprojin Xcode - Configure your target device
- Build and run!
For full AI functionality, deploy the complete backend stack:
# Deploy FastAPI proxy server at YOUR_SERVER_IP:3001
# Handles image upload and orchestrates AI pipeline# Configure LLaVA model endpoint at YOUR_SERVER_IP:11434
# Provides image captioning capabilities# Set up GGUF-compatible model (Qwen-1.5, LLaMA, etc.)
# Generates fantasy lore from captions- Replace
YOUR_SERVER_IPwith your actual server IP address in both:LoreService.swift(iOS app)Info.plist(ATS configuration)
- Ensure all services are accessible on local network
- Verify port 3001 (API) and 11434 (LLaVA) are open
- Camera Permission: Required for photo capture
- Photo Library Permission: Required for image selection
- No Data Collection: All processing happens locally or on your specified server
The API uses HTTP (not HTTPS) for local network communication. iOS requires explicit configuration to allow HTTP traffic:
Required in Info.plist to enable HTTP connections to local server:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>YOUR_SERVER_IP</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>โ ๏ธ HTTP Only: Suitable for local network development- ๐ Local Network: All communication stays within your network
- ๐ No External Data: Images and lore remain on your devices/servers
- ๐ก๏ธ Privacy-First: No telemetry or data collection
The app embraces a fantasy aesthetic with:
- ๐งโโ๏ธ Mystical loading messages ("Consulting the Ancient Texts...")
- ๐ Scroll-based visual metaphors
- โญ Star iconography for favorites and highlights
- ๐จ Warm color palette with orange accents
- ๐ Dark mode compatibility
Comprehensive logging is implemented throughout the app for debugging:
- ๐ฏ User interaction tracking
- ๐ธ Image processing pipeline
- ๐ Network request/response cycles
- ๐พ Core Data operations
- ๐ State management transitions
- Graceful degradation with mock responses during development
- User-friendly error messages
- Automatic retry mechanisms for network failures
- Comprehensive input validation
This is a personal project, but suggestions and improvements are welcome!
This project is for educational and personal use.
Built with โค๏ธ and a touch of magic โจ