# zanzers/palawan_invest architecture

> Architecture diagram of the GitHub repository zanzers/palawan_invest, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zanzers/palawan_invest
- Repository: https://github.com/zanzers/palawan_invest

## Overview

Palawan Home combines a public property catalog and an agent dashboard with an AI listing assistant. Public visitors can search listings without AI; agents submit assistant requests that are authenticated, rate-limited, answered through controlled tools, and persisted with conversation history and tool logs. The README documents planned capabilities such as viewing requests and listing writes, but their implementations are not established by the excerpts. Relationships below use the shown route code, source-index references, or README; unsampled UI and integrations are not inferred beyond those references.

Main entry points: [`src/app/assistant/route.ts`](https://github.com/zanzers/palawan_invest/blob/main/src/app/assistant/route.ts) (Assistant API), [`src/services/listing/listings.queries.ts`](https://github.com/zanzers/palawan_invest/blob/main/src/services/listing/listings.queries.ts) (Listing queries), [`src/app/(agent)/dashboard/page.tsx`](https://github.com/zanzers/palawan_invest/blob/main/src/app/(agent)/dashboard/page.tsx) (Catalog page), [`src/lib/ai/registry.ts`](https://github.com/zanzers/palawan_invest/blob/main/src/lib/ai/registry.ts) (Tool registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public Catalog"]
  node_catalog_page["Catalog page<br/>[page.tsx]"]
  node_search_ui["Search controls<br/>[SearchBar.tsx]"]
  node_featured["Featured listings"]
  node_listings_route["Direct search API<br/>[route.ts]"]
end

subgraph group_agent["Agent Dashboard"]
  node_dashboard["Dashboard shell"]
end

subgraph group_assistant["AI Assistant"]
  node_assistant_route["Assistant API<br/>[route.ts]"]
  node_prompt_schema["Prompt and validation"]
  node_tool_registry["Tool registry<br/>[registry.ts]"]
  node_search_tool["Search listing tool<br/>[search-listing.ts]"]
  node_get_tool["Get listing tool<br/>[get-listing.ts]"]
  node_llm_client["LLM fallback client<br/>[client.ts]"]
end

subgraph group_data["Data and Security"]
  node_conversation_service["Conversation history<br/>[conversations.ts]"]
  node_usage_service["Usage limits<br/>[usage.ts]"]
  node_auth_service["Session authentication<br/>[authenticate.ts]"]
  node_listing_queries["Listing queries"]
  node_listing_mapper["Listing mapping"]
  node_supabase_client["Supabase client<br/>[server.ts]"]
end

node_visitor(("Public visitor"))
node_agent_user(("Agent"))
node_llm_providers{{"LLM providers"}}
node_supabase[("Supabase data platform")]

node_visitor -->|"browses"| node_catalog_page
node_catalog_page -->|"renders"| node_search_ui
node_catalog_page -->|"renders"| node_featured
node_featured -->|"loads listings"| node_listing_queries
node_search_ui -.->|"submits search"| node_listings_route
node_listings_route -->|"queries listings"| node_listing_queries
node_listing_queries -->|"maps rows"| node_listing_mapper
node_listing_queries -->|"queries through"| node_supabase_client
node_supabase_client -->|"connects to"| node_supabase
node_agent_user -->|"uses"| node_dashboard
node_agent_user -->|"sends message"| node_assistant_route
node_assistant_route -->|"validates request"| node_prompt_schema
node_assistant_route -->|"verifies session"| node_auth_service
node_assistant_route -->|"consumes limit"| node_usage_service
node_assistant_route -->|"loads and saves"| node_conversation_service
node_assistant_route -->|"requests completion"| node_llm_client
node_llm_client -->|"tries targets"| node_llm_providers
node_assistant_route -->|"dispatches tool calls"| node_tool_registry
node_tool_registry -->|"executes"| node_search_tool
node_tool_registry -->|"executes"| node_get_tool
node_search_tool -->|"searches listings"| node_listing_queries
node_auth_service -->|"verifies user"| node_supabase
node_conversation_service -->|"persists history"| node_supabase
node_usage_service -->|"enforces daily limits"| node_supabase

click node_catalog_page "https://github.com/zanzers/palawan_invest/blob/main/src/app/(agent)/dashboard/page.tsx"
click node_search_ui "https://github.com/zanzers/palawan_invest/blob/main/src/components/dashboard/SearchBar.tsx"
click node_featured "https://github.com/zanzers/palawan_invest/blob/main/src/components/ListingCards/FeaturedListings.tsx"
click node_listings_route "https://github.com/zanzers/palawan_invest/blob/main/src/app/listings/route.ts"
click node_dashboard "https://github.com/zanzers/palawan_invest/tree/main/src/app/(agent)/dashboard"
click node_assistant_route "https://github.com/zanzers/palawan_invest/blob/main/src/app/assistant/route.ts"
click node_prompt_schema "https://github.com/zanzers/palawan_invest/blob/main/src/api/schema/assistant_schema.ts"
click node_tool_registry "https://github.com/zanzers/palawan_invest/blob/main/src/lib/ai/registry.ts"
click node_search_tool "https://github.com/zanzers/palawan_invest/blob/main/src/lib/ai/tools/search-listing.ts"
click node_get_tool "https://github.com/zanzers/palawan_invest/blob/main/src/lib/ai/tools/get-listing.ts"
click node_llm_client "https://github.com/zanzers/palawan_invest/blob/main/src/lib/openai/client.ts"
click node_conversation_service "https://github.com/zanzers/palawan_invest/blob/main/src/services/conversation/conversations.ts"
click node_usage_service "https://github.com/zanzers/palawan_invest/blob/main/src/services/usage/usage.ts"
click node_auth_service "https://github.com/zanzers/palawan_invest/blob/main/src/lib/auth/authenticate.ts"
click node_listing_queries "https://github.com/zanzers/palawan_invest/blob/main/src/services/listing/listings.queries.ts"
click node_listing_mapper "https://github.com/zanzers/palawan_invest/blob/main/src/lib/services/listings.service.ts"
click node_supabase_client "https://github.com/zanzers/palawan_invest/blob/main/src/lib/supabase/server.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_catalog_page,node_search_ui,node_featured,node_listings_route toneBlue
class node_dashboard,node_supabase toneAmber
class node_assistant_route,node_prompt_schema,node_tool_registry,node_search_tool,node_get_tool,node_llm_client toneMint
class node_conversation_service,node_usage_service,node_auth_service,node_listing_queries,node_listing_mapper,node_supabase_client toneRose
class node_visitor,node_agent_user,node_llm_providers toneIndigo
```

## Components

### Public Catalog

- [Catalog page](https://github.com/zanzers/palawan_invest/blob/main/src/app/(agent)/dashboard/page.tsx): `src/app/(agent)/dashboard/page.tsx`
- [Search controls](https://github.com/zanzers/palawan_invest/blob/main/src/components/dashboard/SearchBar.tsx): `src/components/dashboard/SearchBar.tsx`
- [Featured listings](https://github.com/zanzers/palawan_invest/blob/main/src/components/ListingCards/FeaturedListings.tsx): `src/components/ListingCards/FeaturedListings.tsx`
- [Direct search API](https://github.com/zanzers/palawan_invest/blob/main/src/app/listings/route.ts): `src/app/listings/route.ts`

### Agent Dashboard

- [Dashboard shell](https://github.com/zanzers/palawan_invest/tree/main/src/app/(agent)/dashboard): `src/app/(agent)/dashboard`

### AI Assistant

- [Assistant API](https://github.com/zanzers/palawan_invest/blob/main/src/app/assistant/route.ts): `src/app/assistant/route.ts`
- [Prompt and validation](https://github.com/zanzers/palawan_invest/blob/main/src/api/schema/assistant_schema.ts): `src/api/schema/assistant_schema.ts`
- [Tool registry](https://github.com/zanzers/palawan_invest/blob/main/src/lib/ai/registry.ts): `src/lib/ai/registry.ts`
- [Search listing tool](https://github.com/zanzers/palawan_invest/blob/main/src/lib/ai/tools/search-listing.ts): `src/lib/ai/tools/search-listing.ts`
- [Get listing tool](https://github.com/zanzers/palawan_invest/blob/main/src/lib/ai/tools/get-listing.ts): `src/lib/ai/tools/get-listing.ts`
- [LLM fallback client](https://github.com/zanzers/palawan_invest/blob/main/src/lib/openai/client.ts): `src/lib/openai/client.ts`

### Data and Security

- [Conversation history](https://github.com/zanzers/palawan_invest/blob/main/src/services/conversation/conversations.ts): `src/services/conversation/conversations.ts`
- [Usage limits](https://github.com/zanzers/palawan_invest/blob/main/src/services/usage/usage.ts): `src/services/usage/usage.ts`
- [Session authentication](https://github.com/zanzers/palawan_invest/blob/main/src/lib/auth/authenticate.ts): `src/lib/auth/authenticate.ts`
- [Listing queries](https://github.com/zanzers/palawan_invest/blob/main/src/services/listing/listings.queries.ts): `src/services/listing/listings.queries.ts`
- [Listing mapping](https://github.com/zanzers/palawan_invest/blob/main/src/lib/services/listings.service.ts): `src/lib/services/listings.service.ts`
- [Supabase client](https://github.com/zanzers/palawan_invest/blob/main/src/lib/supabase/server.ts): `src/lib/supabase/server.ts`

### Other components

- **Public visitor**
- **Agent**
- **LLM providers**
- **Supabase data platform**

## Connections

- Public visitor → Catalog page: browses
- Catalog page → Search controls: renders (evidence: `src/app/(agent)/dashboard/page.tsx`)
- Catalog page → Featured listings: renders (evidence: `src/app/(agent)/dashboard/page.tsx`)
- Featured listings → Listing queries: loads listings (evidence: `src/components/ListingCards/FeaturedListings.tsx`)
- Search controls → Direct search API: submits search
- Direct search API → Listing queries: queries listings (evidence: `src/app/listings/route.ts`)
- Listing queries → Listing mapping: maps rows (evidence: `src/services/listing/listings.queries.ts`)
- Listing queries → Supabase client: queries through (evidence: `src/services/listing/listings.queries.ts`)
- Supabase client → Supabase data platform: connects to (evidence: `src/lib/supabase/server.ts`)
- Agent → Dashboard shell: uses
- Agent → Assistant API: sends message
- Assistant API → Prompt and validation: validates request (evidence: `src/app/assistant/route.ts`)
- Assistant API → Session authentication: verifies session (evidence: `src/app/assistant/route.ts`)
- Assistant API → Usage limits: consumes limit (evidence: `src/app/assistant/route.ts`)
- Assistant API → Conversation history: loads and saves (evidence: `src/app/assistant/route.ts`)
- Assistant API → LLM fallback client: requests completion (evidence: `src/app/assistant/route.ts`)
- LLM fallback client → LLM providers: tries targets (evidence: `src/lib/openai/client.ts`)
- Assistant API → Tool registry: dispatches tool calls (evidence: `src/app/assistant/route.ts`)
- Tool registry → Search listing tool: executes (evidence: `src/lib/ai/registry.ts`)
- Tool registry → Get listing tool: executes (evidence: `src/lib/ai/registry.ts`)
- Search listing tool → Listing queries: searches listings (evidence: `src/lib/ai/tools/search-listing.ts`)
- Session authentication → Supabase data platform: verifies user (evidence: `src/lib/auth/authenticate.ts`)
- Conversation history → Supabase data platform: persists history
- Usage limits → Supabase data platform: enforces daily limits
