How guilhermeblancogomes/projeto-react works
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)