Directory Overview
The project is organized into the following main directories:Source Directory Structure
Thesrc/ directory is the heart of the application, organized by feature and responsibility:
Components Directory
Components Directory
The
src/components/ folder contains reusable UI components:- AlquilerButton.jsx - Rental button with transaction handling
- CategoryFilter.jsx - Genre/category filter dropdown
- CompraButton.jsx - Purchase button with transaction handling
- Footer.jsx - Application footer with site links
- Header.jsx - Navigation header with routing
- LoadingSpinner.jsx - Loading indicator component
- PeliculaCard.jsx - Movie card display component
- PeliculaGrid.jsx - Grid layout for movie cards
- SearchBar.jsx - Search input with real-time filtering
- TrailerModal.jsx - Modal for displaying movie trailers
Pages Directory
Pages Directory
The
src/pages/ folder contains page-level components that correspond to routes:- PrincipalPage.jsx - Home page with featured content
- PeliculasPage.jsx - Movie catalog with search and filters
- PeliculaDetailPage.jsx - Detailed movie information page
- AlquileresPage.jsx - User’s rented movies management
- ComprasPage.jsx - User’s purchased movies library
Data Directory
Data Directory
The
src/data/ folder contains data definitions:- mockPeliculas.js - Array of 8 movie objects with complete metadata
Hooks Directory
Hooks Directory
The
src/hooks/ folder contains custom React hooks:- usePeliculaSearch.js - Manages search, filtering, and movie state
- Search term management
- Category filtering
- Filtered results
- Loading states
- Unique category extraction
Styles Directory
Styles Directory
The
src/styles/ folder contains organized CSS files:- App.css - Global application styles and layout
- components.css - Component-specific styles (411 lines)
- pages.css - Page-specific styles (257 lines)
Key Files
App.js
The main application component that sets up routing and layout structure.Located at:
src/App.js:1Architecture Patterns
Component Organization
ReactFlix follows a component-based architecture where UI is broken into small, reusable pieces. Components are organized by function rather than feature.
State Management
ReactFlix uses a hybrid state management approach:- Local State: React’s
useStatefor component-specific state - Custom Hooks:
usePeliculaSearchfor shared search logic - Browser Storage:
localStoragefor persistent user data (rentals/purchases)
Data Flow
- Mock Data (
mockPeliculas.js) serves as the data source - Custom Hook (
usePeliculaSearch) processes and filters data - Pages consume hook data and pass to components
- Components render UI and handle user interactions
- localStorage persists user transactions
File Naming Conventions
Component Files
Component Files
- Format: PascalCase with
.jsxextension - Examples:
PeliculaCard.jsx,SearchBar.jsx - Reason: Distinguishes React components from regular JavaScript files
Hook Files
Hook Files
- Format: camelCase with
useprefix and.jsextension - Examples:
usePeliculaSearch.js - Reason: Follows React hook naming convention
Style Files
Style Files
- Format: kebab-case or lowercase with
.cssextension - Examples:
components.css,pages.css - Reason: Standard CSS file naming
Navigation
Routing
Learn about route configuration
Data Management
Understand data flow and storage
Styling
Explore the styling approach
Customization
Customize the application