# anshitsharma05/routenest architecture

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

- Interactive diagram: https://gitdiagram.com/anshitsharma05/routenest
- Repository: https://github.com/anshitsharma05/routenest

## Overview

RouteNest is split into two clear runtime boundaries: a React/Vite single-page app in `routenest/` and an Express API server in `server/`. The frontend owns navigation, page rendering, and auth-gated UX; the backend owns data access, AI calls, file upload handling, and authorization enforcement.

The frontend entry point is `src/main.jsx`, which mounts `App.jsx` and the global styles in `src/index.css` / `src/App.css`. The app shell includes a shared `Navbar.jsx` and a page-level route structure for `LandingPage`, `Dashboard`, `ItineraryGen`, `NewDiary`, `Recommendations`, `Community`, and `SharedItinerary`. Those pages represent the main user journeys rather than a single generic CRUD interface.

Client-to-server communication is concentrated behind `src/apiConfig.js`, which likely centralizes the API base URL used by page components. The repo uses Axios on the client side, so data flow is request/response oriented rather than state-synced or websocket-driven.

Authentication is split intentionally. On the frontend, Clerk gates the user experience with signed-in/signed-out states before users reach protected pages. On the backend, `@clerk/express` validates bearer tokens again, so the API does not trust the browser for authorization. This is the main security boundary in the system.

The backend is organized by domain routes in `server/routes/`: `itineraries.js`, `memories.js`, `communities.js`, `recommendations.js`, `upload.js`, and `public.js`. That suggests a resource-based REST design where each route module handles one bounded capability rather than a monolithic controller.

Supabase is the persistence layer, and `server/lib/supabase.js` is the shared integration point. The SQL files `supabase_schema.sql` and `supabase_community_schema.sql` define the database shape, including personal travel memories, generated itineraries, communities, posts, comments, and votes. Supabase also serves as the file store for uploaded images, so media and relational data live in separate subsystems but are linked by stored URLs.

The travel memory flow is: a signed-in user creates a diary entry in the frontend, the API validates the Clerk identity, then the server writes metadata to Supabase and uploads photos through the storage layer. The `upload.js` route and `test-upload2.js` indicate image handling is a first-class path, and Multer is used in-memory so uploads do not touch local disk.

The itinerary and recommendation flow is AI-driven. The backend is the only layer that can talk to Google Gemini via `@google/genai`, which keeps the API key off the client and lets the server return cleaned Markdown content for display in the React UI. The `recommendations` and `itineraries` routes are the likely handoff points for this intelligence layer.

The community subsystem is the most relational part of the app. `communities`, `community_posts`, `community_comments`, and `community_post_votes` form the core data model, supporting anonymous posting, threaded discussion, and one-vote-per-user behavior. The README’s pseudonym scheme implies the server derives stable anonymous display names from Clerk identities before storing or rendering community activity.

Public sharing is modeled as a separate read-only boundary. The `public.js` route and the `SharedItinerary` page imply that a private itinerary can be exposed through a public URL without granting full account access, so the architecture distinguishes internal ownership from externally shareable content.

Deployment and build tooling are straightforward but important: the frontend uses Vite with a Vercel config, while the backend is a standalone Node process with Express. ESLint is present in the frontend, and the test scripts in `server/` show some operational checks around Supabase and upload integration.

In diagram form, the main thing to capture is this flow: browser SPA pages → Axios → Express route modules → Clerk auth check → Gemini and/or Supabase → JSON or stored media returned to the UI. The repo is architected around that separation of concerns, with each feature mapped cleanly to a route, a database shape, and a corresponding page in the client.

