Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

LeafLens — iOS App

A SwiftUI iOS application for identifying plants by their leaves and assessing plant health. Point your camera at a leaf, and LeafLens will tell you what plant it is and how healthy it looks.

Features

  • Live Camera Capture — Real-time camera preview with permission handling
  • Plant Identification — Integrates with Plant.id API for species recognition
  • Health Assessment — Analyzes plant condition (good / caution / poor)
  • Care Plans — Generates step-by-step care recommendations
  • Dark Mode Support — Full light/dark theme support via Verdant design system

App Flow

Capture → Scan → Result → Care
  1. Capture — Take or select a photo of a leaf
  2. Scan — AI analysis in progress with loading states and error handling
  3. Result — Identified plant with confidence score, health status, and one-tap action
  4. Care — Numbered care timeline with personalized recommendations

Project Structure

LeafLens-iOS/
├── LeafLensApp.swift                 — App entry point
├── RootView.swift                 — Flow state machine (4-screen navigation)
├── Info.plist                     — Camera permission + font registration
├── Theme/
│   ├── VerdantTheme.swift         — Color palettes (light/dark) + typography
│   └── Color+Hex.swift            — Color(hex:) convenience initializer
├── Models/
│   ├── Plant.swift                — Plant data model + CareStep
│   └── HealthStatus.swift         — Health enum + display bundles
├── Services/
│   ├── PlantDetectionService.swift — Detection protocol + mock implementation
│   ├── PlantIdService.swift       — Plant.id v3 API integration
│   └── CameraController.swift     — AVCaptureSession wrapper
└── Views/
    ├── CaptureView.swift            — Camera preview + permission UI
    ├── ScanView.swift               — Analysis progress + retry states
    ├── ResultView.swift             — Plant hero card + health summary
    ├── CareView.swift               — Care timeline
    └── Components/
        ├── LeafPlate.swift          — Striped photo placeholder
        ├── TrafficLight.swift       — 3-lamp health badge
        ├── HealthBlock.swift        — Health display variants
        └── CameraPreview.swift      — UIViewRepresentable preview

Requirements

  • iOS 17+
  • Xcode 15+
  • Swift 5.9+
  • Plant.id API key (for production identification)

Getting Started

1. Clone the repository

git clone <repo-url>
cd leafsnap-app

2. Open in Xcode

Create a new SwiftUI iOS app project in Xcode, then drag the contents of LeafLens-iOS/ into your project.

3. Add required fonts

Add DM Serif Display (Regular + Italic) to your bundle:

  • Drop the .ttf files into the project
  • Register them under UIAppFonts in Info.plist
  • The app falls back to system fonts if DM Serif is unavailable

4. Configure API key (optional)

The app works out-of-the-box with mock data for testing. To enable real plant identification:

  1. Sign up at Plant.id for an API key
  2. Replace the mock detector in LeafLensApp.swift:
let apiKey = "your-api-key" // Use Keychain or remote config in production
let detector = PlantIdService(apiKey: apiKey)
StateObject(wrappedValue: FlowModel(detector: detector))

Security note: Never ship API keys in your binary. Use a backend proxy or remote configuration.

Architecture

  • MVVM PatternFlowModel owns navigation state; views are dumb and previewable
  • Protocol-Oriented ServicesPlantDetectionService protocol makes swapping APIs trivial
  • Theme System — All colors and typography centralized in VerdantTheme
  • SwiftUI Native — Uses .task, .animation, @StateObject, and other modern APIs

Known Limitations

  • Photo library picker is not yet implemented (library button in CaptureView is a no-op)
  • Front camera switching is not yet implemented
  • Share button on ResultView is not yet implemented
  • Care plan steps are currently hardcoded (should derive from detection results)
  • Push notifications for recheck reminders are not yet scheduled

License

Private repository — all rights reserved.

Acknowledgments

  • Plant identification powered by Plant.id
  • Design system: Verdant

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages