r/softwarearchitecture • • 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.

6 Upvotes

19 comments sorted by

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.

1

u/Sweet-Yoghurt-7097 8d ago

Fair, added context in an edit. Short version: small C++ team, 20+ year legacy, and we'll need AD auth, load handling and replication. Does a thin façade still make sense to you?

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.

1

u/Sweet-Yoghurt-7097 8d ago

Great point on splitting by feature, not "easy vs hard". One public entry point plus an internal C++ service is probably the cleanest two-API version. FastAPI also makes AD auth and that kind of tooling a lot easier than in C++.

1

u/Any-Appointment-814 8d ago

Yeah, that is the version I keep coming back to too. Keep one public entry point and leave the C++ service internal.

2

u/Ok-Peak-8516 9d ago

Why not expose the existing C++ functionality through a Drogon-based service?

1

u/Sweet-Yoghurt-7097 8d ago

Considered it. My worry is AD auth (security), load handling and replication: FastAPI's ecosystem seems a lot more mature there. Have you done any of that with Drogon?

1

u/Ok-Peak-8516 8d ago

Wouldnt you separate those concerns from the actual API implementation?

For AD auth, you could use Keycloak with LDAP and just validate the JWTs on the Drogon side. For load balancing and replication, Nginx and Kubernetes.

I am using C++/Drogon microservices, Keycloak and Docker Compose for my own project, planning to move to Kubernetes and Istio later.

1

u/FuzzyAdvisor5589 5d ago

You can handle these at the gateway level.

1

u/CzyDePL 9d ago

My thoughts are that "seems like a bad idea to me" is not a very strong argument

1

u/Sweet-Yoghurt-7097 8d ago

My real concerns are two deploys, changes touching both sides, and a team that's mostly C++. Added more context in an edit.

1

u/CzyDePL 8d ago

Okay. FastAPI doesn't give you anything for AD with, load handling and replication. Writing API gateway in something other than C++ might be fine choice, but I wouldn't put C++ developers to write python. Yes there is interop but it's possible in pretty much every language. I would suggest using C# and you can have single API by wrapping DLLs instead of exposing C++ API. Alternatively for writing just a simple scalable backend I would chose Go, you don't need any framework if you don't to use it

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/Sweet-Yoghurt-7097 8d ago

Thanks, I'll check the Interface Partitioning chapter. Starting from what our industrial users actually need makes sense.

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

1

u/Sweet-Yoghurt-7097 8d ago

Same small C++ team for the next 2 years, which is why I lean C++. But AD auth security and the rest of the tooling are easier in Python. Agreed on the "public just for now" risk: if we go with two APIs, only FastAPI talks to C++.

0

u/SideMost3148 7d ago

if it's the same c++ team for 2 years that kind of settles it for me. one c++ api, and for the AD auth you could put a small proxy in front that handles login and passes a verified user through. keeps the python part tiny and nobody has to maintain a whole second api just for auth

0

u/LanguidPragmatism 8d ago

Put Nginx in front for auth over one C== APi rather than splitting a small team rn