# gadak-h1/home_link- architecture

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

- Interactive diagram: https://gitdiagram.com/gadak-h1/home_link-
- Repository: https://github.com/gadak-h1/home_link-

## Overview

1. **System shape**
   - HomeLink is a single monorepo-style Next.js 16 application, not a split frontend/backend stack.
   - The same codebase contains the UI, API routes, authentication, database access, and integrations.
   - Runtime is Node-based; Bun is the preferred package manager, but npm is also supported.

2. **Primary boundary: App Router vs API routes**
   - `src/app/**` is the Next.js App Router surface.
   - `src/app/page.tsx` and `src/components/pages/*` make up the user-facing screens.
   - `src/app/api/*/route.ts` is the server-side boundary where all business operations happen: CRUD, auth/session, wallet actions, seeding, Telegram, AI chat, and admin operations.

3. **Presentation layer**
   - The UI is organized by feature pages rather than by generic route components.
   - `src/components/pages/` contains the major experiences: landing, browse, property details, wallet, seller/buyer dashboards, admin dashboards, requests, messages, favorites, rentals, profile, and AI assistant.
   - `src/components/layout/` contains shared chrome such as headers, sidebars, floating navigation, login prompts, preview panels, and the AI launcher.

4. **Shared UI and client-side helpers**
   - `src/components/ui/` is a shadcn/ui-style component library used across pages.
   - `src/hooks/use-api.ts` likely wraps API calls and standardizes loading/error handling.
   - `src/hooks/use-toast.ts`, `src/components/ui/toaster.tsx`, and related toast providers handle user feedback.
   - `src/lib/store.ts` provides global client state, most likely via Zustand, for cross-page UI/session state.

5. **Domain subsystems**
   - The product center is a real-estate marketplace with property browsing, details, favorites, buying, renting, and seller onboarding.
   - Separate dashboards exist for admin, seller, and buyer roles, which indicates role-based navigation and data access.
   - The request workflows are first-class subsystems: purchase requests, rental requests, seller requests, password requests, and account action requests.

6. **Financial subsystem**
   - Wallet functionality is a major domain boundary with its own API group: deposit, withdraw, transaction history, admin wallet operations, and bank accounts.
   - Escrow and receipts are also separate server-side concerns, implying transactional flows are tracked independently from simple property browsing.
   - `commission-settings` and `settings` suggest platform-wide financial rules are configurable rather than hardcoded.

7. **Core data model and persistence**
   - The application uses Prisma ORM with `prisma/schema.prisma` as the source of truth.
   - SQLite is the default datastore, with `db/custom.db` and `prisma/db/custom.db` providing the local pre-seeded database.
   - `src/lib/db.ts` is the main database access module used by API routes and server logic.
   - The `data/*.json` files are seed inputs for `/api/seed`, not the primary runtime storage layer.

8. **Authentication and session flow**
   - Auth is handled by NextAuth through `src/app/api/auth/[...nextauth]/route.ts` plus related auth/session/social routes.
   - The app supports credentials login and optional social OAuth providers such as Google and GitHub.
   - `src/app/auth/callback/page.tsx` indicates a dedicated post-login callback/redirect experience.
   - Role-aware UI and dashboards depend on session/user identity coming from this auth layer.

9. **AI and messaging integrations**
   - `src/app/api/ai-chat/route.ts` powers the assistant page and the floating AI entry point in the layout.
   - `src/app/api/messages/route.ts` supports internal user messaging as part of marketplace workflows.
   - These features sit beside the main marketplace but depend on the same user/session and database boundaries.

10. **Telegram notification subsystem**
   - Telegram is a separate integration surface with config, webhook, and test endpoints under `src/app/api/telegram/*`.
   - `src/lib/telegram.ts` centralizes notification logic, while `scripts/test-telegram-notifications.js` validates delivery.
   - This makes Telegram an outbound notification channel driven by server events rather than a core user-facing feature.

11. **Seeding, export, and local operations**
   - `/api/seed` bootstraps the database from the JSON files in `data/`.
   - `scripts/export-database.js` exports data out of the database for backup or portability.
   - The presence of `SETUP.md`, `run-node.sh`, `start-dev.sh`, `start-server.sh`, and `keep-alive.sh` shows the repo is designed for local/self-hosted execution as well as development.

