# guilhermeblancogomes/projeto-react architecture

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

- Interactive diagram: https://gitdiagram.com/guilhermeblancogomes/projeto-react
- Repository: https://github.com/guilhermeblancogomes/projeto-react

## Overview

##### Project type and purpose
- This is a single-page web application built with React (bootstrapped via Create React App).
- Purpose: allow users to organize their book collection into three shelves (“wantToRead”, “currentlyReading”, “read”) and to search for books via a provided backend API.

##### File structure
- Top-level files:
– package.json, package-lock.json, .gitignore, README.md
– public/index.html: host HTML entry point
- src directory:
– index.js: ReactDOM.render entry
– App.css, index.css: global styling
– components/: reusable React components
- App.js: top-level component, routing and state container
- BooksAPI.js: wrapper over remote API calls (getAll, update, search)
- Shelf.jsx, ListBook.jsx, Book.jsx, SearchBook.jsx, Modal.jsx, Loading.jsx
- No backend folder, so all API calls go to an external service.

##### Key architectural insights from README
- Uses a fixed remote backend API with three methods (getAll, update, search).
- App is purely front-end; no Node/Express server in this repo.
- CSS/HTML skeleton provided; the student’s work is to add interactivity via React.

##### Main components and interactions
a. User’s Web Browser
b. Static Hosting / Web Server (e.g., GitHub Pages, Netlify) serving index.html + JS/CSS assets
c. React Application (SPA)
– App component (holds global state and routes)
– Home view: Shelf components (each shelf), ListBook → Book
– Search view: SearchBook input, results list → Book
– Modal and Loading components for UI feedback
d. BooksAPI module
e. External Backend Service (Udacity Books API)

##### Relationships and data flow
1. User opens browser → requests index.html and bundle.js from hosting
2. React App mounts (index.js → App.js)
3. App.js calls BooksAPI.getAll() → populates state with user’s current shelf books
4. User interacts:
- Moves a book: triggers BooksAPI.update(book, shelf) → on success update local state
- Navigates to search page: SearchBook invokes BooksAPI.search(query) → displays raw results, then merges shelf info
5. All data flows originate from BooksAPI methods to the external backend; results propagate into React component state and re-render UI.

##### Architectural patterns and design principles
- Component-based UI: small, reusable components (Book, Shelf, Modal, Loading)
- Container vs. Presentational: App.js is the “container” holding state; child components receive props
- Single source of truth: App state governs which shelf each book lives in
- Unidirectional data flow: App → children → user action → App → BooksAPI → App

##### Technologies and frameworks
- React (functional components, JSX)
- Create React App (webpack, babel, dev server)
- CSS modules / plain CSS
- RESTful API wrapper in BooksAPI.js (Promises, fetch under the hood)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Top Layer
    Browser["User Web Browser"]:::external
    subgraph "Static Hosting Layer"
        Hosting["Static Host: index.html + bundle.js"]:::external
    end
    Browser --> Hosting
    Hosting --> ReactApp["React Application (SPA)"]:::container
    click Hosting "https://github.com/guilhermeblancogomes/projeto-react/blob/master/public/index.html"
    click ReactApp "https://github.com/guilhermeblancogomes/projeto-react/blob/master/src/index.js"

    %% React Application Structure
    subgraph "React Application"
        %% Application Logic & State
        AppComp["App Component\n(state & router)"]:::container
        click AppComp "https://github.com/guilhermeblancogomes/projeto-react/blob/master/src/components/App.js"

        %% UI Components
        subgraph "Home View"
            ShelfComp["Shelf Component"]:::ui
            ListComp["ListBook Component"]:::ui
            BookComp["Book Component"]:::ui
            click ShelfComp "https://github.com/guilhermeblancogomes/projeto-react/blob/master/src/components/Shelf.jsx"
            click ListComp "https://github.com/guilhermeblancogomes/projeto-react/blob/master/src/components/ListBook.jsx"
            click BookComp "https://github.com/guilhermeblancogomes/projeto-react/blob/master/src/components/Book.jsx"
        end

        subgraph "Search View"
            SearchComp["SearchBook Component"]:::ui
            click SearchComp "https://github.com/guilhermeblancogomes/projeto-react/blob/master/src/components/SearchBook.jsx"
        end

        subgraph "Shared UI"
            ModalComp["Modal Component"]:::ui
            LoadingComp["Loading Component"]:::ui
            click ModalComp "https://github.com/guilhermeblancogomes/projeto-react/blob/master/src/components/Modal.jsx"
            click LoadingComp "https://github.com/guilhermeblancogomes/projeto-react/blob/master/src/components/Loading.jsx"
        end

        %% API Wrapper
        BooksAPI["BooksAPI Module"]:::api
        click BooksAPI "https://github.com/guilhermeblancogomes/projeto-react/blob/master/src/components/BooksAPI.js"
    end

    %% External Backend
    subgraph "External Backend Service"
        Backend["Udacity Books API"]:::external
    end

    %% Resources
    subgraph "Resources & Documentation"
        Styles1["App.css"]:::resources
        Styles2["index.css"]:::resources
        click Styles1 "https://github.com/guilhermeblancogomes/projeto-react/blob/master/src/App.css"
        click Styles2 "https://github.com/guilhermeblancogomes/projeto-react/blob/master/src/index.css"
        Config["package.json"]:::resources
        click Config "https://github.com/guilhermeblancogomes/projeto-react/blob/master/package.json"
        ConfigLock["package-lock.json"]:::resources
        click ConfigLock "https://github.com/guilhermeblancogomes/projeto-react/blob/master/package-lock.json"
        Docs["README.md, CONTRIBUTING.md, SEARCH_TERMS.md"]:::resources
        click Docs "https://github.com/guilhermeblancogomes/projeto-react/blob/master/README.md"
    end

    %% Data Flow & Dependencies
    ReactApp --> AppComp
    AppComp --> ShelfComp
    ShelfComp --> ListComp
    ListComp --> BookComp
    AppComp --> SearchComp
    SearchComp --> BookComp
    AppComp --> ModalComp
    AppComp --> LoadingComp

    AppComp --> BooksAPI
    BooksAPI --> Backend
    Backend --> BooksAPI
    BooksAPI --> AppComp

    %% Styles & Docs Connection
    ReactApp --> Styles1
    ReactApp --> Styles2
    ReactApp --> Config
    ReactApp --> ConfigLock
    ReactApp --> Docs

    classDef ui fill:#D0E6FF,stroke:#357ABD,color:#000
    classDef api fill:#FFDAB9,stroke:#E69138,color:#000
    classDef external fill:#C8E6C9,stroke:#388E3C,color:#000
    classDef container fill:#E1C7F2,stroke:#7B1FA2,color:#000
    classDef resources fill:#F0F0F0,stroke:#888,color:#000
```
