How sdp-3-group-4/straycare-web works
Purpose and entry points
StrayCare is a full-stack social/rescue platform: authenticated users can create and engage with posts, chat, manage connections/bookmarks/notifications, locate clinics, apply for vet verification, and use a marketplace/cart flow. The React client starts at src/main.tsx and composes routing/application state in src/App.tsx. The NestJS API starts at straycare-backend/src/main.ts and assembles feature modules in straycare-backend/src/app.module.ts.
Client application shell
The frontend is a Vite TypeScript React SPA. Authentication state is centralized in src/contexts/AuthContext.tsx; cart state is separately shared through src/contexts/CartContext.tsx. Firebase client setup resides in src/firebase.ts. Protected content is gated by src/components/auth/ProtectedRoute.tsx, separating public authentication UI (src/pages/AuthPage.tsx) from the signed-in home experience (src/pages/HomeFeedPage.tsx).
Home feed and social interaction surface
src/pages/HomeFeedPage.tsx is the signed-in composition boundary for desktop/mobile navigation, central feed content, side panels, and overlays. Feed views specialize by domain—posts/profile/bookmarks/notifications/marketplace—under src/components/home/feed/CenterFeed.tsx, src/components/home/feed/PostCard.tsx, and src/components/home/feed/MarketplaceFeed.tsx. User actions such as post creation, comments, likes, bookmarks, profile edits, and donations flow through the frontend API layer at src/services/api.ts to corresponding backend modules.
Backend API and authorization boundary
Nest feature modules expose controller/service pairs for domain APIs. Firebase token validation is the primary request-security boundary via straycare-backend/src/auth/firebase-auth.guard.ts and Firebase server integration in straycare-backend/src/firebase/firebase.service.ts. Public-route exceptions are explicitly marked through straycare-backend/src/auth/public.decorator.ts. Core social APIs are implemented by straycare-backend/src/posts/posts.controller.ts, straycare-backend/src/comments/comments.controller.ts, and straycare-backend/src/connections/connections.controller.ts.
Persistence and domain services
Prisma is the backend persistence abstraction, with the canonical model and migration history in straycare-backend/prisma/schema.prisma and straycare-backend/prisma/migrations/. All feature services use the shared database layer from straycare-backend/src/prisma/prisma.service.ts. Major persisted domains include users, posts/media, interactions, conversations, marketplace data, notifications, and vet applications, represented by modules such as straycare-backend/src/users/users.service.ts, straycare-backend/src/chat/chat.service.ts, and straycare-backend/src/marketplace/marketplace.service.ts.
Commerce, location, and verification
Marketplace browsing and checkout UI are handled by src/components/home/feed/MarketplaceProductModal.tsx and src/components/home/feed/MarketplaceCheckoutModal.tsx, with client payment integration isolated in src/services/payments.ts and server-side marketplace operations in straycare-backend/src/marketplace/marketplace.service.ts. Clinic proximity begins with browser/user location logic in src/hooks/useUserLocation.ts and geographic utilities in src/utils/geo.ts. Vet verification submits to the dedicated server workflow at straycare-backend/src/vet-applications/vet-applications.controller.ts.
AI and deployment infrastructure
An AI rescue/response capability is isolated behind straycare-backend/src/ai/ai-bot.controller.ts, straycare-backend/src/ai/auto-response.service.ts, and straycare-backend/src/ai/nim.service.ts, keeping model-provider calls outside core social services. The frontend is configured for Firebase Hosting through firebase.json; Firebase is also the identity provider. The backend is containerizable via straycare-backend/Dockerfile and straycare-backend/docker-compose.yml, with environment-specific external credentials expected through its .env.example.
Main entry points: App.tsx Application shell · app.module.ts Feature assembly · HomeFeedPage.tsx Signed-in home · MarketplaceCheckoutModal.tsx Marketplace checkout
Components 24
React Client
- Client entry
src/main.tsx - Application shell
src/App.tsx - Auth state
src/contexts/AuthContext.tsx - Cart state
src/contexts/CartContext.tsx - Firebase client
src/firebase.ts - Protected routes
src/components/auth/ProtectedRoute.tsx - Authentication UI
src/pages/AuthPage.tsx - Signed-in home · Composes navigation, feed, panels, and overlays.
src/pages/HomeFeedPage.tsx - Social feed
src/components/home/feed/CenterFeed.tsx - Marketplace checkout
src/components/home/feed/MarketplaceCheckoutModal.tsx - Frontend API layer
src/services/api.ts - Payment integration
src/services/payments.ts
NestJS API
- API entry
straycare-backend/src/main.ts - Feature assembly
straycare-backend/src/app.module.ts - Firebase auth guard · Public endpoints opt out through the public decorator.
straycare-backend/src/auth/firebase-auth.guard.ts - Social APIs
straycare-backend/src/posts/posts.controller.ts - Domain services
straycare-backend/src/marketplace/marketplace.service.ts - Vet verification
straycare-backend/src/vet-applications/vet-applications.controller.ts - AI rescue responses
straycare-backend/src/ai/ai-bot.controller.ts
Data & Integrations
- Prisma database layer
straycare-backend/src/prisma/prisma.service.ts - Data model & migrations · Defines persisted social, chat, commerce, notification, and vet domains.
straycare-backend/prisma/schema.prisma - Firebase server integration
straycare-backend/src/firebase/firebase.service.ts
Deployment
- Firebase Hosting
firebase.json - Backend container
straycare-backend/Dockerfile
Connections 25
- Client entry → Application shell: mounts
- Application shell → Auth state: provides
- Application shell → Cart state: provides
- Firebase client → Auth state: authenticates
- Application shell → Authentication UI: public route
- Application shell → Protected routes: gates signed-in routes
- Protected routes → Signed-in home: allows
- Signed-in home → Social feed: composes
- Signed-in home → Marketplace checkout: opens
- Social feed → Frontend API layer: social actions
- Marketplace checkout → Frontend API layer: catalog and orders
- Marketplace checkout → Payment integration: payment flow
- Frontend API layer → API entry: API requests
- API entry → Feature assembly: boots
- Feature assembly → Firebase auth guard: applies
- Firebase auth guard → Firebase server integration: validates tokens with
- Feature assembly → Social APIs: registers
- Feature assembly → Vet verification: registers
- Feature assembly → AI rescue responses: registers
- Social APIs → Domain services: delegates to
- Vet verification → Prisma database layer: persists applications
- Domain services → Prisma database layer: reads and writes
- Prisma database layer → Data model & migrations: uses model
- Firebase Hosting → Client entry: serves SPA
- Backend container → API entry: runs