Search code examples
restdeploymentserverarchitectureproduction

Can I deploy multiple front-end apps (web/mobile) with 1 back-end on the same server?


I need some help with deciding on the architecture of my project (a web app for unlocking discounts). I am first planning on creating the website (React for the front-end & Django for the back-end, PostgreSQL database). In the future, I may create a mobile app too for Android & iOS (unsure what front-end framework yet).

So I have decided I want the front-end and back-end to be completely separated so the back-end is a REST api. This will allow me to not have to create multiple back-ends for mobile apps.

But, after researching, I have found that this could be quite expensive in terms of server costs. This is a new business and I am the only developer so funding isn't high. So I was thinking that I could deploy the front-end & back-end on the same server but as separate apps that talk via nginx?

I have 4 questions about this:

  1. If I do this, would it still be possible to reuse the back-end as a REST api for the mobile apps or is that a no because it's linked to the web front-end?
  2. If it is possible, would I be able to host the mobile front-end in the same server (so have everything hosted on 1 server)?
  3. Is this a stupid idea - would I just be better off deploying everything into separate servers in the long-run (to reduce load)?
  4. Should I just worry about this in the future? And for now just deploy the separated web front-end & back-end to the same server.

I have never really deployed anything into a real life production environment so I'm sorry if my questions seem silly. I haven't started development yet but I want to think about scalability & future extensibility before I start. Thank you.


Solution

  • Nowadays I'd go with a serverless approach. Instead of having servers to maintain you can focus on your app functionalities.

    There are a lot of options. You can check, for example, AWS Amplify (https://aws.amazon.com/amplify/) or Netlify (https://www.netlify.com/) for a more "full-stack" approach.

    In AWS, you also can keep separated projects, having your backend in lambdas and your frontend served through S3 + CloudFront. You also don't have servers to care about.

    There are only examples of how you can solve your problem without servers, but answering your questions:

    1. You can reuse your APIs regardless of the way your app is deployed. It will be more related to how you designed them;
    2. Yes, you can host everything in a single server if you want, but I really don't recommend that;
    3. If you don't want to pay for 24/7 servers, you can go for a serverless approach;
    4. As I told you before, you can do what you want without worrying about servers.