🚀 Inspiration: Turning a Nightmare Trip into a Tool for Trust
The inspiration for SafeLease came from a very personal place: a story about my brother's trip to Rome. He and his girlfriend had booked what looked like a dream apartment, but the reality was a nightmare. The photos didn't match, the bedsheets were stained, and the property was completely unattended. It was a classic case of a misrepresented listing that ruined their vacation.
This story, combined with research revealing that rental fraud is a problem affecting millions, sparked the core idea. Renters are navigating a high-risk environment with almost no tools to protect themselves. So I decided to build that tool: an AI-powered co-pilot to bring safety and trust back to the rental process.
🎯 What I Learned & The Journey
This project was a deep dive into the real-world challenges of building a scalable, AI-native application.
The first major hurdle was data acquisition. I quickly learned that automatically scraping major rental platforms is technically difficult and legally problematic. This forced a crucial pivot: instead of trying to scrape the web, I would empower the user. I developed a "copy-paste" solution, where the user provides the raw text, and the AI does the heavy lifting of structuring it. This was a key learning: adapting to constraints leads to a more user-centric design.
As the analysis became more complex, it hit a performance wall. A single, long-running analysis would freeze the app. This led me to re-architect the entire backend into a distributed system using FastAPI, Redis, and RQ (Redis Queue). This taught me how to build a truly scalable application where over ten independent worker jobs can run in parallel without impacting the user experience. So I implemented a robust, job-level Redis cache, which makes rerunning an analysis with minor changes almost instantaneous.
Finally, I learned that making AI reliable is an art. Early prompts produced inconsistent results. I solved this through advanced prompt engineering:
- Tiered Models: Using
Gemini 1.5 Flashfor simple tasks and the more powerfulGemini 1.5 Profor the final, complex synthesis. - Strict JSON Schemas: Forcing the AI to return structured data to eliminate errors.
- Explainable AI: I designed the system so that every worker job returns a standardized
AnalysisStepobject. This creates a full "forensic trail" that is fed to the finalizer, allowing it to cross-reference findings, identify contradictions, and produce a much more intelligent and trustworthy report.
🔧 How I Built It
SafeLease is built on a modern, asynchronous, and scalable full-stack architecture.
Backend (FastAPI, RQ, Redis, PostgreSQL):
- The core is an asynchronous task queue system. An Orchestrator job receives an analysis request and "fans out" over ten independent micro-analysis jobs. These jobs run in parallel, and their dependencies are managed by RQ.
- A Finalizer job gathers the results from all completed jobs, synthesizes them using
Gemini 1.5 Pro, and saves a complete, structured report to the PostgreSQL database. - A custom failure handler and robust "smart worker" logic ensure that any single job failure is caught, the analysis is gracefully marked as
FAILED, and the entire system remains stable.
Google Platform Integration:
- Google Maps Platform: This is the heart of the verification engine. The Geocoding API validates that an address is real. The Places API provides a "ground truth" for cross-referencing listing data (like reviews and property type). Crucially, I use the
country_codefrom the Geocoding result to perform localized reputation searches, making the analysis globally effective. - Gemini AI: I use a tiered approach for both cost-efficiency and quality, leveraging
Gemini 1.5 FlashandProfor different tasks. - Google Cloud Vision API: Powers the reverse image search to detect stolen or reused photos.
- Google Maps Platform: This is the heart of the verification engine. The Geocoding API validates that an address is real. The Places API provides a "ground truth" for cross-referencing listing data (like reviews and property type). Crucially, I use the
Frontend (React, TypeScript, Redux,
react-router-dom):- The frontend is a true single-page application that provides a seamless, interactive experience.
- I use a hybrid state management model: a lean Redux store manages truly global state (like loading status and theme), while components are responsible for their own data fetching.
- The
Sidebarcomponent manages the history list, and theResultsPagemanages the polling for an active analysis, creating a clean separation of concerns.
🏆 Challenges Faced
Beyond the architectural pivots, the main challenge was creating a system that could intelligently handle the vast diversity of real-world data. I built the system to be resilient to missing inputs (e.g., a listing with no photos), to handle API errors gracefully, and to intelligently decide when an analysis can't be performed due to insufficient data. The frontend polling logic, and ensuring it was efficient and didn't cause infinite loops, was also a significant but rewarding challenge to overcome.

Log in or sign up for Devpost to join the conversation.