Best practices for deploying separate backend and frontend applications together

My development team is working on a web app where we split the backend and frontend into different projects. The backend is built as a REST API using Express.js with PostgreSQL, while the frontend uses React. We keep these in separate Git repositories which works great for development.

However, I’m confused about the deployment process. Do both parts need to run on the same server in production? What’s the best way to deploy them when they’re in different repos?

We’re pretty new to this whole deployment thing, so any guidance would be helpful.

Our current tech stack includes:

  • Express.js for API server
  • Prisma for database management
  • WebSocket for real-time features
  • Jest for testing
  • React for the user interface

We plan to host everything on AWS. Any tips or best practices would be great!

honestly they dont need to be on same server at all. deploy your react app to s3 + cloudfront for static hosting, then put your express api on ec2 or lambda. just make sure cors is configured properly so frontend can talk to backend across domains. way cheaper than running everything on one big server too

hmm interesting setup! just curious - have you thought about using docker containers for this? it might make deploying both parts way easier. also wondering what made you decide to keep them in seperate repos instead of a monorepo? does your team work on frontend/backend independently?

I’ve dealt with this exact scenario multiple times. The key insight is treating your deployment pipeline as two independent workflows that can be coordinated. Set up separate CI/CD pipelines for each repository using AWS CodePipeline or GitHub Actions. Your Express API should deploy to an ECS cluster or Elastic Beanstalk, while React builds can go directly to S3 with CloudFront distribution. The critical part is managing environment variables properly - your React build needs to know the API endpoint URL at build time. I typically use AWS Systems Manager Parameter Store to share configuration between deployments. This approach gives you independent scaling and deployment schedules, which becomes invaluable as your application grows. Make sure to implement proper health checks on your API before the frontend deployment references it.