How vilmaponce/sprint5 works
Project Type and Purpose
• This is a single‑page front‑end application built with React (via Vite) that provides a CRUD interface for “interstellar pets.”
• It leverages a mock external API (MockAPI) for data persistence, uses React Router for navigation, Context for global state, and various UI libraries for styling, animations, and alerts.
File Structure Analysis
• public/
• Static assets (images, videos, favicon).
• src/
• components/: Reusable UI pieces (Header, Footer, PetCard, PetForm, LoadingPlanet, StarCursor, GalaxyBackground, AdoptionModal).
• pages/: Route‑specific views (Home, PetList, PetDetail, PetCreate, PetEdit, AdoptedPets, NotFound).
• Router/: AppRouter.jsx defines route→page mapping.
• context/: PetContext.jsx provides global state and dispatch functions for pets.
• services/: api.js encapsulates all HTTP calls (get/list/create/update/delete).
• utils/: Validation schemas (petSchema), configuration for SweetAlert2 and toast notifications.
• main.jsx / App.jsx / App.css: Entry point, root component, and global styles.
Key Architectural Patterns
• Component‑based UI (React).
• Unidirectional data flow: Pages/components dispatch actions → Context → API calls → Context updates state → Components re‑render.
• Separation of concerns:
• UI in components and pages
• State management in Context
• Data access in services/api.js
• Validation and config in utils.
Main Components
a. Client Browser (User Interface)
b. React Application Layers:
• Presentation Layer: Pages & Components
• State Layer: PetContext (Provider & Consumer)
• Service Layer: api.js (Axios HTTP client)
• Utility Layer: petSchema, swalConfig, toastConfig
c. External Mock API Service
d. Static Asset Server (serving public/images, public/video)
e. Build & Dev Tools: Vite (bundler, dev server)
Relationships and Interactions
• From Context to api.js for HTTP operations.
• From api.js to External MockAPI (illustrate GET/POST/PUT/DELETE).
• Assets (images/videos) are fetched by Components at runtime from the public folder.
• Vite sits beneath the entire app, providing bundling and hot‑reload during development, and produces the final static bundle for deployment.
Architectural Notes
• The Router sits at the top of the React tree (AppRouter wraps pages).
• Context Provider wraps Router to give any page access to pet state/actions.
• Utility modules are side‑connected to both Context (for validation before dispatch) and Components (for alerts and toasts).