# journey-bites/journey-bites-website architecture

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

- Interactive diagram: https://gitdiagram.com/journey-bites/journey-bites-website
- Repository: https://github.com/journey-bites/journey-bites-website

## Overview

##### Project type and purpose
- Journey Bites is a Next.js/React frontend application for a travel-blog platform.
- It communicates with a REST API (production via NEXT_PUBLIC_API_BASE_URL, development via JSON Server mocks) and uses Firebase Storage for media uploads.

##### File structure
- **src/app**: Next.js App Router pages and layouts, grouping by authentication (`(auth)`) and global/dashboard routes (`(global)` and `(dashboard)`).
- **src/components**: Reusable UI modules (atomic UI in `ui/`, domain-specific in `article/`, `creator/`, `dashboard/`, `editor/`, etc.).
- **src/lib**: API service layer (`ApiService.ts`, `authApi.ts`, `nextApi.ts`), HTTP exception handling, Firebase helpers, utility functions.
- **src/hook**: Custom React hooks wrapping data-fetch logic (`useArticle`, `useGetPosts`, `useSearch`, etc.).
- **src/providers** & **src/stores**: Global state management (React Query provider, Zustand stores).
- Config files: Next.js config, Tailwind, ESLint, TypeScript, environment samples.

##### Key insights from README
- Uses Next.js (server-side rendering + client), React Query for asynchronous data-fetch and caching, Zustand for local UI/state.
- JSON Server mocks for local development.
- Styling with Tailwind CSS and component library Radix UI.

##### Diagramming the system architecture
a. Main components
- Browser/Client (Next.js frontend)
- Next.js server & routing (App Router)
- UI component layers (pages, layouts, shared components)
- State & data layer (React Query, Zustand stores)
- API service layer (`ApiService.ts`, `authApi.ts`, `nextApi.ts`)
- External services:
– Production REST API (configured via NEXT_PUBLIC_API_BASE_URL)
– JSON Server mock API (for local dev)
– Firebase Storage (media assets)
b. Relationships & interactions
- Client requests page → Next.js routing resolves to page component → uses hooks → calls API service → React Query caches data → UI renders.
- Zustand stores manage ephemeral UI state (dialogs, editor state, user session).
- File uploads: UI → Firebase helper → Firebase Storage bucket.
c. Architectural patterns
- Separation of concerns: Presentation (components) / State (React Query + Zustand) / Service (API helpers)
- Atomic design in UI folder structure (ui primitives vs domain components)
- Next.js App Router for nested layouts and route grouping
- Provider pattern: React Query & userProvider wrap the app
d. Technologies & frameworks
- Next.js, React, React Query, Zustand, Tailwind CSS, Radix UI, JSON Server, Firebase.

