How phuuthanh-dev/pet-love-platform works
Main Components
• Frontend – This is built with React (using Vite, Redux, Tailwind, etc.) and contains pages, components, API service wrappers, context providers (such as a SocketProvider), and routing. It also includes a dedicated “ai” directory with Python scripts and models (for tasks such as dog breed prediction or similar functionality).
• Backend – A Node.js (likely Express-based) server organized using an MVC-like pattern. It is structured into directories such as:
– controllers (handling incoming HTTP requests, including authentication, blog, pet, donation, etc.)
– services (business logic for handling data)
– repositories (data persistence abstractions)
– models (data schema definitions, plugins for pagination and toJSON conversion)
– middlewares (authentication, error handling, validations)
– configurations and utilities (JWT, database connection, cloudinary integration, etc.)
– Socket integration (for real-time features like chat)
– Swagger/OpenAPI files for API documentation.
• Supporting Infrastructure – Dockerfiles for both frontend and backend, docker-compose.yml for container orchestration, CI/CD workflows in .github/workflows, and configuration files (ecosystem.config, eslint, prettier, etc.).
• External Services – Cloudinary for media management, potential external databases (implied by backend/src/utils/db.js), and possibly third-party integrations for payments, notifications, etc.
Out the Relationships and Interactions
• Frontend communicates with the Backend REST APIs to fetch and send data (authentication, pet details, adoptions, messaging, etc.).
• The Backend follows a layered architecture (controllers → services → repositories) to validate, process, and persist data.
• Real-Time Communication: A dedicated socket module in the backend supports functionalities like live chat or notifications, while the frontend integrates it through a SocketProvider.
• The AI component in the frontend (with Python scripts and pretrained models) may either operate independently or be called by the frontend to analyze data (for example, handling pet breed predictions or related processing).
• Docker and CI/CD components allow both frontend and backend to be containerized and deployed in a reliable manner.
Architectural Patterns and Design Principles
• MVC / Layered Architecture: Clear separation of concerns within the backend.
• Component-Based UI: The frontend is modular with reusable components, pages, and contexts.
• API-Driven Communication: RESTful endpoints defined via Swagger/OpenAPI documentation.
• Microservices-style Containerization: Using Docker (and docker-compose) to orchestrate and isolate services, ensuring clean separation between frontend, backend, and supporting processes.
• Repository and Service Patterns: Clean abstraction between data access (repositories) and business logic (services).