How carl-joshua-fabregas/sp2_uppet_mobile_app works
UPPet is a two-part mobile system: an Expo/React Native client in frontend/uppet and a Node/Express backend in backend. The app is centered on peer-to-peer pet adoption for a specific locality, so the architecture is domain-heavy rather than generic CRUD-only.
1. Client boundary
- The frontend is a mobile app built with Expo.
- Navigation is organized with app/ routes, including a drawer shell and tab-based sections for home, messages, my adoptees, and notifications.
- Screen-level pages such as pet profiles, adopter profiles, application views, and chat screens sit alongside reusable UI cards and modals in component/.
2. Frontend state and communication
- The app uses axios in frontend/uppet/api/axios.js to talk to the backend HTTP API.
- Shared client state is split into contexts: UserContext for user/session data, ChatContext for chat state, and SocketContext for realtime connectivity.
- This indicates a clear separation between navigation/UI, request logic, and cross-screen state.
3. Backend structure
- The backend follows a layered Express pattern: routes -> controllers -> services -> models.
- Routes expose domain endpoints, controllers handle request/response logic, services hold reusable business workflows, and models represent persistence objects.
- This makes the backend easy to diagram as a set of domain modules rather than one monolithic API.
4. Domain model boundaries
- Core entities include Adopter, Pet, AdoptionApplication, Match, ChatThread, Messages, Notification, and Rating.
- These are separate subsystems with their own controllers and routes, which suggests the app supports the full adoption lifecycle: profile creation, pet listing, application submission, matching, messaging, notifications, and post-adoption feedback.
5. Adoption workflow
- The main flow appears to be: an adopter creates a profile, a pet owner creates a pet profile, the adopter submits an adoption application, and a match is created when accepted.
- Dedicated routes/controllers for adopters, pets, applications, and matches show that matching is a first-class business process, not just a simple listing/search feature.
6. Messaging and realtime chat
- Chat is split into threads and messages, with both standard API controllers and service helpers.
- The presence of socket.js, SocketController.js, and socketMiddleware.js strongly suggests realtime updates for chat and possibly notifications through Socket.IO or a similar websocket layer.
- This is a key architectural boundary: HTTP for persistence/query, sockets for live delivery.
7. Authentication and authorization
- authController, authRouter, and authMiddleware define the authentication boundary.
- Protected routes likely gate profile edits, application actions, messaging, and owner-only operations.
- The frontend’s user context likely mirrors authenticated identity/session state from the backend.
8. Persistence and seed data
- The models/ directory suggests a document-model ORM/ODM setup, likely backed by MongoDB through database/config/database.js.
- The database/ folder contains CSV seed files and seed.js, which implies the repo includes predefined demo data or initial dataset loading for adopters, pets, applications, chats, messages, notifications, and ratings.
- This is useful for local setup and for diagramming initial data bootstrap separately from runtime traffic.
9. Infrastructure and external services
- backend/config/aws.js indicates integration with AWS-backed services, likely for media or asset storage.
- On the frontend, app.json, eas.json, and the README’s build instructions show the app is packaged and distributed through Expo EAS, with Android builds as the primary mobile deployment path.
10. End-to-end data flow
- Typical request flow is: mobile screen action -> axios request -> backend route -> controller -> service/model -> database -> JSON response.
- For live chat or presence-like updates, the flow shifts to socket connection -> socket middleware/controller -> message/thread processing -> broadcast to clients.
- Notifications likely follow a similar pattern, combining persisted records with realtime delivery.
11. What to draw as major subsystems
- A mobile client boundary with screens, reusable components, and contexts.
- An API boundary with modular domain routes/controllers/services.
- A persistence boundary with entity models and seeded dataset files.
- A realtime boundary for chat/notifications.
- An external storage/build boundary for AWS integration and Expo EAS mobile packaging.
Main entry points: SocketController.js Socket bridge · models Domain models · index.jsx Screens · controller Controllers
Components 17
Mobile client
Expo/React Native app and shared UI/state
- App shell · Root Expo routes with drawer and tab navigation
frontend/uppet/app - Screens · Profile, adoption, message, and gallery screens
frontend/uppet/app/index.jsx - UI cards · Reusable cards, modals, and step-based creation flows
frontend/uppet/component - Contexts · User, chat, and socket shared state
frontend/uppet/context - API client · HTTP bridge from the mobile app to the backend
frontend/uppet/api/axios.js
Backend API
Express routes, controllers, services, and auth
- Routes · Domain route entrypoints for auth, pets, applications, chat, matches, messages, notifications, and ratings
backend/routes - Controllers · HTTP request/response handlers for each domain area
backend/controller - Services · Reusable matching and messaging logic
backend/services - Auth boundary · Authentication and protected-route enforcement
backend/middleware/authMiddleware.js
Realtime layer
Socket-driven chat and live updates
- Socket bridge · Socket.IO-style connection handling for live updates
backend/controller/SocketController.js - Socket config · Socket server wiring and middleware for connections
backend/config/socket.js - Socket middleware · Connection-time socket validation and attachment
backend/middleware/socketMiddleware.js
Data layer
Models, database config, and seed data
- Domain models · Adopter, pet, application, match, chat, message, notification, and rating models
backend/models - DB config · Database connection and persistence initialization
backend/config/database.js - Seed data · CSV fixtures and seed loader for demo/local initialization
database/seed.js
Infrastructure
External services and mobile build packaging
- AWS config · Cloud storage integration for media or assets
backend/config/aws.js - Expo build · EAS and Expo app packaging configuration
frontend/uppet/eas.json
Connections 21
- App shell → Screens: navigates to · Drawer and tab routes open screen-level views
- App shell → UI cards: composes · Screens are built from shared cards, modals, and creation steps
- Screens → API client: requests via · User actions trigger HTTP calls through axios
- Screens → Contexts: reads state · Screens consume shared user, chat, and socket state
- UI cards → Contexts: updates state · Creation flows and cards interact with shared client state
- API client → Routes: calls · Mobile API requests enter the Express route layer
- Routes → Auth boundary: protects · Protected endpoints pass through authentication middleware
- Routes → Controllers: dispatches to · Routers hand requests to domain controllers
- Controllers → Services: delegates to · Controllers reuse workflow logic for matching and messaging
- Controllers → Domain models: reads/writes · Controllers persist and query domain records through models
- Services → Domain models: operates on · Business services coordinate across persistence models
- Domain models → DB config: connects through · Models are backed by the configured database connection
- Seed data → Domain models: loads · Seed scripts populate the domain entities
- Socket config → Socket bridge: initializes · Socket server setup connects the realtime controller
- Socket middleware → Socket bridge: guards · Socket connections pass through middleware before handling
- Socket bridge → Services: reuses · Realtime events can invoke message and matching workflows
- Socket bridge → Domain models: broadcasts from · Live events are driven by persisted chat and notification data
- Controllers → Socket bridge: notifies · HTTP actions may trigger live socket updates
- Screens → Socket bridge: listens on · Chat and notification screens receive realtime updates
- Domain models → AWS config: uses · Domain data may reference cloud-backed assets
- App shell → Expo build: packages with · The mobile client is built and distributed through Expo EAS