# jdcorderor/m-r-landing-page architecture

> Architecture diagram of the GitHub repository jdcorderor/m-r-landing-page, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jdcorderor/m-r-landing-page
- Repository: https://github.com/jdcorderor/m-r-landing-page

## Overview

##### Project Type and Purpose
- This is a monolithic full-stack Next.js (App Router) application.
- Front-end and back-end live in the same codebase. The “app” directory contains React Server and Client Components for UI and file-based API route handlers under app/api.
- It exposes REST endpoints for “citas,” “comentarios,” and “servicios,” backed by a database connection in lib/db.ts.

##### Top-Level Structure
- app/
- UI pages, layouts, global CSS
- API route handlers under app/api/*
- hooks/
- Custom React hooks for client-side effects and data fetching
- lib/
- DB connection module
- public/
- Static assets (images)
- config files
- next.config.ts, tsconfig.json, eslint.config.mjs, postcss.config.mjs

##### Main Components
a. Client Browser
– UI layer consuming React Server/Client Components
– Invokes custom hooks for data fetching and side effects
b. Next.js Server
– Serves pages (SSR/SSG) and static assets
– Exposes API route handlers at /api/citas, /api/comentarios, /api/servicios
c. Database
– Connected via lib/db.ts (e.g., PostgreSQL, MongoDB)
d. Public Assets
– Served from public/images and global CSS
e. (Optional) Deployment Platform
– Vercel or any Node hosting

##### Component Interactions and Data Flow
1) Browser → Next.js Server Pages
- Requests initial HTML and React bundles
2) Browser (Client Components) → API Endpoints
- fetch(‘/api/servicios’) → Next.js Route Handler
3) API Handler → lib/db.ts → Database
- Perform CRUD operations
4) Next.js Server → Browser
- Returns JSON payloads to client
5) Next.js Server → Browser
- Serves static assets and optimized fonts

##### Architectural Patterns and Principles
- File-based routing (App Router): UI and API colocated by path
- Server and Client Components: default server, “use client” for interactivity
- Separation of concerns: UI in app/, data access in lib/, side-effects in hooks/
- Optimized asset delivery: public/, next/font

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Browser
    subgraph "Client Browser"
        Browser["Browser"] 
    end

    %% Frontend UI & Hooks
    subgraph "Frontend UI (React UI & Hooks)"
        Page["app/page.tsx"]:::frontend
        Agendar["app/agendar/page.tsx"]:::frontend
        Layout["app/layout.tsx"]:::frontend
        GlobalsCSS["app/globals.css"]:::frontend
        Hooks1["hooks/homePageHooks.ts"]:::frontend
        Hooks2["hooks/useHomePageEffects.ts"]:::frontend
    end

    %% Next.js Server & API Layer
    subgraph "Next.js Server"
        UIRender["SSR/SSG & Routing"]:::api
        CitasAPI["/api/citas"]:::api
        ComentariosAPI["/api/comentarios"]:::api
        ServiciosAPI["/api/servicios"]:::api
        DBModule["lib/db.ts"]:::data
    end

    %% Database
    Database["Database"]:::data

    %% Static Assets & Config
    subgraph "Static & Config"
        Images["public/images"]:::assets
        NextConfig["next.config.ts"]:::deployment
        TSConfig["tsconfig.json"]:::deployment
    end

    %% Deployment
    Deployment["Deployment (Vercel/Node)"]:::deployment

    %% Connections
    Browser -->|"requests pages"| UIRender
    UIRender -->|"serves HTML & bundles"| Browser

    Browser -->|"navigates to UI components"| Page
    Browser -->|"navigates to UI components"| Agendar

    Page -->|"uses hooks"| Hooks1
    Page -->|"uses hooks"| Hooks2

    Hooks1 -->|"fetches data"| ServiciosAPI
    Hooks2 -->|"fetches data"| ServiciosAPI

    Page -->|"fetches citas"| CitasAPI
    Page -->|"fetches comentarios"| ComentariosAPI

    CitasAPI -->|"queries"| DBModule
    ComentariosAPI -->|"queries"| DBModule
    ServiciosAPI -->|"queries"| DBModule

    DBModule -->|"reads/writes"| Database

    UIRender -->|"serves assets"| Images
    UIRender -->|"serves config"| NextConfig
    UIRender -->|"serves config"| TSConfig

    Deployment -->|"hosts"| UIRender
    Deployment -->|"hosts"| CitasAPI
    Deployment -->|"hosts"| ComentariosAPI
    Deployment -->|"hosts"| ServiciosAPI
    Deployment -->|"hosts"| Images

    %% Click Events
    click Page "https://github.com/jdcorderor/m-r-landing-page/blob/main/app/page.tsx"
    click Agendar "https://github.com/jdcorderor/m-r-landing-page/blob/main/app/agendar/page.tsx"
    click Layout "https://github.com/jdcorderor/m-r-landing-page/blob/main/app/layout.tsx"
    click GlobalsCSS "https://github.com/jdcorderor/m-r-landing-page/blob/main/app/globals.css"
    click Hooks1 "https://github.com/jdcorderor/m-r-landing-page/blob/main/hooks/homePageHooks.ts"
    click Hooks2 "https://github.com/jdcorderor/m-r-landing-page/blob/main/hooks/useHomePageEffects.ts"
    click CitasAPI "https://github.com/jdcorderor/m-r-landing-page/blob/main/app/api/citas/route.ts"
    click ComentariosAPI "https://github.com/jdcorderor/m-r-landing-page/blob/main/app/api/comentarios/route.ts"
    click ServiciosAPI "https://github.com/jdcorderor/m-r-landing-page/blob/main/app/api/servicios/route.ts"
    click DBModule "https://github.com/jdcorderor/m-r-landing-page/blob/main/lib/db.ts"
    click Images "https://github.com/jdcorderor/m-r-landing-page/tree/main/public/images"
    click NextConfig "https://github.com/jdcorderor/m-r-landing-page/blob/main/next.config.ts"
    click TSConfig "https://github.com/jdcorderor/m-r-landing-page/blob/main/tsconfig.json"

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#333,stroke-width:1px
    classDef api fill:#C0F7A1,stroke:#333,stroke-width:1px
    classDef data fill:#FFD8A8,stroke:#333,stroke-width:1px
    classDef assets fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef deployment fill:#E1C6F7,stroke:#333,stroke-width:1px
```
