How renatoamado/pokemon-symfony works
Project type and purpose
• This is a full-stack PHP web application built on the Symfony framework.
• It exposes a browser-accessible UI (Twig templates + static assets) and communicates with an external Pokémon TCG API to fetch card data.
• It persists data locally via Doctrine ORM and supports caching to improve performance.
Main components
a. Infrastructure / Deployment layer (Docker Compose)
• Nginx reverse-proxy (SSL termination)
• PHP-FPM container running the Symfony application
• Database container (e.g. MySQL/PostgreSQL from DATABASE_URL)
b. Entry point & Routing
• public/index.php (Symfony front controller)
• Symfony HTTP Kernel (config/routes + src/Controller)
c. Presentation layer (Frontend)
• Twig templates (templates/*.twig)
• Static assets: app.js, app.css (assets/)
d. Application layer (Backend services)
• Controllers (src/Controller/PokemonController.php)
• Services & Interfaces (PokemonService, CardProvider, CacheService, NonceGenerator)
• Transformers & DTOs (src/Transformer, src/DataTransferObject)
e. Domain / Persistence
• Entities (src/Entity) + Repositories (src/Repository)
• Doctrine Migrations (migrations/)
f. External systems
• Pokémon TCG API (pokemontcg.io) accessed via Pokémon TCG SDK
Relationships & data flow
• Browser → HTTPS request to Nginx → forwarded to PHP-FPM/Symfony
• Symfony front controller → Router → Controller
• Controller calls PokemonService →
• First, CacheService to check local cache (Doctrine)
• If cache miss, CardProvider calls external API via SDK
• Result wrapped in CardDTO, passed through Transformer
• Transformed data returned to Controller
• Controller renders Twig template, sending HTML back to browser
• On certain operations (e.g. caching), repositories persist entities to the database
Architectural patterns & design principles
• MVC (Controllers → Views via Twig)
• Layered/Hexagonal architecture (Controllers → Services → Repositories → DB)
• Dependency Injection (services configured in config/services.yaml)
• Interface-driven contracts (ServiceInterface for all core services)
• DTO & Transformer pattern to decouple API response from domain model
• Top layer: Browser → (HTTPS) Nginx
• Next: PHP-FPM / Symfony front controller
• Routing: config/routes.yaml → Controller
• Application services: PokemonServiceInterface → implementations (CacheService, CardProvider, NonceGenerator)
• Transformation: TransformerInterface → DTOs
• Persistence: Doctrine Repository → Database
• External: Pokémon TCG SDK → HTTP calls to pokemontcg.io
• Build/config scripts: composer, Dockerfiles, docker-compose.yml