Main entry points: [`routenest/src/App.jsx`](https://github.com/anshitsharma05/routenest/blob/main/routenest/src/App.jsx) (App Shell), [`server/lib/supabase.js`](https://github.com/anshitsharma05/routenest/blob/main/server/lib/supabase.js) (Supabase Client), [`server/index.js`](https://github.com/anshitsharma05/routenest/blob/main/server/index.js) (Server Entry), [`routenest/src/apiConfig.js`](https://github.com/anshitsharma05/routenest/blob/main/routenest/src/apiConfig.js) (API Config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend SPA"]
  node_main["Entry<br/>[main.jsx]"]
  node_app["App Shell<br/>react shell<br/>[App.jsx]"]
  node_navbar["Navbar<br/>ui nav<br/>[Navbar.jsx]"]
  node_api_config["API Config<br/>client api<br/>[apiConfig.js]"]
  node_landing["Landing<br/>page<br/>[LandingPage.jsx]"]
  node_dashboard["Dashboard<br/>page<br/>[Dashboard.jsx]"]
  node_itinerary_page["Itinerary<br/>page<br/>[ItineraryGen.jsx]"]
  node_diary_page["Diary<br/>page<br/>[NewDiary.jsx]"]
  node_reco_page["Recommendations<br/>page"]
  node_community_page["Community<br/>page<br/>[Community.jsx]"]
  node_shared_page["Shared Itinerary<br/>page"]
end

subgraph group_backend["API Server"]
  node_server_entry["Server Entry<br/>express entry<br/>[index.js]"]
  node_itineraries_route["Itineraries<br/>route module<br/>[itineraries.js]"]
  node_memories_route["Memories<br/>route module<br/>[memories.js]"]
  node_communities_route["Communities<br/>route module<br/>[communities.js]"]
  node_recommendations_route["Reco API<br/>route module<br/>[recommendations.js]"]
  node_upload_route["Upload<br/>route module<br/>[upload.js]"]
  node_public_route["Public<br/>route module<br/>[public.js]"]
  node_genai(("Gemini<br/>ai service"))
end

subgraph group_data["Data Layer"]
  node_supabase_lib[("Supabase Client<br/>db adapter<br/>[supabase.js]")]
  node_supabase_schema["Core Schema<br/>sql schema"]
  node_community_schema["Community Schema<br/>sql schema"]
end

subgraph group_security["Auth Boundary"]
  node_clerk{{"Clerk Auth<br/>identity guard"}}
end

node_main -->|"mounts"| node_app
node_app -->|"uses"| node_navbar
node_app -->|"routes"| node_landing
node_app -->|"routes"| node_dashboard
node_app -->|"routes"| node_itinerary_page
node_app -->|"routes"| node_diary_page
node_app -->|"routes"| node_reco_page
node_app -->|"routes"| node_community_page
node_app -->|"routes"| node_shared_page
node_landing -.->|"sign-in"| node_clerk
node_dashboard -.->|"gates"| node_clerk
node_itinerary_page -->|"calls"| node_api_config
node_diary_page -->|"calls"| node_api_config
node_reco_page -->|"calls"| node_api_config
node_community_page -->|"calls"| node_api_config
node_shared_page -->|"calls"| node_api_config
node_server_entry -->|"mounts"| node_itineraries_route
node_server_entry -->|"mounts"| node_memories_route
node_server_entry -->|"mounts"| node_communities_route
node_server_entry -->|"mounts"| node_recommendations_route
node_server_entry -->|"mounts"| node_upload_route
node_server_entry -->|"mounts"| node_public_route
node_itineraries_route -.->|"verifies"| node_clerk
node_memories_route -.->|"verifies"| node_clerk
node_communities_route -.->|"verifies"| node_clerk
node_recommendations_route -.->|"verifies"| node_clerk
node_upload_route -.->|"verifies"| node_clerk
node_public_route -.->|"checks"| node_clerk
node_itineraries_route -->|"generates"| node_genai
node_recommendations_route -->|"generates"| node_genai
node_itineraries_route -->|"reads/writes"| node_supabase_lib
node_memories_route -->|"reads/writes"| node_supabase_lib
node_communities_route -->|"reads/writes"| node_supabase_lib
node_upload_route -->|"stores"| node_supabase_lib
node_public_route -->|"reads"| node_supabase_lib
node_supabase_lib -->|"implements"| node_supabase_schema
node_supabase_lib -->|"implements"| node_community_schema

click node_main "https://github.com/anshitsharma05/routenest/blob/main/routenest/src/main.jsx"
click node_app "https://github.com/anshitsharma05/routenest/blob/main/routenest/src/App.jsx"
click node_navbar "https://github.com/anshitsharma05/routenest/blob/main/routenest/src/components/Navbar.jsx"
click node_api_config "https://github.com/anshitsharma05/routenest/blob/main/routenest/src/apiConfig.js"
click node_landing "https://github.com/anshitsharma05/routenest/blob/main/routenest/src/pages/LandingPage.jsx"
click node_dashboard "https://github.com/anshitsharma05/routenest/blob/main/routenest/src/pages/Dashboard.jsx"
click node_itinerary_page "https://github.com/anshitsharma05/routenest/blob/main/routenest/src/pages/ItineraryGen.jsx"
click node_diary_page "https://github.com/anshitsharma05/routenest/blob/main/routenest/src/pages/NewDiary.jsx"
click node_reco_page "https://github.com/anshitsharma05/routenest/blob/main/routenest/src/pages/Recommendations.jsx"
click node_community_page "https://github.com/anshitsharma05/routenest/blob/main/routenest/src/pages/Community.jsx"
click node_shared_page "https://github.com/anshitsharma05/routenest/blob/main/routenest/src/pages/SharedItinerary.jsx"
click node_server_entry "https://github.com/anshitsharma05/routenest/blob/main/server/index.js"
click node_itineraries_route "https://github.com/anshitsharma05/routenest/blob/main/server/routes/itineraries.js"
click node_memories_route "https://github.com/anshitsharma05/routenest/blob/main/server/routes/memories.js"
click node_communities_route "https://github.com/anshitsharma05/routenest/blob/main/server/routes/communities.js"
click node_recommendations_route "https://github.com/anshitsharma05/routenest/blob/main/server/routes/recommendations.js"
click node_upload_route "https://github.com/anshitsharma05/routenest/blob/main/server/routes/upload.js"
click node_public_route "https://github.com/anshitsharma05/routenest/blob/main/server/routes/public.js"
click node_supabase_lib "https://github.com/anshitsharma05/routenest/blob/main/server/lib/supabase.js"
click node_supabase_schema "https://github.com/anshitsharma05/routenest/blob/main/server/supabase_schema.sql"
click node_community_schema "https://github.com/anshitsharma05/routenest/blob/main/server/supabase_community_schema.sql"

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_main,node_app,node_navbar,node_api_config,node_landing,node_dashboard,node_itinerary_page,node_diary_page,node_reco_page,node_community_page,node_shared_page toneBlue
class node_server_entry,node_itineraries_route,node_memories_route,node_communities_route,node_recommendations_route,node_upload_route,node_public_route,node_genai toneAmber
class node_supabase_lib,node_supabase_schema,node_community_schema toneMint
class node_clerk toneRose
```

## Components

### Frontend SPA

React/Vite client that renders pages, gates UX, and calls the API.

- [Entry](https://github.com/anshitsharma05/routenest/blob/main/routenest/src/main.jsx): react entry · Mounts the SPA and global styles. · `routenest/src/main.jsx`
- [App Shell](https://github.com/anshitsharma05/routenest/blob/main/routenest/src/App.jsx): react shell · Top-level client shell and routing container. · `routenest/src/App.jsx`
- [Navbar](https://github.com/anshitsharma05/routenest/blob/main/routenest/src/components/Navbar.jsx): ui nav · Shared navigation across the SPA. · `routenest/src/components/Navbar.jsx`
- [API Config](https://github.com/anshitsharma05/routenest/blob/main/routenest/src/apiConfig.js): client api · Central Axios/API base configuration. · `routenest/src/apiConfig.js`
- [Landing](https://github.com/anshitsharma05/routenest/blob/main/routenest/src/pages/LandingPage.jsx): page · Public entry and sign-in oriented landing page. · `routenest/src/pages/LandingPage.jsx`
- [Dashboard](https://github.com/anshitsharma05/routenest/blob/main/routenest/src/pages/Dashboard.jsx): page · Authenticated home and overview screen. · `routenest/src/pages/Dashboard.jsx`
- [Itinerary](https://github.com/anshitsharma05/routenest/blob/main/routenest/src/pages/ItineraryGen.jsx): page · UI for generating or viewing itineraries. · `routenest/src/pages/ItineraryGen.jsx`
- [Diary](https://github.com/anshitsharma05/routenest/blob/main/routenest/src/pages/NewDiary.jsx): page · Creates personal travel memories with uploads. · `routenest/src/pages/NewDiary.jsx`
- [Recommendations](https://github.com/anshitsharma05/routenest/blob/main/routenest/src/pages/Recommendations.jsx): page · Displays AI-assisted travel recommendations. · `routenest/src/pages/Recommendations.jsx`
- [Community](https://github.com/anshitsharma05/routenest/blob/main/routenest/src/pages/Community.jsx): page · Community feed and discussion interface. · `routenest/src/pages/Community.jsx`
- [Shared Itinerary](https://github.com/anshitsharma05/routenest/blob/main/routenest/src/pages/SharedItinerary.jsx): page · Public read-only itinerary sharing view. · `routenest/src/pages/SharedItinerary.jsx`

### API Server

Express service that enforces auth, handles routes, uploads, and AI/persistence access.

- [Server Entry](https://github.com/anshitsharma05/routenest/blob/main/server/index.js): express entry · Bootstraps the API process and route mounting. · `server/index.js`
- [Itineraries](https://github.com/anshitsharma05/routenest/blob/main/server/routes/itineraries.js): route module · Handles itinerary generation and retrieval. · `server/routes/itineraries.js`
- [Memories](https://github.com/anshitsharma05/routenest/blob/main/server/routes/memories.js): route module · Handles diary entries and memory metadata. · `server/routes/memories.js`
- [Communities](https://github.com/anshitsharma05/routenest/blob/main/server/routes/communities.js): route module · Handles community posts, comments, and votes. · `server/routes/communities.js`
- [Reco API](https://github.com/anshitsharma05/routenest/blob/main/server/routes/recommendations.js): route module · Serves AI-backed recommendation responses. · `server/routes/recommendations.js`
- [Upload](https://github.com/anshitsharma05/routenest/blob/main/server/routes/upload.js): route module · Handles in-memory image upload flows. · `server/routes/upload.js`
- [Public](https://github.com/anshitsharma05/routenest/blob/main/server/routes/public.js): route module · Serves read-only public itinerary access. · `server/routes/public.js`
- **Gemini**: ai service · Server-side generative model integration.

### Data Layer

Supabase-backed persistence, schemas, and storage integration.

- [Supabase Client](https://github.com/anshitsharma05/routenest/blob/main/server/lib/supabase.js): db adapter · Shared Supabase integration used by routes. · `server/lib/supabase.js`
- [Core Schema](https://github.com/anshitsharma05/routenest/blob/main/server/supabase_schema.sql): sql schema · Supabase schema for itineraries and memories. · `server/supabase_schema.sql`
- [Community Schema](https://github.com/anshitsharma05/routenest/blob/main/server/supabase_community_schema.sql): sql schema · Supabase schema for communities and social data. · `server/supabase_community_schema.sql`

### Auth Boundary

Clerk-based identity checks on both client and server.

- **Clerk Auth**: identity guard · Browser and API identity boundary.

## Connections

- Entry → App Shell: mounts · SPA entry mounts the application shell.
- App Shell → Navbar: uses · Shell renders shared navigation.
- App Shell → Landing: routes · Public landing page is part of the client route structure.
- App Shell → Dashboard: routes · Authenticated dashboard is part of the client route structure.
- App Shell → Itinerary: routes · Itinerary generation/view page is part of the client route structure.
- App Shell → Diary: routes · Diary creation page is part of the client route structure.
- App Shell → Recommendations: routes · Recommendations page is part of the client route structure.
- App Shell → Community: routes · Community page is part of the client route structure.
- App Shell → Shared Itinerary: routes · Shared itinerary page is part of the client route structure.
- Landing → Clerk Auth: sign-in · Landing page participates in auth-gated UX.
- Dashboard → Clerk Auth: gates · Protected client experience depends on Clerk state.
- Itinerary → API Config: calls · Uses centralized API client settings.
- Diary → API Config: calls · Uses centralized API client settings.
- Recommendations → API Config: calls · Uses centralized API client settings.
- Community → API Config: calls · Uses centralized API client settings.
- Shared Itinerary → API Config: calls · Uses centralized API client settings.
- Server Entry → Itineraries: mounts · Main server registers itinerary routes.
- Server Entry → Memories: mounts · Main server registers memory routes.
- Server Entry → Communities: mounts · Main server registers community routes.
- Server Entry → Reco API: mounts · Main server registers recommendation routes.
- Server Entry → Upload: mounts · Main server registers upload routes.
- Server Entry → Public: mounts · Main server registers public routes.
- Itineraries → Clerk Auth: verifies · API validates bearer identity before returning data.
- Memories → Clerk Auth: verifies · API validates bearer identity before returning data.
- Communities → Clerk Auth: verifies · API validates bearer identity before returning data.
- Reco API → Clerk Auth: verifies · API validates bearer identity before returning data.
- Upload → Clerk Auth: verifies · API validates bearer identity before returning data.
- Public → Clerk Auth: checks · Public access is separated from private ownership.
- Itineraries → Gemini: generates · Itinerary content is AI-assisted on the server.
- Reco API → Gemini: generates · Recommendation content is AI-assisted on the server.
- Itineraries → Supabase Client: reads/writes · Persists itinerary data through Supabase.
- Memories → Supabase Client: reads/writes · Persists diary metadata and related records.
- Communities → Supabase Client: reads/writes · Persists community posts, comments, and votes.
- Upload → Supabase Client: stores · Stores upload metadata and storage references.
- Public → Supabase Client: reads · Loads public itinerary content for sharing.
- Supabase Client → Core Schema: implements · Adapter targets the core Supabase schema.
- Supabase Client → Community Schema: implements · Adapter targets the community schema.
