How lihancancode/thikanaai works
1. Overall shape
Thikana AI is a single Next.js 15 App Router application that combines the UI, backend endpoints, and server-side business logic in one repo. There is no separate standalone API service; instead, the backend boundary is split between server actions and route handlers under src/app.
2. Primary runtime and persistence
The application is built around Supabase for authentication, PostgreSQL data, and likely storage. Client-side code uses Supabase’s browser client, while privileged operations use dedicated server/admin clients from src/lib/supabase. The database schema is versioned in supabase/migrations, so the schema is an important architectural boundary.
3. User-facing product areas
The app is organized by top-level product flows: listings, student, landlord, alerts, chat, profile, dashboard, admin, and auth pages. This indicates a marketplace plus tenant/student utility platform, not just a simple listings site. The landing page and shared layout sit in src/app/page.tsx and src/app/layout.tsx.
4. Marketplace and listing flow
Listing browsing lives in src/app/listings, with detail pages, a new-listing flow, estimation tools, and a family-related sub-area. Reusable listing UI is in src/components/listings and src/components/cards. Listing search is exposed through src/app/api/listings/search, which is the main data-access path for marketplace discovery.
5. AI subsystem
The AI features are concentrated in src/app/api/ai/*. Separate endpoints handle listing generation, flatmate matching, neighborhood Q&A, query parsing, photo scoring, rent estimation, and trust scoring. This suggests AI is not a single model integration, but a set of narrow, task-specific services layered on top of Gemini.
6. Trust, fraud, and image analysis
Fraud detection is a dedicated subsystem. src/lib/image-hash.ts and src/app/api/utils/hash-photos support hashing photos, while src/app/actions/ai-trust-score.ts and src/app/api/ai/trust-score compute listing trust signals. The related migrations add photo_hashes and trust_scores, so image verification and score persistence are first-class parts of the architecture.
7. Student matching and shared-living flows
The student area is a separate domain with its own pages for feed, finance, matching, room shares, and a student-specific Flick API route. Supporting logic lives in src/lib/flatmate-candidates.ts, src/lib/flatmate-db.ts, and student-specific action files. This domain likely reads from Supabase, applies compatibility logic, and then surfaces matches/results in the student UI.
8. Alerts and notifications
Saved search alerts are handled by both UI and API: src/app/alerts, src/app/api/alerts/save, and src/app/api/alerts/[id]. The 005_chat_and_notifications.sql migration indicates notifications and chat are persisted features rather than purely client-side state. This area is the user-facing layer for ongoing match notifications.
9. Auth, roles, and privileged operations
Authentication is centered in src/app/auth and supported by src/lib/auth-utils.ts plus Supabase middleware/server helpers. The presence of src/app/api/make-admin and 007_admin_verification.sql shows role elevation is controlled server-side. The middleware file is important for session handling and request gating at the edge.
10. External integrations and utility layers
Gemini integration is centralized in src/lib/gemini.ts; Mapbox is abstracted in src/lib/mapbox.ts; image processing and hashing utilities support server-side media analysis. Shared UI primitives live in src/components/ui, layout/navigation in src/components/layout and src/components/shared, and animations/providers in src/lib/animations plus src/components/providers. These are supporting layers rather than domain boundaries.
11. Operational boundaries
Security and request-shaping happen at the edge via src/middleware.ts, while global presentation setup is in next.config.ts, src/app/globals.css, and Tailwind/PostCSS config. Seed data utilities in src/lib/seed-listings.ts and src/lib/seed-profiles.ts suggest local bootstrapping/testing support. Overall, the repo is a layered monolith: UI routes on top, server actions/route handlers in the middle, and Supabase/Gemini/Mapbox as external dependencies.
Main entry points: route.ts AI services · client.ts Supabase clients · page.tsx Listings · ai-trust-score.ts Server actions
Components 30
App Router
Next.js UI routes, server actions, and route handlers under src/app.
- App shell · Global document shell, navigation, and shared app scaffolding.
src/app/layout.tsx - Landing · Public entry point and overview of the product.
src/app/page.tsx - Listings · Browse and search listings, with item detail and creation flows nearby.
src/app/listings/page.tsx - Listing detail · Single listing view and associated discovery actions.
src/app/listings/[id]/page.tsx - New listing · Flow for creating or generating a new listing.
src/app/listings/new/page.tsx - Estimate · Rent estimation and listing valuation surface.
src/app/listings/estimate/page.tsx - Student hub · Student-facing entry point for matching and shared-living features.
src/app/student/page.tsx - Matching · Compatibility, feeds, and match results for student users.
src/app/student/matching/page.tsx - Alerts · Saved searches and notification management.
src/app/alerts/page.tsx - Chat · User messaging and conversation surface.
src/app/chat/page.tsx - Dashboard · General authenticated dashboard.
src/app/dashboard/page.tsx - Profile · User profile and account settings surface.
src/app/profile/page.tsx - Landlord · Landlord-facing dashboard and operational actions.
src/app/landlord/dashboard/page.tsx - Admin · Administrative control surface.
src/app/admin/page.tsx - Search API · Primary listing discovery endpoint.
src/app/api/listings/search/route.ts - AI services · Task-specific AI endpoints for listings, matching, Q&A, parsing, scoring, and estimation.
src/app/api/ai/generate-listing/route.ts - Alerts API · Save, fetch, and manage alert records.
src/app/api/alerts/save/route.ts - Admin API · Server-side role elevation and admin control.
src/app/api/make-admin/route.ts - Server actions · Server-side mutations for trust scoring, chat, auth, profile, landlord, and student workflows.
src/app/actions/ai-trust-score.ts - Student API · Student-specific integration endpoint.
src/app/student/flick-api/route.ts
Shared Logic
Reusable server/client helpers and domain logic in src/lib.
- Supabase clients · Browser, server, admin, and middleware Supabase helpers.
src/lib/supabase/client.ts - Auth utils · Session, role, and request-auth helper logic.
src/lib/auth-utils.ts - Gemini · Central Gemini model integration used by AI endpoints.
src/lib/gemini.ts - Flatmate logic · Candidate selection, compatibility, and persistence helpers for student matching.
src/lib/flatmate-candidates.ts - Image hash · Photo hashing and trust-related image analysis support.
src/lib/image-hash.ts - Mapbox · Geospatial and map-related helper integration.
src/lib/mapbox.ts
UI Components
Shared presentation components used across product flows.
- Listing UI · Listing cards, maps, and marketplace presentation pieces.
src/components/listings/ListingCard.tsx - Layout UI · Shared navbar and page-level layout elements.
src/components/layout/Navbar.tsx - Shared UI · Reusable buttons, animations, and provider wrappers.
src/components/ui/GreenButton.tsx
Supabase
Database schema, migrations, and Supabase client helpers.
- Schema · Versioned Supabase/PostgreSQL schema and storage configuration.
supabase/migrations/001_initial_schema.sql
Connections 34
- App shell → Landing: renders · App shell frames the public landing page.
- App shell → Listings: frames · Global shell supports marketplace pages.
- App shell → Student hub: frames · Global shell supports student flows.
- App shell → Dashboard: frames · Global shell supports authenticated dashboards.
- Listings → Search API: searches · Marketplace browsing is backed by the search endpoint.
- Listings → Listing detail: opens · Listings index links into item detail views.
- Listings → New listing: creates · Marketplace supports listing creation.
- Listings → Estimate: estimates · Discovery flow connects to rent estimation.
- New listing → AI services: generates · New listing flow uses AI generation services.
- Listing detail → AI services: scores · Detail view can call AI-backed enrichment and trust functions.
- Listing detail → Listing UI: uses · Detail and browse surfaces share listing presentation components.
- Estimate → AI services: estimates · Rent estimation is delegated to AI services.
- Student hub → Matching: routes to · Student hub leads into matching and feed flows.
- Matching → Flatmate logic: matches · Student matching depends on compatibility helpers.
- Matching → Student API: integrates · Student-specific endpoint supports the matching experience.
- Alerts → Alerts API: manages · Saved alerts are persisted through route handlers.
- Chat → Server actions: mutates · Chat interactions are handled by server-side actions.
- Profile → Server actions: updates · Profile edits use server actions.
- Landlord → Server actions: operates · Landlord dashboard mutations are server-side.
- Admin → Admin API: administers · Admin page uses privileged admin control endpoints.
- AI services → Gemini: calls · AI routes centralize on Gemini integration.
- AI services → Supabase clients: reads/writes · AI outputs and related state are persisted through Supabase helpers.
- Server actions → Supabase clients: persists · Server mutations use privileged Supabase access.
- Server actions → Auth utils: checks · Action layer relies on auth and role helpers.
- Auth utils → Supabase clients: auths · Authentication helpers wrap Supabase session handling.
- Alerts API → Supabase clients: stores · Alerts are stored in Supabase.
- Search API → Supabase clients: queries · Search is backed by database access.
- Admin API → Auth utils: gates · Role elevation is gated by server-side auth logic.
- Image hash → AI services: supports · Image verification underpins trust and photo scoring flows.
- Image hash → Schema: persists · Photo hashes and trust scores are schema-backed features.
- Flatmate logic → Schema: reads/writes · Student matching logic is persisted in the database schema.
- Supabase clients → Schema: targets · All Supabase clients point at the versioned PostgreSQL schema.
- Shared UI → Layout UI: supports · Shared primitives are composed by layout/navigation components.
- Listing UI → Shared UI: composes · Marketplace UI is built from shared primitives.