How catamc90/auto-parts-catalog works
Project Type and Purpose
• This is a full-stack web application built on Symfony 7.1.
• It consumes an external Auto Parts Catalog API (via RapidAPI) to display part identification, cross-referencing, compatibility, and ordering data.
• It follows the MVC (Model-View-Controller) pattern with Twig templates for views and Doctrine ORM for persistence.
Main Components
A. Client (Browser)
– HTML/CSS/JS delivered by Symfony’s AssetMapper & Importmap.
– Interactive UI controllers under assets/controllers/*.js.
– Twig templates under templates/ generate UI markup.
B. Web Server / Entry Point
– public/index.php → Bootstraps Symfony Kernel.
– Symfony HTTP kernel handles routing & middleware.
C. Controllers (src/Controller)
– HomeController, ManufacturersController, ModelsController, TypesController, CategoryController, ArticlesController.
– Each maps routes (config/routes.yaml) to actions that orchestrate data flows.
D. Services / API Clients (src/Api)
– CatalogApi.php: encapsulates HTTP calls to the external RapidAPI Auto Parts Catalog.
– RapidBaseApi.php: base client for handling authentication, request/response logic.
E. Domain Layer
– Entities (src/Entity): Doctrine entities for local persistence of catalogs, caching or any domain objects you choose to store.
– Repositories (src/Repository): data access layer for Entities.
– Form Types (src/Form/Type): define form schema for search, language selection, quick-search.
F. Persistence & Caching
– Database (configured under config/packages/doctrine.yaml).
– Doctrine Migrations (migrations/) for schema evolution.
G. Infrastructure & Cross-Cutting Concerns
– Security (config/packages/security.yaml) if user auth is needed.
– Messenger (config/packages/messenger.yaml) for async tasks (e.g., batch imports).
– Monolog (logging), Mailer, Notifier, Web Profiler, etc.
H. External Dependencies
– RapidAPI Auto Parts Catalog API.
– Any third-party services configured in .env (RAPIDAPI_KEY).
Relationships & Data Flow
1. User → Browser UI (Twig + JS)
2. Browser → HTTP Request → public/index.php → Symfony Kernel
3. Kernel → Router → Appropriate Controller
4. Controller
a. Validates input (Forms, Validators).
b. Invokes CatalogApi service or local Repository.
c. Persists or caches results if needed.
d. Passes data to Twig template.
5. Twig → Renders HTML → Response → Browser
6. Browser → Displays UI; optional AJAX calls to controllers (via asset JS controllers).
7. Service calls → External API → API responses → Service layer → Controller.
Architectural Patterns & Principles
• MVC: clear separation of Models (Entities), Views (Twig), Controllers.
• Service Layer: CatalogApi encapsulates all external API logic.
• Dependency Injection: Symfony services defined in config/services.yaml.
• Layered Architecture: Presentation → Application → Domain → Infrastructure.
• Config-First: YAML config for routing, services, packages.
• Asset Management: Importmap + AssetMapper decouples JS/CSS delivery.