How khoasinno/homex-symfony works
This project is a Symfony-based online appointment booking system for a healthcare environment. It includes multiple user interfaces (for administrators, doctors, and patients) along with integrations for external services such as Google OAuth for login and Momo for payment processing. The project follows the typical MVC pattern enhanced by Symfony’s structure, using Doctrine for database interactions, Twig for templating, and a rich set of front-end assets (including CKEditor and theme assets for admin and customer interfaces).
Main Components
• Frontend Clients: Represent the three major interfaces:
• Admin Interface (located in public/admin with its own assets, HTML templates, and CSS)
• Customer/Patient Interface (in public/customer, with dedicated assets and templates)
• Public/General Interface (the main public index and home pages)
• Backend – Symfony Application:
• Core application kernel, routing (configured in config/routes* and services in config/services.yaml)
• Controllers organized under src/Controller (sub-folders for Admin, Doctor, Patient, and others such as Registration and Security)
• Business Logic & Services (under src/Service with components like MailService, MomoService, ScheduleService, and ImageUploader)
• Entities and Repositories (for Appointment, User, Specialty, ScheduleWork, etc. in src/Entity and src/Repository)
• DataFixtures and Migrations for database seeding and schema management
• External Integrations:
• Google OAuth (using the knpuniversity/oauth2-client-bundle and a custom GoogleAuthenticator in src/Security)
• Momo Payment Gateway (as seen in the MomoController and related service integration)
• Database:
• The Doctrine-managed database where all entities are persisted. This can be visualized as a central datastore interacting with the business logic layer.
• Assets & Static Files:
• JavaScript, CSS, and multimedia assets found in the assets and public directories (including CKEditor libraries and plugins).
Relationships and Data Flows
• User requests (from browsers or mobile devices) first hit the public folder and are routed into the Symfony kernel.
• The routing component dispatches requests to the appropriate controller based on URL (e.g., admin routes, patient routes, security routes).
• Controllers interact with services for business operations, such as scheduling appointments, sending mail notifications, or handling external API calls.
• The services layer processes logic and interacts with repositories to perform queries and persist data into the database.
• External services are invoked:
• For authentication, the Google OAuth process is handled via the GoogleAuthenticator and related client configuration.
• For financial transactions, the MomoService communicates with the Momo API, retrieving payment URLs or deeplink data.
• Responses are rendered using Twig templates and served back to the client.
Important Architectural Patterns and Design Principles
• MVC Pattern: Clearly distinguish between models (entities), views (Twig templates), and controllers (routing and business logic).
• Service-Oriented Architecture within Symfony: Business logic is delegated to individual services (e.g., MailService, ScheduleService, ImageUploader).
• Integration with External Systems: Use of OAuth2 and third-party payment gateways shows a modular approach for external dependencies.
• Layer separation: Frontend assets, backend logic, and configuration files are stored in distinct directories, ensuring maintainability and scalability.
Representing Technologies and Frameworks
• Symfony framework (routing, controllers, kernel, security)
• Doctrine ORM for database management
• Twig templating engine for views
• CKEditor for rich text editing integrated in the admin/customer interfaces
• External libraries such as knpuniversity/oauth2-client-bundle, league/oauth2-google, and Momo’s API integration.
• Composer for dependency management
• Clear labels for every component (e.g., “Admin Controller”, “DoctorController”, “Doctrine Repository”, “GoogleAuthenticator”, “MomoService”).
• How user requests traverse from the client (browser) to Symfony’s routing and into Controllers.
• How Controllers invoke Services, which in turn interact with the Database or external APIs.
• Annotations for configuration files (e.g., config/routes.yaml, config/services.yaml) where key integrations like the OAuth2 configurations are set.
• Entry point into the Symfony backend (public/index.php → Kernel).
• Expand the backend component to detail the controllers (grouped by function), the services layer, and data repositories.
• External integrations:
• The flow of Google OAuth login via GoogleAuthenticator and related configuration.
• The communication with the Momo Payment Gateway from the MomoService / MomoController.
• Finally, display the database and emphasize the communication to/from Doctrine ORM.