# drew-space/unidel-housing architecture

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

- Interactive diagram: https://gitdiagram.com/drew-space/unidel-housing
- Repository: https://github.com/drew-space/unidel-housing

## Overview

#### Purpose and Runtime

Ruum is a Next.js App Router marketplace for University of Delta students to discover off-campus housing and connect with verified agents. It runs as a TypeScript frontend on Vercel, with Convex providing backend functions and database; Clerk supplies authentication. Global app composition and the Convex client boundary are rooted at `app/layout.tsx` and `components/providers/ConvexClientProvider.tsx`.

#### Route Domains and Entry Points

The application separates three route groups:
- Public/student marketplace: landing, listing discovery/detail, agent profiles, favorites, and KYC at `app/(main)/page.tsx`, `app/(main)/house/page.tsx`, and `app/(main)/house/[id]/page.tsx`.
- Agent workspace: dashboard and listing creation at `app/(agent)/dashboard/page.tsx` and `app/(agent)/dashboard/create-listing/page.tsx`.
- Administrative workspace: operational dashboard, KYC queue, agent management, and listing moderation at `app/(admin)/admin/dashboard/page.tsx`, `app/(admin)/admin/kyc/page.tsx`, and `app/(admin)/admin/listings/page.tsx`.

Each domain has its own layout boundary: `app/(main)/layout.tsx`, `app/(agent)/dashboard/layout.tsx`, and `app/(admin)/admin/layout.tsx`.

#### Identity, Roles, and Access Control

Clerk establishes the authenticated user identity; Convex persists application user records and roles. Role-aware routing is enforced client-side through `hooks/useRoleGuard.ts` and `hooks/useAdminRedirect.ts`, while request-level behavior is centralized in `proxy.ts`. User lifecycle and role data operations are implemented in `convex/users.ts`, with Clerk/Convex auth integration configured in `convex/auth.config.ts`.

Important boundary: authentication identity is external (Clerk), while marketplace authorization state—student, agent, admin, verification status—belongs in Convex.

#### Listing Discovery and Publishing

Housing posts are the core marketplace entity, modeled in `convex/schema.ts` and operated on by `convex/housePost.ts`. Public pages render browsing and detail experiences, using reusable listing presentation components at `components/HouseCard.tsx` and `components/ImageGallery.tsx`.

The expected flow is: agent passes verification → creates a listing in the agent dashboard → Convex stores/query-serves the listing → public listing pages expose filtered/searchable inventory. Listing input constraints are represented by `lib/schemas/house.ts`, creating a UI-to-backend validation boundary.

#### Verification and Trust Operations

Agent onboarding is a manual KYC workflow: applicants submit identity evidence, admins review it, and rejected applicants can resubmit. Backend workflow and status transitions reside in `convex/kyc.ts`; user/agent administration is in `convex/admin.ts`. The public-facing KYC entry is `app/(main)/kyc/page.tsx`, while the review queue is `app/(admin)/admin/kyc/page.tsx`.

Trust signals extend beyond KYC: students can save listings via `convex/favourites.ts`, review agents through `convex/reviews.ts`, and report agent/listing issues through `convex/agentReports.ts`. These moderation inputs feed the admin workspace rather than automated enforcement.

#### UI Composition and External Boundaries

Shared navigation and responsive shell components connect route domains: `components/Navbar.tsx`, `components/app-sidebar.tsx`, and `components/admin-sidebar.tsx`. The interface is built with Tailwind and shadcn/ui primitives under `components/ui`.

Convex is the principal application-data service and exposes generated typed bindings in `convex/_generated/api.d.ts`. The repository also contains an HTTP integration surface at `convex/http.ts`, though the primary visible application flow is Next.js client routes invoking Convex-backed marketplace operations.

