How rioacosta/s5-02-virtual-pet-app-front works
Project type and purpose
• This is a front-end Single Page Application (SPA) for a “Virtual Pet App” built with React and Vite.
• It provides user authentication, a main dashboard, admin dashboard, pet detail views, creation flows, and a meditation session page, plus static assets (avatars, sounds, etc.).
File structure
Top-level folders & files
• public/ – static assets served at root (images, sounds)
• src/ – application source code
– App.jsx, main.jsx – React entry points
– config/config.js – app configuration (e.g., base API URL)
– pages/ – React page components (AuthPage, Dashboard, AdminDashboard, BuddyDetailPage, CreateBuddyPage, MeditationSessionPage)
– services/ – API client layer
· api.ts – axios instance or fetch wrapper with baseURL
· authService.ts – authentication endpoints
· adminService.ts – admin-only endpoints
– utils/ – helper functions (e.g., authUtils.ts)
• dist/ – production build artifacts
• vite.config.js – Vite build config
• .env, package.json, package-lock.json
Elements
– Clear labels for each component (e.g., “AuthService (src/services/authService.ts)”)
• Blue for UI components
• Green for service/API layer
• Orange for data stores
• Gray for static asset hosting
“Add all the path calls” – Extract and annotate each endpoint from the service files
AuthService (src/services/authService.ts)
• POST /api/auth/login
• POST /api/auth/register
• POST /api/auth/logout
• GET /api/auth/me
AdminService (src/services/adminService.ts)
• GET /api/admin/buddies
• GET /api/admin/buddies/:id
• POST /api/admin/buddies
• /api/admin/buddies/:id
• DELETE /api/admin/buddies/:id
• (similarly for users or other admin resources)
Generic API (src/services/api.ts)
• Base URL configured via src/config/config.js
• Interceptors for auth token injection
Other service calls implied by pages:
• GET /api/buddies
• GET /api/buddies/:id
• POST /api/buddies
• GET /api/sessions/:sessionId
• POST /api/sessions
Detail level guidance
• For each page component, show which service methods it invokes.
• Config.js baseURL usage.
• Public/assets folder as part of “Static Asset Host.”