How sachinggsingh/pawperfection works
Project type and purpose
• PawPerfection is a full-stack web application for personalized pet training.
• The frontend is built with React (Vite, Redux, Tailwind CSS), and the backend uses Node.js/Express with a MongoDB Atlas database. Authentication is handled via JWT/OAuth.
File structure
• Top level: two main directories, Backend and Frontend/client.
• Backend follows an MVC-style layout:
• /controllers – request handlers
• /models – Mongoose schemas for users, pets, training programs
• /routes – Express routers (user, pet, training)
• /middleware/auth.js – JWT validation
• index.js – application entry point, Express server setup
• Frontend is a single-page React app under client:
• /components, /pages – presentational and page components
• /redux – Redux slice for auth and store configuration
• /util/api.js – central API client for making HTTP calls
• Vite config and HTML entry point
• Common configuration: .gitignore, package.json files in both root and subdirectories.
Key architecture points from the README
• REST API layer (Express)
• MongoDB Atlas for data persistence
• JWT and third-party OAuth for authentication
• Cross-platform client (web) with offline mode (service workers or local cache)
• CI/CD via GitHub Actions (implied)
Main components
a. Frontend Application
• React SPA (pages, components, Redux store)
• Service worker or local storage for offline mode
b. API Gateway (Express server)
• Route handlers → Controllers → Models
• Auth middleware (JWT / OAuth integration)
c. Database
• MongoDB Atlas cluster (collections: users, pets, trainingPrograms)
d. External Services
• OAuth provider (Google/Facebook)
• Email/Notification service (reminders, schedules)
• Video CDN (host training tutorials)
e. CI/CD Pipeline
• GitHub Actions for build/test/deploy
Relationships & data flow
• User’s browser ↔ (HTTPS) → React frontend
• Frontend dispatches Redux actions → util/api.js → Express REST endpoints
• Express middleware validates JWT, calls controllers
• Controllers query/update MongoDB via models
• Controllers return JSON → frontend updates UI
• Offline mode: service worker intercepts network calls, serves cached assets/data
• For authentication: frontend redirects to OAuth provider, receives token, stores in Redux
Architectural patterns & design principles
• Client–Server separation (React vs. Express)
• MVC on the backend
• Flux (Redux) on the frontend
• RESTful API design
• Layered security: JWT, auth middleware
• Modular, folder-based separation of concerns
Detail level
• Major folder as a component: controllers, models, routes
• Redux store and API utility as separate pieces in the frontend
• Middleware chain in the backend
• Don’t overcomplicate—focus on clear, logical separation of concerns