Main entry points: [`app/(main)/page.tsx`](https://github.com/drew-space/unidel-housing/blob/main/app/(main)/page.tsx) (Student marketplace), [`convex/users.ts`](https://github.com/drew-space/unidel-housing/blob/main/convex/users.ts) (Users and roles), [`convex/housePost.ts`](https://github.com/drew-space/unidel-housing/blob/main/convex/housePost.ts) (Listing operations), [`app/(agent)/dashboard/page.tsx`](https://github.com/drew-space/unidel-housing/blob/main/app/(agent)/dashboard/page.tsx) (Agent workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Next.js frontend"]
  node_app_root["App composition<br/>root layout<br/>[layout.tsx]"]
  node_convex_provider["Convex client provider<br/>client boundary"]
  node_student_routes["Student marketplace<br/>route domain<br/>[page.tsx]"]
  node_student_layout["Student layout<br/>route layout<br/>[layout.tsx]"]
  node_listing_pages["Listing discovery<br/>route pages<br/>[page.tsx]"]
  node_agent_workspace["Agent workspace<br/>route domain<br/>[page.tsx]"]
  node_agent_layout["Agent layout<br/>route layout<br/>[layout.tsx]"]
  node_admin_workspace["Admin workspace<br/>route domain<br/>[page.tsx]"]
  node_admin_layout["Admin layout<br/>route layout<br/>[layout.tsx]"]
  node_role_guards["Role guards<br/>client access control<br/>[useRoleGuard.ts]"]
  node_request_proxy["Request proxy<br/>request access control<br/>[proxy.ts]"]
  node_listing_validation["Listing validation<br/>input schema<br/>[house.ts]"]
end

subgraph group_backend["Convex backend"]
  node_convex_schema[("Marketplace schema<br/>data model<br/>[schema.ts]")]
  node_users_roles{{"Users and roles<br/>Convex functions<br/>[users.ts]"}}
  node_listing_service{{"Listing operations<br/>Convex functions<br/>[housePost.ts]"}}
  node_kyc_workflow{{"KYC workflow<br/>Convex functions<br/>[kyc.ts]"}}
  node_trust_moderation{{"Trust and moderation<br/>Convex functions<br/>[admin.ts]"}}
  node_convex_auth["Convex auth config<br/>auth integration<br/>[auth.config.ts]"]
end

subgraph group_external["External services"]
  node_clerk(("Clerk<br/>identity provider"))
end

node_app_root -->|"mounts"| node_convex_provider
node_convex_provider -->|"uses identity"| node_clerk
node_student_layout -->|"frames"| node_student_routes
node_student_routes -->|"includes"| node_listing_pages
node_agent_layout -->|"frames"| node_agent_workspace
node_admin_layout -->|"frames"| node_admin_workspace
node_request_proxy -.->|"complements"| node_role_guards
node_role_guards -->|"checks role state"| node_users_roles
node_clerk -->|"integrates identity"| node_convex_auth
node_convex_auth -->|"authenticates operations"| node_users_roles
node_users_roles -->|"persists"| node_convex_schema
node_listing_validation -->|"validates input for"| node_listing_service
node_agent_workspace -->|"submits listing"| node_listing_validation
node_agent_workspace -->|"creates listings"| node_listing_service
node_listing_service -->|"reads and writes"| node_convex_schema
node_listing_pages -->|"queries inventory"| node_listing_service
node_student_routes -->|"submits KYC"| node_kyc_workflow
node_admin_workspace -->|"reviews KYC"| node_kyc_workflow
node_kyc_workflow -->|"updates verification"| node_users_roles
node_student_routes -->|"favorites, reviews, reports"| node_trust_moderation
node_admin_workspace -->|"operates moderation"| node_trust_moderation
node_trust_moderation -->|"persists trust signals"| node_convex_schema

click node_app_root "https://github.com/drew-space/unidel-housing/blob/main/app/layout.tsx"
click node_convex_provider "https://github.com/drew-space/unidel-housing/blob/main/components/providers/ConvexClientProvider.tsx"
click node_student_routes "https://github.com/drew-space/unidel-housing/blob/main/app/(main)/page.tsx"
click node_student_layout "https://github.com/drew-space/unidel-housing/blob/main/app/(main)/layout.tsx"
click node_listing_pages "https://github.com/drew-space/unidel-housing/blob/main/app/(main)/house/page.tsx"
click node_agent_workspace "https://github.com/drew-space/unidel-housing/blob/main/app/(agent)/dashboard/page.tsx"
click node_agent_layout "https://github.com/drew-space/unidel-housing/blob/main/app/(agent)/dashboard/layout.tsx"
click node_admin_workspace "https://github.com/drew-space/unidel-housing/blob/main/app/(admin)/admin/dashboard/page.tsx"
click node_admin_layout "https://github.com/drew-space/unidel-housing/blob/main/app/(admin)/admin/layout.tsx"
click node_role_guards "https://github.com/drew-space/unidel-housing/blob/main/hooks/useRoleGuard.ts"
click node_request_proxy "https://github.com/drew-space/unidel-housing/blob/main/proxy.ts"
click node_listing_validation "https://github.com/drew-space/unidel-housing/blob/main/lib/schemas/house.ts"
click node_convex_schema "https://github.com/drew-space/unidel-housing/blob/main/convex/schema.ts"
click node_users_roles "https://github.com/drew-space/unidel-housing/blob/main/convex/users.ts"
click node_listing_service "https://github.com/drew-space/unidel-housing/blob/main/convex/housePost.ts"
click node_kyc_workflow "https://github.com/drew-space/unidel-housing/blob/main/convex/kyc.ts"
click node_trust_moderation "https://github.com/drew-space/unidel-housing/blob/main/convex/admin.ts"
click node_convex_auth "https://github.com/drew-space/unidel-housing/blob/main/convex/auth.config.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_app_root,node_convex_provider,node_student_routes,node_student_layout,node_listing_pages,node_agent_workspace,node_agent_layout,node_admin_workspace,node_admin_layout,node_role_guards,node_request_proxy,node_listing_validation toneBlue
class node_convex_schema,node_users_roles,node_listing_service,node_kyc_workflow,node_trust_moderation,node_convex_auth toneAmber
class node_clerk toneMint
```

## Components

### Next.js frontend

App Router route domains and shared client boundaries.

- [App composition](https://github.com/drew-space/unidel-housing/blob/main/app/layout.tsx): root layout · `app/layout.tsx`
- [Convex client provider](https://github.com/drew-space/unidel-housing/blob/main/components/providers/ConvexClientProvider.tsx): client boundary · `components/providers/ConvexClientProvider.tsx`
- [Student marketplace](https://github.com/drew-space/unidel-housing/blob/main/app/(main)/page.tsx): route domain · Discovery, details, favorites, and KYC entry. · `app/(main)/page.tsx`
- [Student layout](https://github.com/drew-space/unidel-housing/blob/main/app/(main)/layout.tsx): route layout · `app/(main)/layout.tsx`
- [Listing discovery](https://github.com/drew-space/unidel-housing/blob/main/app/(main)/house/page.tsx): route pages · Browse and listing detail pages. · `app/(main)/house/page.tsx`
- [Agent workspace](https://github.com/drew-space/unidel-housing/blob/main/app/(agent)/dashboard/page.tsx): route domain · Dashboard and listing creation. · `app/(agent)/dashboard/page.tsx`
- [Agent layout](https://github.com/drew-space/unidel-housing/blob/main/app/(agent)/dashboard/layout.tsx): route layout · `app/(agent)/dashboard/layout.tsx`
- [Admin workspace](https://github.com/drew-space/unidel-housing/blob/main/app/(admin)/admin/dashboard/page.tsx): route domain · Operations, KYC review, agent management, and moderation. · `app/(admin)/admin/dashboard/page.tsx`
- [Admin layout](https://github.com/drew-space/unidel-housing/blob/main/app/(admin)/admin/layout.tsx): route layout · `app/(admin)/admin/layout.tsx`
- [Role guards](https://github.com/drew-space/unidel-housing/blob/main/hooks/useRoleGuard.ts): client access control · `hooks/useRoleGuard.ts`
- [Request proxy](https://github.com/drew-space/unidel-housing/blob/main/proxy.ts): request access control · `proxy.ts`
- [Listing validation](https://github.com/drew-space/unidel-housing/blob/main/lib/schemas/house.ts): input schema · `lib/schemas/house.ts`

### Convex backend

Marketplace data, workflows, and typed operations.

- [Marketplace schema](https://github.com/drew-space/unidel-housing/blob/main/convex/schema.ts): data model · Defines housing posts and application state. · `convex/schema.ts`
- [Users and roles](https://github.com/drew-space/unidel-housing/blob/main/convex/users.ts): Convex functions · Persists application users, roles, and lifecycle data. · `convex/users.ts`
- [Listing operations](https://github.com/drew-space/unidel-housing/blob/main/convex/housePost.ts): Convex functions · Creates, stores, and queries housing posts. · `convex/housePost.ts`
- [KYC workflow](https://github.com/drew-space/unidel-housing/blob/main/convex/kyc.ts): Convex functions · Manages submission, review, rejection, and resubmission. · `convex/kyc.ts`
- [Trust and moderation](https://github.com/drew-space/unidel-housing/blob/main/convex/admin.ts): Convex functions · Favorites, reviews, reports, and admin operations. · `convex/admin.ts`
- [Convex auth config](https://github.com/drew-space/unidel-housing/blob/main/convex/auth.config.ts): auth integration · `convex/auth.config.ts`

### External services

- **Clerk**: identity provider · External authenticated identity source.

## Connections

- App composition → Convex client provider: mounts
- Convex client provider → Clerk: uses identity
- Student layout → Student marketplace: frames
- Student marketplace → Listing discovery: includes
- Agent layout → Agent workspace: frames
- Admin layout → Admin workspace: frames
- Request proxy → Role guards: complements
- Role guards → Users and roles: checks role state
- Clerk → Convex auth config: integrates identity
- Convex auth config → Users and roles: authenticates operations
- Users and roles → Marketplace schema: persists
- Listing validation → Listing operations: validates input for
- Agent workspace → Listing validation: submits listing
- Agent workspace → Listing operations: creates listings
- Listing operations → Marketplace schema: reads and writes
- Listing discovery → Listing operations: queries inventory
- Student marketplace → KYC workflow: submits KYC
- Admin workspace → KYC workflow: reviews KYC
- KYC workflow → Users and roles: updates verification
- Student marketplace → Trust and moderation: favorites, reviews, reports
- Admin workspace → Trust and moderation: operates moderation
- Trust and moderation → Marketplace schema: persists trust signals
