How zomato/espresso works
Main Components
• Frontend (espresso-ui):
• This is built in Next.js (as seen by next.config.ts, package.json, and Next.js–like folder structure under src/app) and provides a browser-based UI for managing templates and document creation.
• Backend Service (service):
• Implemented in Go (service/main.go, controller for PDF generation, and various configurations).
• Exposes REST APIs for PDF generation and signing.
• Contains controllers (e.g., service/controller/pdf_generation) and internal services (e.g., service/internal/service/generateDoc) that handle document creation workflow.
• Core Libraries (lib):
• Modules like renderer, signer, templatestore, and workerpool abstract and encapsulate core logic.
• For example, the renderer converts HTML/CSS to PDF, the signer handles digital signing using X.509 certificates, and templatestore provides storage interaction with S3, MySQL, or disk.
• Auxiliary Components:
• GitHub workflows, Dockerfiles, and Makefile indicate continuous integration/deployment and containerized deployment.
• Documentation (docs/Integration.md, docs/QuickStart.md) supports deployment and integration.
Out Relationships and Interactions
• The Frontend interacts with the Backend Service via REST API calls.
• The Backend Service routes incoming requests to the appropriate controller (i.e., the PDF generation controller).
• The controller then invokes internal services (generateDoc) that coordinate with the libraries:
• The Renderer module (from lib/renderer) converts HTML templates to PDFs.
• The Signer module (from lib/signer) digitally signs the generated PDFs.
• The Template Store (from lib/templatestore) fetches and manages the templates, possibly utilizing different back-ends (S3, MySQL, Disk).
• The Worker Pool (from lib/workerpool) illustrates how tasks may be executed concurrently to handle peak loads.
• External dependencies and integrations (e.g., certificates for signing, cloud storage for S3) should also be depicted.
Architectural Patterns & Design Principles
• Separation of Concerns: Different modules handle distinct tasks (rendering, signing, storage).
• Modular Design: Core functionality is abstracted in libraries making the system extensible.
• API-Driven Interaction: The service layer exposes a REST API used by the UI.
• Containerization: Dockerfiles and Docker Compose setup indicate container-based deployments.
• High Performance & Scalability: Use of worker pools and efficient, specialized modules is fundamental.
Relevant Technologies
• Frontend: Next.js, React, JavaScript/TypeScript.
• Backend: Go (with modules for PDF generation, digital signing, and templating).
• Container Tools: Docker, Docker Compose.
• Additional Tools: GitHub Actions (CI/CD workflows) and pre-commit hooks (for code quality enforcement).