How fmorar/easyrent works
1. This is a Next.js App Router application that acts as a real-estate operations platform, not just a marketing site. The UI is split into route groups for authenticated workspace, public-facing pages, auth flows, and an “unbranded” share surface.
2. The highest-level boundary is between server-rendered pages/components and client-side interactive forms. Most domain screens live under src/app/[locale]/(dashboard) and src/app/[locale]/(public), with many client components in src/components/* handling editing, dialogs, tables, maps, and uploaders.
3. Supabase is the core backend. src/lib/supabase/{server,client,admin}.ts provides the three main access modes, while supabase/migrations/* defines the data model, RLS, RPCs, storage policies, and feature-specific tables. The app relies on Supabase for auth, Postgres, storage, and public token-based report access.
4. The domain is centered on properties, projects, agents, leads, contracts, market analysis, and performance reporting. Each domain has its own action layer in src/lib/actions/*, UI in src/components/<domain>/*, and pages/API routes under src/app/.... This keeps CRUD flows, analytics flows, and public sharing flows separated.
5. Server actions appear to be the primary mutation path for standard workspace operations. Forms such as property/project/contract/report editors likely submit through these actions, which then persist to Supabase and may trigger enrichment, media handling, or document generation.
6. Heavy or long-running operations are exposed as API routes under src/app/api/*. These include contract generation/export/finalization, market-report and performance-report runs/PDFs, property voice intake, photo zip exports, and public report fetches by token. This is the boundary for work that is not simple form submission.
7. AI and document automation are first-class subsystems. src/lib/contracts/*, src/lib/market-analysis/openai-report-service.ts, src/lib/property-performance/openai-owner-summary-service.ts, and src/lib/ai/* indicate OpenAI-backed generation/rewrite/extraction flows for contracts, market reports, property-performance insights, and text cleanup.
8. Market analysis has its own pipeline: crawler adapters in src/lib/market-analysis/crawler/adapters/*, fetch/normalize logic, comparables scoring, pricing, FX conversion, and PDF rendering. The outputs feed both internal dashboards and public report pages, with tokenized public RPCs in the database.
9. Property-performance reporting is another pipeline with its own extraction, scoring, recommendation, analytics, and PDF services. It likely combines listing metadata, engagement analytics, and AI-generated summaries to produce owner-facing reports and dashboards.
10. Sharing and public visibility are explicit architectural concerns. Projects, properties, and reports can be published through tokenized links, branded/unbranded pages, and share dialogs/buttons. The app distinguishes internal workspace views from public report and marketplace views.
11. Internationalization is built into the route structure. There are localized routes under src/app/[locale], message catalogs in messages/en.json and messages/es.json, and navigation/request helpers in src/i18n/*. That means locale resolution affects routing, layout, and content rendering across the app.
12. External integrations matter to the architecture: Google Places/geocoding for address and location workflows, likely PostHog for analytics (src/components/analytics/*, src/lib/analytics/*), and Supabase storage for uploads such as avatars, covers, property photos, videos, and generated documents.
13. The supporting UI layer is a reusable component library in src/components/ui plus domain-specific shells, sidebars, headers, and public-site sections. This keeps presentation concerns separate from the domain services and data-access layers.
14. Overall, the architecture is a three-part system: a localized Next.js frontend, a Supabase/Postgres-backed domain and auth layer, and a set of specialized generation/analysis pipelines for contracts, market reports, and performance reports. The key diagram boundaries should show workspace CRUD, public share/report access, and asynchronous AI/report-generation flows.
Main entry points: (dashboard)/layout.tsx Workspace · actions Server actions · [locale]/layout.tsx Locale shell · api API routes
Components 21
App routes
Localized route groups, page shells, and API boundaries.
- Locale shell · Locale-aware root that coordinates routing and content across the app.
src/app/[locale]/layout.tsx - Workspace · Authenticated workspace area for CRUD screens and operational workflows.
src/app/[locale]/(dashboard)/layout.tsx - Public site · Public-facing pages, marketplace, projects, agents, and report views.
src/app/[locale]/(public)/layout.tsx - Auth flow · Login, invite acceptance, and password reset flows.
src/app/[locale]/(auth)/layout.tsx - API routes · Heavy or asynchronous operations such as generation, export, run, and token fetch flows.
src/app/api
UI layer
Reusable shells, domain editors, and presentation components.
- UI kit · Reusable low-level controls used across forms, dialogs, tables, and sheets.
src/components/ui - Shell UI · Headers, sidebars, footers, locale switcher, and other global chrome.
src/components/layout - Property UI · Property forms, galleries, maps, uploaders, and ownership/contact controls.
src/components/property - Project UI · Project editors, previews, FAQ, amenities, property links, and sharing controls.
src/components/project - Contract UI · Contract editor, data form, export actions, validation banners, and status views.
src/components/contracts - Report UI · Public market and property-performance report renderers and supporting charts.
src/components/public-report - Sharing UI · Share dialogs, public links, and publication prompts for projects and properties.
src/components/sharing
Domain services
Server actions, AI pipelines, and report generation logic.
- Server actions · Primary mutation boundary for workspace CRUD, enrichment, and sharing flows.
src/lib/actions - Contract engine · Prefill, template health, generation, description cleanup, and export services for contracts.
src/lib/contracts/contract-generation-service.ts - Market analysis · Crawler, normalization, pricing, comparables, FX, PDF, and OpenAI report generation.
src/lib/market-analysis/openai-report-service.ts - Performance reports · Extraction, scoring, recommendations, owner summaries, and PDF generation for performance reports.
src/lib/property-performance/openai-owner-summary-service.ts - i18n · Locale routing and request helpers used by localized pages and navigation.
src/i18n/request.ts
Data platform
Supabase access modes and schema/migrations.
- Supabase server · Server-side authenticated database and storage access.
src/lib/supabase/server.ts - Supabase client · Browser-side Supabase access for interactive client components.
src/lib/supabase/client.ts - Supabase admin · Privileged service access used for backend-only operations and tokenized public reads.
src/lib/supabase/admin.ts - Schema · Postgres schema, RLS, RPCs, storage policies, and feature tables.
supabase/migrations
Connections 30
- Locale shell → Workspace: routes · Locale-aware routes branch into authenticated workspace pages.
- Locale shell → Public site: routes · Locale-aware routes branch into public-facing pages and reports.
- Locale shell → Auth flow: routes · Locale-aware routes branch into login, invite, and reset flows.
- Locale shell → i18n: resolves locale · Locale resolution and navigation helpers drive routing and content selection.
- Workspace → Shell UI: uses · Workspace pages compose shared headers, sidebars, and topbars.
- Public site → Shell UI: uses · Public pages compose global headers, footers, and mobile navigation.
- Workspace → Property UI: renders · Property workspace screens use property editors, maps, uploads, and preview components.
- Workspace → Project UI: renders · Project workspace screens use project editors, previews, and share controls.
- Workspace → Contract UI: renders · Contract workspace screens use contract editors and export UI.
- Workspace → Sharing UI: shares · Workspace views expose publication dialogs, links, and share prompts.
- Public site → Report UI: renders · Public report pages render market-analysis and property-performance reports.
- Public site → Sharing UI: publishes · Public-facing entities expose share links and publication entry points.
- Property UI → UI kit: builds on · Property UI is composed from shared inputs, tables, dialogs, and tabs.
- Project UI → UI kit: builds on · Project UI is composed from shared inputs, dialogs, and tables.
- Contract UI → UI kit: builds on · Contract UI is composed from shared inputs, editors, and status primitives.
- Server actions → Supabase server: reads/writes · Server actions use authenticated Supabase access for workspace mutations.
- Server actions → Supabase client: hydrates · Client forms and interactive screens pair with browser Supabase access.
- Server actions → Supabase admin: privileged ops · Some actions rely on admin access for backend-only operations.
- Server actions → Schema: persists · Actions operate over the Supabase/Postgres schema and policies.
- Contract engine → Supabase server: loads data · Contract generation and export services read workspace data from Supabase.
- Contract engine → Supabase admin: exports · Export/finalization flows use privileged access when needed.
- Market analysis → Supabase server: stores results · Market analysis persists report state and compares data through Supabase.
- Market analysis → Supabase admin: public token RPC · Public market report access is backed by privileged token-based database calls.
- Performance reports → Supabase server: stores results · Performance report runs and summaries persist through Supabase.
- Performance reports → Supabase admin: public token RPC · Public performance report access uses token-based database reads.
- API routes → Contract engine: executes · Contract API routes trigger generation, export, and finalize workflows.
- API routes → Market analysis: executes · Market-report API routes run analysis and render PDFs.
- API routes → Performance reports: executes · Performance-report API routes run analysis and render PDFs.
- API routes → Server actions: delegates · Some endpoints reuse the standard server-action mutation layer.
- Schema → Server actions: defines data · Schema migrations define the tables and RPCs consumed by workspace actions.