Native Device APIs
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The Driveway Estimator Pro application leverages native device APIs to bridge the gap between web-based logic and physical hardware capabilities. By utilizing Capacitor as a cross-platform bridge, the application accesses hardware features such as the camera for capturing site photos and GPS for location-based material pricing. These native integrations are essential for the "Capture → Measure → Estimate" workflow that defines the core value proposition of the software.
The architecture relies on specific Capacitor plugins to expose native functionality to the React frontend, ensuring that homeowners and contractors can perform field measurements with high precision using sensors typically unavailable to standard web applications.
Sources: MOBILE_BUILD.md:3-8, README.md:38-42, todo.md:105-108
Architecture and Infrastructure
The project uses a hybrid architecture where Capacitor wraps the React web application into native iOS and Android containers. This allows the use of standard web technologies while providing a communication layer to native SDKs.
Native Bridge Flow
The following diagram illustrates how the frontend communicates with native hardware through the Capacitor bridge:
The flow ensures that hardware responses (like a photo or coordinates) are passed back to the web layer for processing, such as AI edge detection or ZIP code lookup.
Sources: MOBILE_BUILD.md:14-25, README.md:46-59
Core Native Integrations
Camera and Image Processing
The application utilizes @capacitor/camera to handle driveway photography. This API is used for both real-time capture and accessing the device's photo library. Once a photo is captured, the path is handled by the backend to perform AI-based boundary detection.
| Component | Functionality | Native Requirement |
|---|---|---|
| Capture Component | Provides UI for taking driveway photos | NSCameraUsageDescription (iOS), CAMERA (Android) |
| Photo Upload | Transfers native file paths to S3 storage | Network Access |
| Fallback | Allows desktop testing via standard file upload | Browser File API |
Sources: MOBILE_BUILD.md:144-150, todo.md:27-30, README.md:10-11
Geolocation and Regional Pricing
The @capacitor/geolocation plugin identifies the user's GPS coordinates to facilitate local pricing lookups. While the database stores zipCode as a string, the native API provides latitude and longitude which are then processed via reverse geocoding services.
LiDAR and Depth Sensing (Roadmap)
The project identifies the use of LiDAR sensors on compatible devices (such as iPhone Pro) as a critical enhancement for manual depth input. Currently, depth is a manual input stored in the projects table, but native integration is planned to automate this via Capacitor.
Sources: todo.md:31, todo.md:79, drizzle/schema.ts:59
Configuration and Permissions
Native APIs require explicit user permission and manifest configuration to function correctly in the production environment.
Android Manifest
Native permissions for Android are defined in android/app/src/main/AndroidManifest.xml.
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Sources: MOBILE_BUILD.md:164-168
iOS Info.plist
Permissions for iOS are defined with usage descriptions in ios/App/App/Info.plist.
<key>NSCameraUsageDescription</key>
<string>We need camera access to capture driveway photos</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>We need your location to provide accurate local pricing</string>
Sources: MOBILE_BUILD.md:156-160
Data Persistence and Native Logging
The application includes a specialized debug-collector.js that intercepts native-level events and network requests to facilitate remote debugging. This collector captures user interactions and network failures that occur within the native webview.
Key fields captured by the native collector:
- Viewport Details:
width,height(for responsive adjustment) - Network Requests: Intercepts
fetchandXHRfor native API debugging - UI Events: Clicks, scrolls, and navigation within the native container
Sources: client/public/manus/debug-collector.js:141-150, client/public/manus/debug-collector.js:255-265
Conclusion
The Native Device APIs in Driveway Estimator Pro provide the necessary hardware access to transform a standard web app into a functional field tool. By abstracting Camera and Geolocation through Capacitor, the system maintains a unified codebase while leveraging high-precision native sensors for accurate driveway measurements and pricing. Future iterations will further this integration by incorporating LiDAR sensor data for automated depth calculations.