# Frontend Architecture ## Component Architecture ### Component Organization ``` frontend/src/ ├── components/ │ ├── layout/ │ │ ├── Header.jsx │ │ ├── Footer.jsx │ │ └── Layout.jsx │ ├── books/ │ │ ├── BookCard.jsx │ │ ├── BookList.jsx │ │ ├── BookSearchResults.jsx │ │ └── AddBookForm.jsx │ ├── progress/ │ │ ├── LogProgressModal.jsx │ │ ├── ProgressDisplay.jsx │ │ └── StatusIndicator.jsx │ ├── calendar/ │ │ ├── Calendar.jsx │ │ ├── CalendarDay.jsx │ │ └── CalendarLegend.jsx │ └── common/ │ ├── Button.jsx │ ├── Input.jsx │ ├── Modal.jsx │ ├── Loading.jsx │ └── ErrorMessage.jsx ├── pages/ │ ├── Home.jsx │ ├── AddBook.jsx │ ├── BookDetail.jsx │ └── CalendarView.jsx ├── hooks/ │ ├── useBooks.js │ ├── useProgress.js │ └── useLogs.js ├── services/ │ ├── api.js (API client setup) │ ├── booksService.js │ └── logsService.js ├── context/ │ └── AppContext.jsx ├── utils/ │ ├── dateUtils.js │ ├── paceUtils.js │ └── validation.js ├── styles/ │ └── index.css (Tailwind directives) └── App.jsx ``` ### Component Template ```typescript // Example: BookCard.jsx import React from 'react'; import { useNavigate } from 'react-router-dom'; import StatusIndicator from '../progress/StatusIndicator'; import { formatDate } from '../../utils/dateUtils'; /** * BookCard - Displays a single book with progress metrics * @param {Object} book - Book object with progress data * @param {Function} onLogProgress - Handler for log progress action */ function BookCard({ book, onLogProgress }) { const navigate = useNavigate(); const handleCardClick = () => { navigate(`/books/${book.id}`); }; const handleLogClick = (e) => { e.stopPropagation(); // Prevent navigation when clicking log button onLogProgress(book); }; return (
{book.author}
}Due: {formatDate(book.deadlineDate)}
Target: {book.requiredPace.toFixed(1)} pages/day
Your pace: {' '} {book.actualPace ? `${book.actualPace.toFixed(1)} pages/day` : 'No data yet'}
{book.pagesRemaining} pages left, {book.daysRemaining} days