How octaviusoo/3.1-home-inspector works
1. Overall shape
This is a Next.js App Router application built with React and Node.js. The main user flows are centered on creating, editing, viewing, exporting, and syncing structured inspection reports.
2. Primary route boundaries
The app surface is organized around a few key routes:
- app/page.jsx for the main landing/workspace
- app/report/[id]/page.jsx for editing a specific report
- app/report/[id]/view/page.jsx for read-only presentation/viewing
- app/error.jsx and app/not-found.jsx for app-level failure states
The dynamic report/[id] segment is the main domain boundary.
3. Report editor as the core UI
The largest subsystem is the report editor, assembled from many focused React components in components/. Sections like Summary, Scope, Standards, Glossary, Documents, InspectionDetails, Presentation, and AIGuide imply a modular report structure where each section can be edited independently and reordered/managed through dedicated modals.
4. Domain model and persistence layer
Persistent app state appears to live in Firebase/Firestore, with firebase.ts, firestore.rules, and lib/db/* forming the data layer. The lib/db modules split responsibilities by concern: reports, media, settings, comments, shortcuts, translations, maintenance, and sync. This suggests the UI talks to an application-specific data access layer rather than directly to Firestore everywhere.
5. AI assistance and suggestion generation
The app integrates Gemini through lib/gemini.js, with a large catalog of category-specific suggestion modules under lib/suggestions/ such as roofing, plumbing, electrical, HVAC, foundation, kitchen, bathroom, etc. These likely feed AI-assisted text generation, inspection recommendations, or templated findings inside the report editor.
6. Media capture and handling
The UI includes dedicated tooling for photos, video, voice, QR, and image editing (PhotoEditorModal, PhotoViewer, VideoCapture, VoiceRecorder, QRScanner, QRGenerator, MediaImage). This points to a workflow where media is captured during inspection, attached to report sections, and then reused in the generated report output.
7. Export and document generation pipeline
Report output is handled by lib/docx-generator.js and lib/export.js, with many patch_*.js scripts indicating a post-processing pipeline for generated documents. The presence of these patch scripts suggests the export path is not trivial: content is assembled, rendered into a document format, and then adjusted for layout, fonts, bookmarks, photos, tables, and viewer compatibility.
8. Sync, backup, and restore flows
lib/firebaseSync.js, lib/sync.js, lib/db/sync.js, and the FirebaseRestoreModal indicate support for synchronization and recovery of report data. The architecture likely supports a local editing experience with cloud-backed persistence/restore rather than a purely server-centric workflow.
9. Platform and offline support
public/sw.js and public/manifest.json indicate PWA-style support, so the app likely includes offline caching or installable web-app behavior. The build artifacts in .next-dev/ confirm standard Next.js server/client bundling and runtime separation.
10. Supporting tooling and scripts
The repository includes many maintenance scripts (translate-*.js, update_*, fix_*, parse.js, split.js) plus ESLint and CSS tooling. These are ancillary to runtime but important to the repo’s evolution: they suggest the app’s document/content structure has been repeatedly migrated, translated, and normalized over time.
Main entry points: ReportEditor.jsx Editor · db/index.js DB API · suggestions/index.js Suggestions · firebaseSync.js Sync
Components 19
App shell
Next.js route layer and page-level entry points.
- Home · Main landing and workspace entry.
app/page.jsx - Report edit · Dynamic report editor route for a specific report.
app/report/[id]/page.jsx - Report view · Read-only report presentation route.
app/report/[id]/view/page.jsx - Error · App-level error boundary page.
app/error.jsx - Not found · App-level 404 page.
app/not-found.jsx
UI components
Core editor, sections, and modal workflows.
- Editor · Main report editing orchestrator.
components/ReportEditor.jsx - Section editor · Reusable section-level editing UI.
components/SectionEditor.jsx - Report sections · Structured report sections such as Summary, Scope, Standards, Glossary, Documents, InspectionDetails, Presentation, and AI guidance.
- Media tools · Photo, video, voice, QR, and image workflow components.
- Modals · Shared dialogs for creation, management, settings, restore, and confirmation flows.
Data layer
Persistence, sync, and Firebase-backed modules.
Content engine
AI suggestions, export generation, and document assembly.
- Suggestions · Category-specific inspection suggestion modules used to generate findings and guidance.
lib/suggestions/index.js - Gemini · Gemini integration for assisted generation.
lib/gemini.js - Export · Document generation and export flow for report output.
lib/export.js - DOCX gen · Report-to-Word document assembly and formatting.
lib/docx-generator.js
Tooling
Build, repair, translation, and maintenance scripts.
- Patches · Repair and normalization scripts for generated docs, photos, tables, fonts, bookmarks, and viewer compatibility.
- Scripts · Translation, update, parsing, splitting, and repair scripts used to evolve report content and structure.
Connections 18
- Home → Editor: opens · The workspace route mounts the main editor.
- Report edit → Editor: hosts · The dynamic report route renders the editor for one report.
- Report view → Editor: reuses data · Read-only view consumes report content generated by the editing flow.
- Editor → Section editor: delegates · The editor composes section-level editing surfaces.
- Editor → Report sections: organizes · The editor manages the modular report sections.
- Editor → Media tools: attaches media · Media capture and editing are part of report authoring.
- Editor → Modals: uses · The editor relies on shared dialogs for workflow actions.
- Editor → DB API: persists · Report state is stored through the application DB layer.
- DB API → Firebase: backed by · The DB layer is implemented on Firebase/Firestore.
- DB API → Sync: coordinates · Sync-related persistence flows pass through the DB layer.
- Sync → Firebase: syncs · Backup and restore flows synchronize against Firebase.
- Editor → Suggestions: suggests · The editor can inject category-specific guidance and findings.
- Suggestions → Gemini: uses · Suggestion generation is powered by Gemini.
- Editor → Export: exports · Completed reports are sent to the document export pipeline.
- Export → DOCX gen: builds · Export assembles the Word document through the DOCX generator.
- DOCX gen → Patches: post-processes · Generated documents are adjusted by patch scripts for layout and compatibility.
- Scripts → Report sections: migrates · Repository scripts normalize and translate report content structures.
- Scripts → Suggestions: updates · Utility scripts refresh or rewrite suggestion catalogs.