# lucascarvalhod/react-frontend-challenge architecture

> Architecture diagram of the GitHub repository lucascarvalhod/react-frontend-challenge, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lucascarvalhod/react-frontend-challenge
- Repository: https://github.com/lucascarvalhod/react-frontend-challenge

## Overview

Libris is a web app for discovering books, viewing book details, and maintaining a personal reading shelf. The main workflow starts at the protected discovery route: users search and filter paginated Google Books results, open a book, and can manage saved books and reading status on the shelf. Login is a local simulation; session checks protect the discovery, shelf, and detail routes. The README documents theme and shelf persistence. Edges are limited to relationships shown in excerpts, the SOURCE INDEX, or README; some unsampled component behavior is therefore represented only at subsystem level.

Main entry points: [`src/App.tsx`](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/App.tsx) (Routes and guards), [`src/store/app-store.ts`](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/store/app-store.ts) (Application state), [`src/components/header.tsx`](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/header.tsx) (Site header), [`src/pages/discover-page.tsx`](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/pages/discover-page.tsx) (Discovery page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and access"]
  node_app["Routes and guards<br/>[App.tsx]"]
  node_login["Login form<br/>[login-form.tsx]"]
  node_loginformhook["Login form behavior<br/>[use-login-form.ts]"]
  node_loginservice["Simulated login<br/>[login-service.ts]"]
  node_session["Session service<br/>[session-service.ts]"]
end

subgraph group_books["Book discovery"]
  node_discover["Discovery page<br/>[discover-page.tsx]"]
  node_controls["Search controls"]
  node_searchresults["Search results"]
  node_bookcard["Book card<br/>[book-card.tsx]"]
  node_searchhook["Search behavior<br/>[use-book-search.ts]"]
  node_debounce["Input debounce<br/>[use-debounce.ts]"]
  node_booksservice["Books API service<br/>[books-service.ts]"]
  node_googlebooks["Google Books API"]
  node_detailpage["Book detail page"]
  node_detailhook["Detail behavior<br/>[use-book-detail.ts]"]
  node_detailcontent["Detail content"]
end

subgraph group_shelf["Personal library"]
  node_shelfpage["Shelf page<br/>[shelf-page.tsx]"]
  node_shelfhook["Shelf behavior"]
  node_shelftable["Shelf table<br/>[shelf-table.tsx]"]
end

subgraph group_shared["Shared state and UI"]
  node_store["Application state<br/>[app-store.ts]"]
  node_shelfslice["Library state<br/>[library-slice.ts]"]
  node_themeslice["Theme state<br/>[theme-slice.ts]"]
  node_header["Site header<br/>[header.tsx]"]
  node_accountmenu["Account menu<br/>[account-menu.tsx]"]
  node_mobilemenu["Mobile menu"]
  node_themebutton["Theme toggle<br/>[theme-toggle.tsx]"]
  node_brand["Brand<br/>[brand.tsx]"]
  node_states["Loading and error states<br/>[states.tsx]"]
  node_booktype["Book contracts<br/>[book.ts]"]
end

node_reader(("Reader"))
node_browserstorage[("Browser localStorage")]

node_reader -->|"opens app"| node_app
node_app -->|"checks session"| node_session
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_discover
node_app -->|"routes to"| node_shelfpage
node_app -->|"routes to"| node_detailpage
node_app -->|"initializes theme"| node_store
node_login -->|"uses form behavior"| node_loginformhook
node_loginformhook -->|"uses login service"| node_loginservice
node_loginservice -->|"updates session"| node_session
node_session -->|"reads and clears"| node_browserstorage
node_discover -->|"uses search"| node_searchhook
node_discover -->|"renders controls"| node_controls
node_discover -->|"renders results"| node_searchresults
node_searchhook -->|"debounces input"| node_debounce
node_searchhook -->|"queries books"| node_booksservice
node_booksservice -->|"fetches volumes"| node_googlebooks
node_booksservice -->|"maps responses"| node_booktype
node_searchresults -->|"renders cards"| node_bookcard
node_detailpage -->|"loads book"| node_detailhook
node_detailpage -->|"renders details"| node_detailcontent
node_detailhook -->|"gets book"| node_booksservice
node_detailpage -->|"renders states"| node_states
node_shelfpage -->|"uses shelf behavior"| node_shelfhook
node_shelfpage -->|"renders shelf"| node_shelftable
node_shelfhook -->|"uses state"| node_store
node_store -->|"combines slice"| node_shelfslice
node_store -->|"combines slice"| node_themeslice
node_store -->|"persists library and theme"| node_browserstorage
node_header -->|"renders menu"| node_accountmenu
node_header -->|"renders menu"| node_mobilemenu
node_header -->|"renders brand"| node_brand
node_header -->|"renders toggle"| node_themebutton
node_accountmenu -->|"logs out via"| node_session
node_themebutton -->|"updates theme"| node_store

click node_app "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/App.tsx"
click node_login "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/auth/login-form.tsx"
click node_loginformhook "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/hooks/use-login-form.ts"
click node_loginservice "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/services/login-service.ts"
click node_session "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/services/session-service.ts"
click node_discover "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/pages/discover-page.tsx"
click node_controls "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/books/search-controls.tsx"
click node_searchresults "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/books/book-search-results.tsx"
click node_bookcard "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/books/book-card.tsx"
click node_searchhook "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/hooks/use-book-search.ts"
click node_debounce "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/hooks/use-debounce.ts"
click node_booksservice "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/services/books-service.ts"
click node_detailpage "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/pages/book-detail-page.tsx"
click node_detailhook "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/hooks/use-book-detail.ts"
click node_detailcontent "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/books/book-detail-content.tsx"
click node_shelfpage "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/pages/shelf-page.tsx"
click node_shelfhook "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/hooks/use-library-shelf.ts"
click node_shelftable "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/books/shelf-table.tsx"
click node_store "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/store/app-store.ts"
click node_shelfslice "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/store/library-slice.ts"
click node_themeslice "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/store/theme-slice.ts"
click node_header "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/header.tsx"
click node_accountmenu "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/auth/account-menu.tsx"
click node_mobilemenu "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/mobile-menu-sidebar.tsx"
click node_themebutton "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/ui/theme-toggle.tsx"
click node_brand "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/ui/brand.tsx"
click node_states "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/ui/states.tsx"
click node_booktype "https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/types/book.ts"

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,node_login,node_loginformhook,node_loginservice,node_session toneBlue
class node_discover,node_controls,node_searchresults,node_bookcard,node_searchhook,node_debounce,node_booksservice,node_googlebooks,node_detailpage,node_detailhook,node_detailcontent,node_browserstorage toneAmber
class node_shelfpage,node_shelfhook,node_shelftable toneMint
class node_store,node_shelfslice,node_themeslice,node_header,node_accountmenu,node_mobilemenu,node_themebutton,node_brand,node_states,node_booktype toneRose
class node_reader toneIndigo
```

## Components

### App and access

- [Routes and guards](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/App.tsx): `src/App.tsx`
- [Login form](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/auth/login-form.tsx): `src/components/auth/login-form.tsx`
- [Login form behavior](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/hooks/use-login-form.ts): `src/hooks/use-login-form.ts`
- [Simulated login](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/services/login-service.ts): `src/services/login-service.ts`
- [Session service](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/services/session-service.ts): `src/services/session-service.ts`

### Book discovery

- [Discovery page](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/pages/discover-page.tsx): `src/pages/discover-page.tsx`
- [Search controls](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/books/search-controls.tsx): `src/components/books/search-controls.tsx`
- [Search results](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/books/book-search-results.tsx): `src/components/books/book-search-results.tsx`
- [Book card](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/books/book-card.tsx): `src/components/books/book-card.tsx`
- [Search behavior](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/hooks/use-book-search.ts): `src/hooks/use-book-search.ts`
- [Input debounce](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/hooks/use-debounce.ts): `src/hooks/use-debounce.ts`
- [Books API service](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/services/books-service.ts): `src/services/books-service.ts`
- **Google Books API**
- [Book detail page](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/pages/book-detail-page.tsx): `src/pages/book-detail-page.tsx`
- [Detail behavior](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/hooks/use-book-detail.ts): `src/hooks/use-book-detail.ts`
- [Detail content](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/books/book-detail-content.tsx): `src/components/books/book-detail-content.tsx`

### Personal library

- [Shelf page](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/pages/shelf-page.tsx): `src/pages/shelf-page.tsx`
- [Shelf behavior](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/hooks/use-library-shelf.ts): `src/hooks/use-library-shelf.ts`
- [Shelf table](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/books/shelf-table.tsx): `src/components/books/shelf-table.tsx`

### Shared state and UI

- [Application state](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/store/app-store.ts): `src/store/app-store.ts`
- [Library state](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/store/library-slice.ts): `src/store/library-slice.ts`
- [Theme state](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/store/theme-slice.ts): `src/store/theme-slice.ts`
- [Site header](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/header.tsx): `src/components/header.tsx`
- [Account menu](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/auth/account-menu.tsx): `src/components/auth/account-menu.tsx`
- [Mobile menu](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/mobile-menu-sidebar.tsx): `src/components/mobile-menu-sidebar.tsx`
- [Theme toggle](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/ui/theme-toggle.tsx): `src/components/ui/theme-toggle.tsx`
- [Brand](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/ui/brand.tsx): `src/components/ui/brand.tsx`
- [Loading and error states](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/components/ui/states.tsx): `src/components/ui/states.tsx`
- [Book contracts](https://github.com/lucascarvalhod/react-frontend-challenge/blob/main/src/types/book.ts): `src/types/book.ts`

### Other components

- **Reader**
- **Browser localStorage**

## Connections

- Reader → Routes and guards: opens app (evidence: `README.md`)
- Routes and guards → Session service: checks session (evidence: `src/App.tsx`)
- Routes and guards → Login form: routes to (evidence: `src/App.tsx`)
- Routes and guards → Discovery page: routes to (evidence: `src/App.tsx`)
- Routes and guards → Shelf page: routes to (evidence: `src/App.tsx`)
- Routes and guards → Book detail page: routes to (evidence: `src/App.tsx`)
- Routes and guards → Application state: initializes theme (evidence: `src/App.tsx`)
- Login form → Login form behavior: uses form behavior (evidence: `src/components/auth/login-form.tsx`)
- Login form behavior → Simulated login: uses login service (evidence: `src/hooks/use-login-form.ts`)
- Simulated login → Session service: updates session (evidence: `src/services/login-service.ts`)
- Session service → Browser localStorage: reads and clears (evidence: `src/services/session-service.ts`)
- Discovery page → Search behavior: uses search (evidence: `src/pages/discover-page.tsx`)
- Discovery page → Search controls: renders controls (evidence: `src/pages/discover-page.tsx`)
- Discovery page → Search results: renders results (evidence: `src/pages/discover-page.tsx`)
- Search behavior → Input debounce: debounces input (evidence: `src/hooks/use-book-search.ts`)
- Search behavior → Books API service: queries books (evidence: `src/hooks/use-book-search.ts`)
- Books API service → Google Books API: fetches volumes (evidence: `src/services/books-service.ts`)
- Books API service → Book contracts: maps responses (evidence: `src/services/books-service.ts`)
- Search results → Book card: renders cards (evidence: `src/components/books/book-search-results.tsx`)
- Book detail page → Detail behavior: loads book (evidence: `src/pages/book-detail-page.tsx`)
- Book detail page → Detail content: renders details (evidence: `src/pages/book-detail-page.tsx`)
- Detail behavior → Books API service: gets book (evidence: `src/hooks/use-book-detail.ts`)
- Book detail page → Loading and error states: renders states (evidence: `src/pages/book-detail-page.tsx`)
- Shelf page → Shelf behavior: uses shelf behavior (evidence: `src/pages/shelf-page.tsx`)
- Shelf page → Shelf table: renders shelf (evidence: `src/pages/shelf-page.tsx`)
- Shelf behavior → Application state: uses state (evidence: `src/hooks/use-library-shelf.ts`)
- Application state → Library state: combines slice (evidence: `src/store/app-store.ts`)
- Application state → Theme state: combines slice (evidence: `src/store/app-store.ts`)
- Application state → Browser localStorage: persists library and theme (evidence: `src/store/app-store.ts`)
- Site header → Account menu: renders menu (evidence: `src/components/header.tsx`)
- Site header → Mobile menu: renders menu (evidence: `src/components/header.tsx`)
- Site header → Brand: renders brand (evidence: `src/components/header.tsx`)
- Site header → Theme toggle: renders toggle (evidence: `src/components/header.tsx`)
- Account menu → Session service: logs out via (evidence: `src/components/auth/account-menu.tsx`)
- Theme toggle → Application state: updates theme (evidence: `src/components/ui/theme-toggle.tsx`)
