Build a FastAPI summarization service

Quick Overview

This question evaluates web API development and backend engineering competencies, including FastAPI usage, Python type hints, Pydantic-based request/response validation, error handling, in-memory state management, and modular router/service/model layering, and it belongs to the Coding & Algorithms category with a focus on backend web service and API design. It is commonly asked to assess practical ability to deliver production-ready REST endpoints with proper validation and error handling under constrained resources, and the level of abstraction required is primarily practical implementation with attention to architectural design.

Build a FastAPI summarization service

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Implement a minimal but production-ready FastAPI service for text summarization. Requirements: - Expose an endpoint `POST /summarize`. - The request body is JSON: `{ "text": string }`. - The response body is JSON: `{ "summary": string }`. - The summarization logic can be a placeholder function; you do not need to call a real model. - Store each request and response pair in memory. Engineering requirements: - Use a clean structure with separate router, service, and model layers. - Use type hints throughout. - Use Pydantic models for request and response validation. - Handle invalid input and unexpected errors properly. - Keep the code modular, readable, and simple. - Do not use a database; in-memory storage is sufficient. What to provide: - Show the proposed file structure. - Then provide the code for each file.

Overview: This question evaluates web API development and backend engineering competencies, including FastAPI usage, Python type hints, Pydantic-based request/response validation, error handling, in-memory state management, and modular router/service/model layering, and it belongs to the Coding & Algorithms category with a focus on backend web service and API design. It is commonly asked to assess practical ability to deliver production-ready REST endpoints with proper validation and error handling under constrained resources, and the level of abstraction required is primarily practical implementation with attention to architectural design.

Meta logo
Meta
Jan 19, 2026
mediumSoftware EngineerOnsiteCoding & Algorithms
9
0

Implement a minimal but production-ready FastAPI service for text summarization.

Requirements:

  • Expose an endpoint POST /summarize .
  • The request body is JSON: { "text": string } .
  • The response body is JSON: { "summary": string } .
  • The summarization logic can be a placeholder function; you do not need to call a real model.
  • Store each request and response pair in memory.

Engineering requirements:

  • Use a clean structure with separate router, service, and model layers.
  • Use type hints throughout.
  • Use Pydantic models for request and response validation.
  • Handle invalid input and unexpected errors properly.
  • Keep the code modular, readable, and simple.
  • Do not use a database; in-memory storage is sufficient.

What to provide:

  • Show the proposed file structure.
  • Then provide the code for each file.