12. **Cross-cutting infrastructure**
   - `Caddyfile` suggests the app can be fronted by Caddy for reverse proxying and TLS termination.
   - `public/` holds static assets, while `src/app/globals.css` and Tailwind config define the visual system.
   - The architecture is therefore a classic full-stack Next.js monolith: browser UI and role-based pages on top, API routes in the middle, Prisma/SQLite persistence below, with Telegram/OAuth/AI as external integrations.

Main entry points: [`src/app/api`](https://github.com/gadak-h1/home_link-/tree/main/src/app/api) (API Surface), [`src/app`](https://github.com/gadak-h1/home_link-/tree/main/src/app) (App Router), [`Caddyfile`](https://github.com/gadak-h1/home_link-/tree/main/Caddyfile) (External Integrations), [`src/components/pages`](https://github.com/gadak-h1/home_link-/tree/main/src/components/pages) (Feature Pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_app_router["App Router<br/>next app"]
  node_landing_page["Landing<br/>page<br/>[landing-page.tsx]"]
  node_feature_pages["Feature Pages"]
  node_layout_shell["Layout Shell"]
  node_ui_library["UI Library<br/>ui kit"]
  node_client_hooks["Client Hooks"]
  node_client_store(("Client Store<br/>state<br/>[store.ts]"))
end

subgraph group_server["Server"]
  node_api_routes["API Surface<br/>route handlers"]
  node_auth_api["Auth<br/>[route.ts]"]
  node_market_api["Marketplace API<br/>domain api"]
  node_wallet_api["Wallet API<br/>financial api"]
  node_requests_api["Requests API<br/>workflow api"]
  node_messages_ai_api["Messages & AI<br/>communication api"]
  node_admin_api["Admin API"]
  node_telegram_api["Telegram<br/>integration api"]
end

subgraph group_data["Data"]
  node_db_layer[("DB Layer<br/>prisma access<br/>[db.ts]")]
  node_schema["Prisma Schema<br/>[schema.prisma]"]
  node_sqlite_db[("SQLite DB<br/>database file<br/>[custom.db]")]
  node_seed_data["Seed Data<br/>json seeds"]
end

subgraph group_infra["Infra"]
  node_ops_scripts["Ops Scripts<br/>local ops<br/>[export-database.js]"]
  node_external_integrations["External Integrations<br/>oauth/telegram/reverse proxy"]
end

node_app_router -->|"renders"| node_landing_page
node_app_router -->|"hosts"| node_feature_pages
node_app_router -->|"wraps"| node_layout_shell
node_layout_shell -->|"uses"| node_ui_library
node_feature_pages -->|"calls"| node_client_hooks
node_feature_pages -->|"reads/writes"| node_client_store
node_app_router -->|"routes to"| node_api_routes
node_api_routes -->|"includes"| node_auth_api
node_api_routes -->|"includes"| node_market_api
node_api_routes -->|"includes"| node_wallet_api
node_api_routes -->|"includes"| node_requests_api
node_api_routes -->|"includes"| node_messages_ai_api
node_api_routes -->|"includes"| node_admin_api
node_api_routes -->|"includes"| node_telegram_api
node_api_routes -->|"queries"| node_db_layer
node_db_layer -->|"maps to"| node_schema
node_schema -->|"persists in"| node_sqlite_db
node_seed_data -->|"seeds via"| node_api_routes
node_ops_scripts -.->|"exports/tests"| node_sqlite_db
node_external_integrations -->|"auth providers"| node_auth_api
node_external_integrations -->|"notifies"| node_telegram_api
node_external_integrations -.->|"fronts"| node_api_routes

click node_app_router "https://github.com/gadak-h1/home_link-/tree/main/src/app"
click node_landing_page "https://github.com/gadak-h1/home_link-/blob/main/src/components/pages/landing-page.tsx"
click node_feature_pages "https://github.com/gadak-h1/home_link-/tree/main/src/components/pages"
click node_layout_shell "https://github.com/gadak-h1/home_link-/tree/main/src/components/layout"
click node_ui_library "https://github.com/gadak-h1/home_link-/tree/main/src/components/ui"
click node_client_hooks "https://github.com/gadak-h1/home_link-/tree/main/src/hooks"
click node_client_store "https://github.com/gadak-h1/home_link-/blob/main/src/lib/store.ts"
click node_api_routes "https://github.com/gadak-h1/home_link-/tree/main/src/app/api"
click node_auth_api "https://github.com/gadak-h1/home_link-/blob/main/src/app/api/auth/[...nextauth]/route.ts"
click node_market_api "https://github.com/gadak-h1/home_link-/tree/main/src/app/api/properties"
click node_wallet_api "https://github.com/gadak-h1/home_link-/tree/main/src/app/api/wallet"
click node_requests_api "https://github.com/gadak-h1/home_link-/tree/main/src/app/api/purchase-requests"
click node_messages_ai_api "https://github.com/gadak-h1/home_link-/tree/main/src/app/api/messages"
click node_admin_api "https://github.com/gadak-h1/home_link-/tree/main/src/app/api/users"
click node_telegram_api "https://github.com/gadak-h1/home_link-/tree/main/src/app/api/telegram"
click node_db_layer "https://github.com/gadak-h1/home_link-/blob/main/src/lib/db.ts"
click node_schema "https://github.com/gadak-h1/home_link-/blob/main/prisma/schema.prisma"
click node_sqlite_db "https://github.com/gadak-h1/home_link-/blob/main/db/custom.db"
click node_seed_data "https://github.com/gadak-h1/home_link-/tree/main/data"
click node_ops_scripts "https://github.com/gadak-h1/home_link-/blob/main/scripts/export-database.js"
click node_external_integrations "https://github.com/gadak-h1/home_link-/tree/main/Caddyfile"

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_router,node_landing_page,node_feature_pages,node_layout_shell,node_ui_library,node_client_hooks,node_client_store toneBlue
class node_api_routes,node_auth_api,node_market_api,node_wallet_api,node_requests_api,node_messages_ai_api,node_admin_api,node_telegram_api toneAmber
class node_db_layer,node_schema,node_sqlite_db,node_seed_data toneMint
class node_ops_scripts,node_external_integrations toneRose
```

## Components

### Frontend

Next.js App Router UI, feature pages, shared layout, and client helpers.

- [App Router](https://github.com/gadak-h1/home_link-/tree/main/src/app): next app · Top-level Next.js routes and shell for the monolith. · `src/app`
- [Landing](https://github.com/gadak-h1/home_link-/blob/main/src/components/pages/landing-page.tsx): page · Home screen entry point. · `src/components/pages/landing-page.tsx`
- [Feature Pages](https://github.com/gadak-h1/home_link-/tree/main/src/components/pages): pages · Marketplace, auth, dashboards, requests, messages, wallet, and profile experiences. · `src/components/pages`
- [Layout Shell](https://github.com/gadak-h1/home_link-/tree/main/src/components/layout): layout · Shared chrome: header, sidebar, navigation, preview, login, AI launcher. · `src/components/layout`
- [UI Library](https://github.com/gadak-h1/home_link-/tree/main/src/components/ui): ui kit · Reusable shadcn-style components and toasts used across the app. · `src/components/ui`
- [Client Hooks](https://github.com/gadak-h1/home_link-/tree/main/src/hooks): hooks · API access, mobile detection, and toast helpers. · `src/hooks`
- [Client Store](https://github.com/gadak-h1/home_link-/blob/main/src/lib/store.ts): state · Shared client-side UI/session state. · `src/lib/store.ts`

### Server

API routes and server-side business operations.

- [API Surface](https://github.com/gadak-h1/home_link-/tree/main/src/app/api): route handlers · Server-side business boundary under App Router. · `src/app/api`
- [Auth](https://github.com/gadak-h1/home_link-/blob/main/src/app/api/auth/[...nextauth]/route.ts): nextauth · Credentials and social login plus session endpoints. · `src/app/api/auth/[...nextauth]/route.ts`
- [Marketplace API](https://github.com/gadak-h1/home_link-/tree/main/src/app/api/properties): domain api · Properties, places, categories, favorites, purchase and rental workflows. · `src/app/api/properties`
- [Wallet API](https://github.com/gadak-h1/home_link-/tree/main/src/app/api/wallet): financial api · Deposits, withdrawals, transaction history, and admin wallet operations. · `src/app/api/wallet`
- [Requests API](https://github.com/gadak-h1/home_link-/tree/main/src/app/api/purchase-requests): workflow api · Seller, purchase, rental, password, and account action requests. · `src/app/api/purchase-requests`
- [Messages & AI](https://github.com/gadak-h1/home_link-/tree/main/src/app/api/messages): communication api · Internal messaging and assistant chat endpoints. · `src/app/api/messages`
- [Admin API](https://github.com/gadak-h1/home_link-/tree/main/src/app/api/users): admin api · Settings, receipts, logs, users, and moderation operations. · `src/app/api/users`
- [Telegram](https://github.com/gadak-h1/home_link-/tree/main/src/app/api/telegram): integration api · Config, webhook, and delivery test endpoints for notifications. · `src/app/api/telegram`

### Data

Persistence, seed data, and domain schema.

- [DB Layer](https://github.com/gadak-h1/home_link-/blob/main/src/lib/db.ts): prisma access · Main database access module used by server logic. · `src/lib/db.ts`
- [Prisma Schema](https://github.com/gadak-h1/home_link-/blob/main/prisma/schema.prisma): schema · Source of truth for the application data model. · `prisma/schema.prisma`
- [SQLite DB](https://github.com/gadak-h1/home_link-/blob/main/db/custom.db): database file · Local runtime database and pre-seeded copies. · `db/custom.db`
- [Seed Data](https://github.com/gadak-h1/home_link-/tree/main/data): json seeds · JSON inputs for database seeding and local bootstrap. · `data`

### Infra

External integrations and local operations.

- [Ops Scripts](https://github.com/gadak-h1/home_link-/blob/main/scripts/export-database.js): local ops · Database export, Telegram test, and startup scripts. · `scripts/export-database.js`
- [External Integrations](https://github.com/gadak-h1/home_link-/tree/main/Caddyfile): oauth/telegram/reverse proxy · OAuth providers, Telegram channel, and Caddy fronting for deployment. · `Caddyfile`

## Connections

- App Router → Landing: renders · The App Router serves the home entry screen.
- App Router → Feature Pages: hosts · Feature-driven pages are mounted under the app shell.
- App Router → Layout Shell: wraps · Shared chrome surrounds most application views.
- Layout Shell → UI Library: uses · Layout components are built from the shared UI kit.
- Feature Pages → Client Hooks: calls · Pages rely on client helpers for API access and UX state.
- Feature Pages → Client Store: reads/writes · Role and UI state are shared across pages.
- App Router → API Surface: routes to · Server operations are exposed through route handlers.
- API Surface → Auth: includes · Authentication and session management live here.
- API Surface → Marketplace API: includes · Marketplace CRUD and browsing endpoints.
- API Surface → Wallet API: includes · Financial actions and wallet history endpoints.
- API Surface → Requests API: includes · Request workflow endpoints.
- API Surface → Messages & AI: includes · Messaging and assistant chat endpoints.
- API Surface → Admin API: includes · Administrative management endpoints.
- API Surface → Telegram: includes · Telegram integration endpoints.
- API Surface → DB Layer: queries · Most route handlers read and write through the DB layer.
- DB Layer → Prisma Schema: maps to · Prisma schema defines the persistence model.
- Prisma Schema → SQLite DB: persists in · Local SQLite stores the runtime data.
- Seed Data → API Surface: seeds via · Seed payloads are loaded through the seed endpoint.
- Ops Scripts → SQLite DB: exports/tests · Scripts support backup and delivery validation around the database.
- External Integrations → Auth: auth providers · OAuth login flows plug into the auth boundary.
- External Integrations → Telegram: notifies · Telegram is the outbound notification channel.
- External Integrations → API Surface: fronts · Caddy can reverse proxy the deployed app.
