How to Host Your Modern Open-Source Web App for Free
It’s simple with AWS Lambda, Angular, MongoDB, and Github Pages.
We all like to build and try new things to get some experience with the latest technologies. As developers who closely work with the web, we often make web applications with our innovative ideas. Most of the time, we do these kinds of things just for fun. After all, we would like to publish our work as an open-source project. Thereafter, we could show your awesome work to other developers and users. If our web app is having old-fashioned monolithic architecture with several PHP source files, there are thousands of free shared hosting services to publish our work. But if we are following modern microservices architecture, usually there will be a bill at the end of the month.
I also make open-source web apps that use the microservices pattern just for fun during my free time. I found the following approach to host those non-commercial apps without spending a single penny.
LAMG is like the LAMP stack that stands for Linux, Apache, MySQL, and PHP. LAMP offers a good development stack for monolithic web applications. Likewise, MEAN-like tech stacks are popular modern monolithic stacks. Further, those modern stacks can be used with the microservices pattern too since each component can be deployed into separate containers also by having good scalability factors.
LAMG stands for Lambda, Angular, MongoDB, and Github pages. This tech stack uses AWS Lambda service for the backend logic, MongoDB atlas for the data persistence, Angular as the frontend framework, and Github pages for the frontend components deployment. These services are absolutely free for simple or medium-sized open-source web applications. There are a few limitations as mentioned below but those are negligible for non-commercial applications.
- AWS Lambda and API Gateway offer 1 million requests per month for free with their free tier.
- MongoDB atlas gives us 512 megabytes of free disk space.
- Github Pages service is limited to 100 gigabytes of bandwidth limit per month and also limited to 1 gigabyte of repository size. Also, they don’t expect commercial websites such as e-commerce platforms to be published with their service.
Working with the frontend
The frontend of the application could be implemented using Angular that offers everything you need to make a well-structured single-page web app. Github pages-enabled repository can be used to store the frontend source and also the minified static web content.
All backend API calls can be sent to the AWS API Gateway that triggers Lambda functions. There are no deployment-related limitations with this component of LAMG.
Indeed, deploying the frontend is so easy with the CLI via the
ng deploy command.
Working with the backend
LAMG uses AWS Lambda for implementing the backend logic. If you are developing a simple web app that has only one or two serverless functions, the API gateway could be configured manually. But if your web application has many serverless functions it is always easy to use a deployment automation tool such as Serverless and Claudia to save time. For example, I recently made a simple web app to show a random movie based on a category that is chosen by the user, and I configured the API gateway manually.
If there is a need for data management and persistence, a MongoDB atlas instance can be integrated easily with the serverless function code. AWS API Gateway also offers 1 million invocations for free per month.
This deployment strategy allows you to host your personal projects for free. The Angular framework is not a mandatory component in the LAMG concept and it can be either removed or replaced. Also, there are a lot of advantages because we are using Github Pages for hosting. We will be able to use all the free features from Github.