How gadak-h1/home_link- works
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: api API Surface · app App Router · Caddyfile External Integrations · pages Feature Pages
Components 21
Frontend
Next.js App Router UI, feature pages, shared layout, and client helpers.
- App Router · Top-level Next.js routes and shell for the monolith.
src/app - Landing · Home screen entry point.
src/components/pages/landing-page.tsx - Feature Pages · Marketplace, auth, dashboards, requests, messages, wallet, and profile experiences.
src/components/pages - Layout Shell · Shared chrome: header, sidebar, navigation, preview, login, AI launcher.
src/components/layout - UI Library · Reusable shadcn-style components and toasts used across the app.
src/components/ui - Client Hooks · API access, mobile detection, and toast helpers.
src/hooks - Client Store · Shared client-side UI/session state.
src/lib/store.ts
Server
API routes and server-side business operations.
- API Surface · Server-side business boundary under App Router.
src/app/api - Auth · Credentials and social login plus session endpoints.
src/app/api/auth/[...nextauth]/route.ts - Marketplace API · Properties, places, categories, favorites, purchase and rental workflows.
src/app/api/properties - Wallet API · Deposits, withdrawals, transaction history, and admin wallet operations.
src/app/api/wallet - Requests API · Seller, purchase, rental, password, and account action requests.
src/app/api/purchase-requests - Messages & AI · Internal messaging and assistant chat endpoints.
src/app/api/messages - Admin API · Settings, receipts, logs, users, and moderation operations.
src/app/api/users - Telegram · Config, webhook, and delivery test endpoints for notifications.
src/app/api/telegram
Data
Persistence, seed data, and domain schema.
- DB Layer · Main database access module used by server logic.
src/lib/db.ts - Prisma Schema · Source of truth for the application data model.
prisma/schema.prisma - SQLite DB · Local runtime database and pre-seeded copies.
db/custom.db - Seed Data · JSON inputs for database seeding and local bootstrap.
data
Infra
External integrations and local operations.
- Ops Scripts · Database export, Telegram test, and startup scripts.
scripts/export-database.js - External Integrations · OAuth providers, Telegram channel, and Caddy fronting for deployment.
Caddyfile
Connections 22
- 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.