---
title: "One Core, Two Interfaces, No Rewrites"
url: https://daily.dev/posts/one-core-two-interfaces-no-rewrites-g1a1au956
source_url: https://belderbos.dev/blog/two-interfaces-one-core
type: article
source: "Planet Python"
published: 2026-07-04T19:52:57.679Z
updated: 2026-07-05T14:20:54.374Z
tags: ["python", "architecture", "vector-search", "fastapi"]
reading_time: 6
upvotes: 2
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# One Core, Two Interfaces, No Rewrites

**[Planet Python](https://daily.dev/sources/planetpython)** · 6 min read · 2 upvotes · 0 comments

## Summary

A walkthrough of building a shared functional core that powers both a CLI and a FastAPI web app without duplicating logic. Key patterns covered include pure functions as the shared spine, using Python's `@cache` decorator for memoized library loading, FastAPI's `lifespan` context for pre-warming the vector matrix and PyTorch model before the first request, and lazy imports to ensure Hugging Face offline environment variables are set before `sentence-transformers` loads. The post argues that classes are unnecessary here — NamedTuples and memoized functions handle all state — and that adding a third interface later requires only importing the same core functions.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://belderbos.dev/blog/two-interfaces-one-core>

## Similar posts on daily.dev

- [Why are we talking about architecture again?](https://daily.dev/posts/why-are-we-talking-about-architecture-again--qeiyintcw) · ITNEXT · 17 upvotes · 2 comments
- [FastAPI for MLOps: Python Project Structure and API Best Practices](https://daily.dev/posts/fastapi-for-mlops-python-project-structure-and-api-best-practices-kxffyyikd) · PyImageSearch · 3 upvotes · 0 comments
- [Google Testing Blog: Simplify Your Code: Functional Core, Imperative Shell](https://daily.dev/posts/google-testing-blog-simplify-your-code-functional-core-imperative-shell-v9gndb9hq) · Google Testing · 3 upvotes · 0 comments
- [Revisiting the Just Eat Takeaway iOS Modular Architecture in 2026](https://daily.dev/posts/revisiting-the-just-eat-takeaway-ios-modular-architecture-in-2026-rw14gvrvl) · Medium · 0 upvotes · 0 comments
- [How to use AI to generate type-safe Python code that survives production](https://daily.dev/posts/how-to-use-ai-to-generate-type-safe-python-code-that-survives-production-vasuplwtd) · All Things Open · 1 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python), [#architecture](https://daily.dev/tags/architecture), [#vector-search](https://daily.dev/tags/vector-search), [#fastapi](https://daily.dev/tags/fastapi)

[View this post on daily.dev](https://daily.dev/posts/one-core-two-interfaces-no-rewrites-g1a1au956)
