A PHP-based web service that authenticates with an API, retrieves task data, and generates downloadable PDF documents from the data. Built with clean architecture principles and a distributed system approach.
- Authentication with the BauBuddy API
- Secure token caching using Redis
- Task data retrieval from the API
- Dynamic HTML generation from task data
- PDF creation using wkhtmltopdf
- Background worker for notifications
- RESTful API with Swagger documentation
- Health check endpoint for monitoring
- PHP 8.4
- Slim Framework 4
- Docker & Docker Compose
- Redis for caching and messaging
- Nginx as web server
- wkhtmltopdf for PDF generation
The project follows clean architecture principles with the following layers:
- Domain: Core business logic, entities, and interfaces
- Application: Use cases, controllers, and middleware
- Infrastructure: External services, repositories, and frameworks
- Docker and Docker Compose
- Git
-
Clone the repository:
git clone https://github.com/zekiunal/vero.git cd vero -
Create a
.envfile with the following content:API_BASE_URL=https://api.baubuddy.de REDIS_HOST=redis REDIS_PORT=6379 DISPLAY_ERROR_DETAILS=true LOG_ERRORS=true LOG_ERROR_DETAILS=true API_VERSION=1.0.0 -
Build and start the Docker containers:
docker compose up -d --build
-
Install dependencies:
docker compose exec app composer install
http://localhost:8080/index.html
To generate a PDF, make a GET request to the /service endpoint with username and password parameters:
GET http://localhost:8080/service?username=365&password=1
The service will respond with a PDF file for download.
To check the health of the service:
GET http://localhost:8080/health
The API documentation is available at:
GET http://localhost:8080/api/docs
- Entities: Domain objects like
Task - Repositories: Data access interfaces and implementations
- Services: Business logic components for authentication, PDF generation, etc.
- Use Cases: Application-specific business rules
- Controllers: HTTP request handlers
- Middleware: Request/response processors
- Workers: Background processes for asynchronous operations
- A request comes in with username and password
- The service authenticates with the BauBuddy API
- The service fetches task data from the API
- Tasks are transformed into a formatted HTML document
- The HTML is converted to PDF using wkhtmltopdf
- The PDF is sent as a downloadable response
- Notifications are published to Redis for the worker to process
The service includes a background worker that processes notifications published to Redis. The worker subscribes to the notifications channel and processes messages in real-time.
The worker is automatically started as part of the Docker Compose setup. If you need to restart it manually:
docker compose restart workerThe service is containerized using Docker, making it easy to deploy in any environment that supports Docker containers.
For production deployments, consider:
- Setting up a reverse proxy with SSL termination
- Configuring proper logging with log rotation
- Using a Redis cluster for improved reliability
- Setting appropriate resource limits for containers
- Implementing monitoring and alerting
The service provides a Swagger UI interface for API exploration. The documentation includes:
- Endpoints description
- Request parameters
- Response formats
- Response codes
- Example requests
GET http://localhost:8080/api/docs
The Swagger JSON specification is available at:
GET http://localhost:8080/api/docs/json
This project is licensed under the MIT License - see the LICENSE file for details.