##### Detailed and essential elements to capture
- Next.js page & layout hierarchy (authentication vs global vs dashboard).
- Major component categories (pages, common components, domain features).
- Service layer modules and how they map to hooks.
- Providers wrapping the application.
- Distinction between production and mock API endpoints.
- External storage (Firebase) integration.
- State management boundaries (React Query vs Zustand).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Browser
    Browser["Browser/Client"]:::frontend

    %% Next.js Server & Routing
    subgraph "Server & Routing"
        Router["Next.js App Router"]:::frontend
        AuthRoutes["Authentication Routes & Layout"]:::frontend
        GlobalRoutes["Global/Layout Routes"]:::frontend
        DashboardRoutes["Dashboard Nested Routes"]:::frontend
    end

    %% UI Components
    subgraph "UI Components"
        UIPrimitives["UI Component Library (Atomic Primitives)"]:::frontend
        ArticleUI["Article Components"]:::frontend
        CreatorUI["Creator Components"]:::frontend
        DashboardUI["Dashboard Components"]:::frontend
        EditorUI["Editor Components"]:::frontend
    end

    %% State Management
    subgraph "State Management"
        ReactQueryProv["React Query Provider"]:::state
        UserProv["User Context Provider"]:::state
        ReactQueryCache["React Query Cache"]:::state
        DialogStore["Dialog Store (Zustand)"]:::state
        EditorStore["Editor Store (Zustand)"]:::state
        UserStore["User Store (Zustand)"]:::state
    end

    %% Service Layer
    subgraph "Service Layer"
        CoreAPI["Core API Service"]:::service
        AuthAPI["Auth API Helpers"]:::service
        NextAPI["Next.js API Wrappers"]:::service
        APIExports["Generic API Exports"]:::service
        HTTPExceptions["HTTP Exception Handling"]:::service
        FirebaseStorage["Firebase Storage Integration"]:::service
    end

    %% Hooks
    subgraph "Custom Hooks"
        useArticle["useArticle"]:::service
        useGetPosts["useGetPosts"]:::service
        useSearch["useSearch"]:::service
        useFollowCreator["useFollowCreator"]:::service
        useSubscribe["useSubscribe"]:::service
    end

    %% Mocks & Config
    subgraph "Mocks & Config"
        MockDB["Mock Database"]:::config
        MockRoutes["Mock Routes"]:::config
        NextConfig["Next.js Config"]:::config
        TailwindConfig["Tailwind CSS Config"]:::config
        TSConfig["TypeScript Config"]:::config
    end

    %% External Services
    subgraph "External Services"
        ProdAPI["Production REST API"]:::external
        JSONServer["JSON Server Mock API"]:::external
        Firebase["Firebase Storage"]:::external
    end

    %% Connections
    Browser -->|"navigates to"| Router
    Router -->|"renders"| AuthRoutes
    Router -->|"renders"| GlobalRoutes
    GlobalRoutes -->|"renders"| DashboardRoutes

    AuthRoutes --> UIPrimitives
    GlobalRoutes --> UIPrimitives
    DashboardRoutes --> UIPrimitives

    UIPrimitives --> ArticleUI
    UIPrimitives --> CreatorUI
    UIPrimitives --> DashboardUI
    UIPrimitives --> EditorUI

    %% State & Providers
    Browser --> ReactQueryProv
    Browser --> UserProv
    ReactQueryProv --> ReactQueryCache

    UIPrimitives --> DialogStore
    EditorUI --> EditorStore
    AuthRoutes --> UserStore

    %% Data Flow via Hooks & Service Layer
    ArticleUI --> useArticle
    DashboardUI --> useGetPosts
    ArticleUI --> useSearch
    CreatorUI --> useFollowCreator
    CreatorUI --> useSubscribe

    useArticle --> CoreAPI
    useGetPosts --> CoreAPI
    useSearch --> CoreAPI
    useFollowCreator --> AuthAPI
    useSubscribe --> AuthAPI

    CoreAPI --> NextAPI
    AuthAPI --> NextAPI
    NextAPI --> APIExports
    APIExports --> HTTPExceptions

    HTTPExceptions --> ProdAPI
    HTTPExceptions --> JSONServer

    EditorUI --> FirebaseStorage
    FirebaseStorage --> Firebase

    %% Mocks & Config usage
    JSONServer --> MockDB
    JSONServer --> MockRoutes
    CoreAPI --> NextConfig
    UIPrimitives --> TailwindConfig
    UIPrimitives --> TSConfig

    %% Click Events
    click Router "https://github.com/journey-bites/journey-bites-website/tree/main/src/app"
    click AuthRoutes "https://github.com/journey-bites/journey-bites-website/tree/main/src/app/(auth)"
    click GlobalRoutes "https://github.com/journey-bites/journey-bites-website/tree/main/src/app/(global)"
    click DashboardRoutes "https://github.com/journey-bites/journey-bites-website/tree/main/src/app/(global)/(dashboard)"
    click UIPrimitives "https://github.com/journey-bites/journey-bites-website/tree/main/src/components/ui"
    click ArticleUI "https://github.com/journey-bites/journey-bites-website/tree/main/src/components/article"
    click CreatorUI "https://github.com/journey-bites/journey-bites-website/tree/main/src/components/creator"
    click DashboardUI "https://github.com/journey-bites/journey-bites-website/tree/main/src/components/dashboard"
    click EditorUI "https://github.com/journey-bites/journey-bites-website/tree/main/src/components/editor"
    click CoreAPI "https://github.com/journey-bites/journey-bites-website/blob/main/src/lib/ApiService.ts"
    click AuthAPI "https://github.com/journey-bites/journey-bites-website/blob/main/src/lib/authApi.ts"
    click NextAPI "https://github.com/journey-bites/journey-bites-website/blob/main/src/lib/nextApi.ts"
    click APIExports "https://github.com/journey-bites/journey-bites-website/blob/main/src/lib/api.ts"
    click HTTPExceptions "https://github.com/journey-bites/journey-bites-website/blob/main/src/lib/HttpExceptions.ts"
    click FirebaseStorage "https://github.com/journey-bites/journey-bites-website/blob/main/src/lib/firebase/storage.ts"
    click useArticle "https://github.com/journey-bites/journey-bites-website/blob/main/src/hook/useArticle.tsx"
    click useGetPosts "https://github.com/journey-bites/journey-bites-website/blob/main/src/hook/useGetPosts.ts"
    click useSearch "https://github.com/journey-bites/journey-bites-website/blob/main/src/hook/useSearch.tsx"
    click useFollowCreator "https://github.com/journey-bites/journey-bites-website/blob/main/src/hook/useFollowCreator.tsx"
    click useSubscribe "https://github.com/journey-bites/journey-bites-website/blob/main/src/hook/useSubscribe.tsx"
    click ReactQueryProv "https://github.com/journey-bites/journey-bites-website/blob/main/src/providers/ReactQuery.tsx"
    click UserProv "https://github.com/journey-bites/journey-bites-website/blob/main/src/providers/userProvider.tsx"
    click DialogStore "https://github.com/journey-bites/journey-bites-website/blob/main/src/stores/useDialogStore.ts"
    click EditorStore "https://github.com/journey-bites/journey-bites-website/blob/main/src/stores/useEditorStore.ts"
    click UserStore "https://github.com/journey-bites/journey-bites-website/blob/main/src/stores/userStore.ts"
    click MockDB "https://github.com/journey-bites/journey-bites-website/blob/main/src/mock/db.json"
    click MockRoutes "https://github.com/journey-bites/journey-bites-website/blob/main/src/mock/route.json"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#009,stroke-width:1px
    classDef state fill:#E6FFE6,stroke:#0A0,stroke-width:1px
    classDef service fill:#FFF5CC,stroke:#CC9900,stroke-width:1px
    classDef external fill:#FFE6CC,stroke:#D35400,stroke-width:1px
    classDef config fill:#F0F0F0,stroke:#888,stroke-width:1px
```
