Foma Render Engine is a high-performance email rendering microservice designed for the Fordima Inc ecosystem. It transforms simplified templates in .fre format (standard HTML/CSS) into robust emails compatible with all email clients (Gmail, Outlook, Apple Mail, etc.).
-
Layout/View System: Separate the overall structure (header/footer) from the specific content.
-
Format .fre: Use standard HTML and CSS without worrying about email complexity.
-
Auto-Inlining: Automatically integrates CSS into HTML via Juice.
-
Handlebars Engine: Dynamic data injection and simple template logic.
-
Docker Ready: Instant deployment and complete isolation.
The engine expects to find a templates/ folder at the root:
/templates
├── layout.fre # The overall structure (must contain {{{body}}})
├── otp.fre # Example: Template for verification codes
└── welcome.fre # Example: Welcome Template
With Docker (Recommended)
-
Construct the image :
docker compose build
-
Launch the service :
docker compose up
The server will be available at http://localhost:3000.
Endpoint : POST /render
Request body (JSON) :
{
"template": "otp",
"data": {
"userName": "Fordi Malanda",
"code": "882941",
"companyName": "FomaBank",
"logoUrl": "https://cdn.foma.dev/logo.png"
}
}Example answer :
{
"success": true,
"html": "<!DOCTYPE html><html>...</html>"
}- The Layout (
layout.fre)
It defines the graphic charter. Important: You must include {{{body}}} where the specific content should be injected.
<html>
<style> .main { color: #333; } </style>
<body>
<div class="main">
{{{body}}}
</div>
</body>
</html>- The View (
otp.fre)
No need for or tags, focus on the message.
<h1>Code: {{code}}</h1>
<p>Hello {{userName}}, here is your Foma code.</p>Runtime: Node.js 22 (Alpine)
Framework: Fastify
Engines: Handlebars (Logic), Juice (CSS Inlining)
Port: 3000