Building Nimby, a searchable camera roll that runs on your phone
You remember the name on a receipt you photographed, but you have no idea when you took the photo. The same gallery holds screenshots of products you meant to compare, documents you need once a month, and photos from a t
You remember the name on a receipt you photographed, but you have no idea when you took the photo. The same gallery holds screenshots of products you meant to compare, documents you need once a month, and photos from a trip you remember by place. Scrolling is a poor substitute for the detail you already know.
I built Nimby, an Android app that indexes the photos you choose and lets you search by details inside them. For a repeatable walkthrough, scan the sample receipt that says PINEAPPLE MARKET. Search for pineapple, open the original photo, check the matching text, and tap Keep. The same receipt can later surface as a reimbursement follow-up. Photo analysis and search run on the phone.
That receipt drives the architecture. The app needs to answer three questions throughout the flow. Which image can I still open? What evidence made it match? What has the user decided to do with it?
The architecture
The TypeScript UI handles navigation, permission prompts, query parsing, and results. NimbyGallery is a Kotlin Expo module that handles Android media access, inference, storage, and background work. The bridge passes IDs, URIs, state, and search results. Kotlin opens and decodes the source image, so it can run the photo pipeline without passing large bitmaps through JavaScript. Expo Modules API
1. Start with Androidβs media model
Nimby supports gallery access through MediaStore and individual selection through Androidβs photo picker. The selected-photo route lets someone try the app with a receipt before granting wider gallery access. Nimby also has to handle permission changes and photos that have been deleted or edited since the last scan. A database row can still exist after its URI stops resolving. Android photo picker
The database separates source from image. A source is a URI with metadata like its name, album, and version. An image row is keyed by a SHA-256 fingerprint of the bytes. Multiple sources can refer to the same image row. On a rescan, a known URI and version let the worker avoid reading the bytes for a new fingerprint. A new source with bytes the app has already seen can reuse the existing image analysis. The cache also checks the Eye engine version before reusing a completed result.
This condensed excerpt from ScanWorker.kt shows the cache check and the inference path.
val imageId = memory.knownImage(photo)
?: memory.attach(photo, fingerprint(uri))
if (memory.isCached(imageId)) {
if (!gallery.readable(uri)) {
throw IOException("Photo access has changed.")
}
// Reuse the analysis and record the item in this scan's history.
return
}
val bitmap = decodePhoto(context.contentResolver, uri)
try {
val output = infer(engine, bitmap)
memory.complete(imageId, mapEyeAnalysis(output))
} finally {
bitmap.recycle()
}
The worker records progress and per-photo errors and checks for cancellation between expensive operations. Completed results are stored as the scan runs, so stopping a scan leaves completed work available. An opt-in Auto-scan uses WorkManager once the user has completed a scan and granted gallery access. The user chooses a daily or weekly schedule and can constrain it to charging. Android decides when the work actually runs.
2. Index text and visual data for different jobs
Desert Ant Eye supplies categories, tags, quality scores, and embeddings. The project pins Eye SDK 4.3.0 and the v1.0.0 weights. The worker decodes a downscaled bitmap for Eye, then uses the result to decide which photos are eligible for Tesseract OCR. That second pass focuses on text-heavy images such as receipts, documents, and screenshots. OCR can finish after the initial classification, so the UI exposes indexing status and the query can be retried when text is ready. Eye SDK documentation
The OCR text lives in memory_details, keyed by image ID. SQLite triggers keep the full-text table synchronized when an image or its details change. The FTS4 schema in MemoryIndex.kt is small enough to read in one sitting.
CREATE VIRTUAL TABLE memory_search USING fts4(
labels, text, place, collection, tokenize=unicode61, prefix='2,3'
);
The FTS row uses the image ID as its docid. It combines structured fields with searchable text and includes Qwen tags when the user has approved and saved them. The app can update an OCR row or a collection in SQLite and let the triggers refresh the corresponding FTS row. SQLite FTS4 documentation
Visual similarity uses a separate path. Eye embeddings are validated and normalized to 512-dimensional unit vectors, then stored as 32-bit floats. Thatβs 2 KiB of vector data per image, before database overhead. The dot product of two normalized vectors gives their cosine similarity. Nimby uses that for reference-photo search and related-photo suggestions. Exact duplicates use the content fingerprint, and near-duplicate review uses visual similarity.
3. Return the reason a photo matched
Recall uses a deterministic parser in src/recallQuery.ts. It pulls out supported dates, photo categories, and place hints, then passes the remaining terms with the structured filters. For example, the query below produces electricity bill as the text to search.
import { parseRecallQuery } from './src/recallQuery';
const request = parseRecallQuery('find my electricity bill');
// {
// terms: 'electricity bill',
// category: null,
// date: null,
// place: null,
// textOnly: false
// }
Kotlin normalizes and bounds the query, extracts letters and numbers as tokens, quotes each token, and binds the resulting expression to memory_search MATCH ?. It ranks exact OCR phrases ahead of tag and place matches, then looks up an available source for each image. Dismissed results and archived copies are excluded from normal Recall. On eligible queries with sparse results and no OCR match, the engine can append suggestions from an Eye or Qwen scene-tag seed. Those suggestions carry distinct visual evidence.
The important part of the response is evidence. A result can include a short Photo text excerpt, an Eye tag, a Qwen tag, a category, or a place. In the receipt demo, seeing PINEAPPLE MARKET under the tile explains the result before you open the image. The app can also use recorded feedback to reorder results within the same evidence tier, giving the userβs past actions a say while preserving stronger matches ahead of weaker ones.
4. Give a found photo somewhere to go
I wanted the search result to stay useful after you close it. Keep records a local decision. Daily discoveries can resurface saved references. Timeline groups nearby captures into moments and can suggest highlights. The Photo Map uses opt-in EXIF location data and a bundled basemap. The same local index supports receipt and shopping follow-ups, including reminders you explicitly schedule.
Archive is reversible. It hides a source inside Nimby while the original stays in Androidβs gallery. After a 30-day eligibility window, permanent deletion is a separate review that requires the userβs confirmation and Androidβs system approval. The app rechecks the source version before asking Android to delete it. That matters if the photo changed after it was archived.
There are also two experiments in the sandbox build. Parallel uses rules and gallery evidence to compare possible next steps. Evolve records the choices and outcomes locally. Those outcomes can inform later suggestions. Keeping or dismissing a photo gives Discover a signal about what to surface next.
5. Draw the network boundary around specific actions
Nimby can scan and search locally available photos in airplane mode. The gallery index lives in Androidβs app-private storage. Optional features have their own network boundaries.
| Feature | What happens |
|---|---|
| Qwen Vision and Moonshine | Optional models download separately. Image follow-up suggestions and English voice transcription run on-device after installation. Qwen Vision is about 1.3 GB and requires a supported device with enough memory. |
| Find buying links | Opening the sheet can fetch a versioned public endpoint manifest from the landing site. When you confirm a product name, the app sends that text and an optional retailer filter. The source image and full OCR transcript stay on the phone. |
| License redemption | The demo sends the license key and activation details to Dodoβs sandbox. The phone stores the local license record encrypted with an Android Keystore-backed AES-GCM key. |
| Website | Amplify serves the static site. Tally handles beta signups and Dodo hosts sandbox checkout. |
For buying links, the request contract is deliberately small. The app shows the proposed name so you can edit it before sending it.
POST /product-search
Content-Type: application/json
{"query":"Sony WH-1000XM5","retailer":"amazon"}
The hosted route uses API Gateway β Lambda β Tavily. Lambda validates the request, reserves a slot in a shared daily DynamoDB counter with a conditional update, and reads the credential from Secrets Manager. The response filter checks for supported Indian retailers and product pages that match the requested terms. It drops obvious accessory, review, and duplicate links. Results can still be empty, and the app offers a Google search as another route. Availability and product variants are for the user to check on the retailerβs site.
Keeping the endpoint public and the credential server-side lets the static site publish just { version, endpoint } in product-search.json. The app validates the manifest before using it. The Amplify deploy script verifies both the published HTML and the manifest against the packaged build, so a landing redesign can be deployed with the existing retailer backend.
The license demo follows a separate flow. Dodo issues a key through sandbox checkout, the user enters it in Settings β License, and the app activates one installation and validates the activation against the configured product. It keeps the last successful verification locally for up to seven days. A user can release the installation before moving the key to another device. Core photo features work independently of the sandbox entitlement.
Run it locally
The project needs a native Android build because it links the Kotlin media module and native model runtimes. Start with the JDK, Android SDK, model assets, and local signing instructions in the setup guide. Fresh setup and evaluation guide
npm ci
npm run android:demo
adb shell am start -n dev.nimby.app/.MainActivity
For a reproducible demo, transfer tests/fixtures/review/register-slip.png to the test device. Choose it using Home β Add photos β Choose individual photos, scan it, wait for OCR if needed, and search for pineapple. The query word is printed on the receipt and is absent from the filename. The result should show the matching text and let you open and keep the original. Settings β On-device models β Eye β Run Self-Test runs the packaged model against a bundled image.
The project also includes TypeScript checks, Node tests for query parsing and the retailer and license flows, and Python smoke tests for the database and offline map asset. The landing page and local retailer endpoint can be served together with node --env-file-if-exists=.env landing/serve-local.mjs. A Tavily key is needed only to make live Tavily requests.
One release build crashed before React Native loaded. Logcat pointed to WorkManagerβs Room database, and comparing the release DEX files showed that R8 had removed the generated constructor Room uses at startup. The preview currently disables release minification. I now check the packaged build by installing it, cold-launching it on Android, and running the receipt walkthrough.
What Iβd work on next
First, Iβd evaluate Recall on larger, messier galleries and measure retrieval quality and scan time across a wider range of Android devices. Iβd also test how often Daily discoveries bring back something people actually want to act on. The web checkout and license flow works as a sandbox demo, with production billing still ahead.
The next version should keep the same test in view. Can someone find the receipt they remember, see why it surfaced, and decide what to do with it on the phone they already use?
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.