Elixir/Phoenix service for generating link previews with WhatsApp-style metadata extraction.
- Open Graph/Twitter metadata parsing
- Concurrent request handling
- Auto-scale across CPU cores
- Elixir 1.15+
- Erlang OTP 26+
- Install dependencies:
mix deps.get
- Start server:
mix phx.server
curl "http://localhost:4000/api/v1/preview?url=https://example.com"
Sample Response:
{
"title": "Example Domain",
"description": "This domain is for use in illustrative examples...",
"image": "https://example.com/og-image.jpg",
"url": "https://example.com"
}
- Production build:
MIX_ENV=prod mix release
- Run with maximum CPU utilization:
ERL_FLAGS="+S 4:4" _build/prod/rel/rich_preview/bin/rich_preview start
FROM elixir:1.15
WORKDIR /app
COPY . .
RUN mix local.hex --force && \
mix local.rebar --force && \
mix deps.get && \
mix release
CMD ["_build/prod/rel/rich_preview/bin/rich_preview", "start"]
- Processes ≠ Threads: 1MB memory footprint vs 10KB
Task.async
≈ Concurrent::Promise but more lightweight- Pattern matching ≈ case/when with type checking