r/softwarearchitecture • u/Sweet-Yoghurt-7097 • 9d ago
Discussion/Advice C++/Qt legacy app: one API or two (C++ + FastAPI)?
We need to build an API for the industry on top of a big legacy C++/Qt codebase. The plan is to move some features to FastAPI and have it call a C++ API for the rest because to complex to move in fasAPI
Two APIs seems like a bad idea to me. I'd rather build a single API in C++.
Thoughts?
EDIT context++: 20+ year old C++/Qt codebase, complex but stable in prod. Goal: turn 100+ .exe into lighter apps via APIs. Small team (4, 5), strong in C++, weak in Python, same people maintaining for the next 2 years. Expected features: AD authentication, load handling, replication. My worry: C++ frameworks like Drogon may not be as mature as FastAPI for that.
3
u/guac-o 9d ago
Only way to answer is to understand the context much better which is impossible with the sparse detail in OPs post.
Sometimes a thin façade is an ok tradeoff.
3
u/Any-Appointment-814 9d ago
Two APIs isn't automatically bad, two public ones is. I'd keep exactly one thing the outside world talks to, and if that's FastAPI then the C++ side becomes an internal service with a small boring contract that only FastAPI calls. What usually bites people in this setup is the same business rule ending up half in Python and half in C++, so I'd split by feature area and have each feature fully owned by one side, not "easy stuff moves, hard stuff stays". Honestly if most of the logic is staying in C++ for years anyway, a single C++ API is probably less pain.
2
u/Ok-Peak-8516 9d ago
Why not expose the existing C++ functionality through a Drogon-based service?
1
u/CzyDePL 9d ago
My thoughts are that "seems like a bad idea to me" is not a very strong argument
1
u/_descri_ 9d ago
Widely used C or C++ libraries tend to expose APIs or bindings for multiple programming languages to let clients users plug them into whatever code they write.
Thus I suggest to study your users, their needs, tools, and expectations, then implement whatever is good for most of them. If that works well, you'll be able to extend it, or add a new API for another group of users.
You may consider having a simple API for most users and an in-depth functionality as an extension - that will make your system both easy to learn and highly flexible. You should provide a sample application code for your simple API in the documentation.
Volume 4 of Pattern-Oriented Software Architecture has a chapter on Interface Partitioning. There are several good patterns such as COMBINED METHOD, ENUMERATION METHOD, and BATCH METHOD which may save the day if you need your API to have high performance.
1
u/codewithdeekeej 8d ago
I'd worry less about the number of APIs and more about the number of places
business logic lives.
Two layers is fine if the Python one is a dumb front door: auth, routing,
rate limits, nothing else. It turns bad the moment a feature is half in
FastAPI and half in C++, because then every bug needs both skill sets and
your team has one of them.
Given 4-5 people who are strong in C++ and will own this for two years, I'd
keep all logic in one C++ service and not write the boring parts in either
language. AD auth, TLS and load handling can sit in an off-the-shelf reverse
proxy or gateway in front of it. That also takes most of the pressure off
the "is Drogon mature enough" question, since the framework only has to
serve requests.
Before committing, I'd wrap one of the 100 exes end to end as a pilot. In
my experience the hard part is rarely the HTTP framework. It's the old code
assuming one process per user, global state, or a Qt event loop being
around. Better to find that out on exe number one.
0
u/SideMost3148 8d ago
two APIs mostly hurts at release time. every change ends up touching two deploys and two sets of docs, and a year in nobody remembers which side owns what
if your team is mostly python people though, fastapi in front with the c++ part as an internal thing nobody outside ever calls is pretty normal. where it goes bad is when the c++ api quietly becomes public too because one client needed it "just for now"
who's maintaining this in 2 years? that decides it more than the architecture tbh
0
u/LanguidPragmatism 8d ago
Put Nginx in front for auth over one C== APi rather than splitting a small team rn