Deploying AirPulse on AWS: A Full-Stack Environmental Monitoring Platform
Learn how I deployed AirPulse, an environmental monitoring and forecasting platform, using Amazon EC2, Amazon RDS for PostgreSQL with PostGIS, AWS Amplify, PM2, and Cloudflare Tunnel. This article covers the deployment architecture, connectivity, and verification process.
Deploying AirPulse on AWS: Building a Cloud-Hosted Environmental Monitoring Platform
Introduction
Air pollution monitoring becomes more useful when environmental data can be accessed through a reliable, publicly accessible web application. As part of my work on AirPulse, an environmental monitoring and forecasting platform, I worked on deploying the application using AWS services and supporting infrastructure.
AirPulse combines a React-based frontend, an Express backend, and a PostgreSQL database with PostGIS for geospatial operations. The deployment focused on connecting these components securely and making the application accessible beyond a local development environment.
In this post, I’ll walk through the deployment architecture, the services used, and the verification steps that helped bring AirPulse online.
1. Hosting the Backend on Amazon EC2
The first step was deploying the AirPulse backend to an Amazon EC2 instance running Ubuntu.
I installed Node.js and configured the existing Express application to run on the server. The backend exposes API endpoints used by the frontend to retrieve monitoring data, access environmental information, and support the application's geospatial functionality.
Using EC2 provided control over the server environment, application dependencies, and runtime configuration.
To keep the backend process running reliably, I configured PM2, a process manager for Node.js applications. This helps manage the application process and supports automatic recovery and restart behavior when configured appropriately.
2. Setting Up Amazon RDS PostgreSQL with PostGIS
AirPulse needs to store environmental observations and work with geographic information, including station locations and spatial queries.
For the database layer, I used Amazon RDS for PostgreSQL and enabled the PostGIS extension to support geospatial operations.
After configuring database connectivity between EC2 and RDS, I executed eight database migrations to create the required tables and establish the database structure expected by the application.
The database connection was configured to use the managed RDS instance rather than a local development database.
This separation allows the application backend and database to run as distinct components, making maintenance and future scaling easier to manage.
3. Deploying the Frontend with AWS Amplify
The AirPulse frontend is built with React and uses Vite as its build tool.
I connected the GitHub repository to AWS Amplify to build and host the frontend. This provided a deployment workflow in which application code could be built and published from the repository.
The deployed frontend communicates with the backend through its configured API endpoint. Correctly configuring this connection was essential because the frontend and backend were hosted separately.
This approach also creates a foundation for integrating future frontend changes through a source-control-based deployment workflow.
4. Connecting the Backend Through Cloudflare Tunnel
The backend needed a publicly reachable HTTPS endpoint so the deployed frontend could communicate with it.
I used Cloudflare Tunnel to expose the backend through HTTPS and connect it to the hosted frontend.
This provided a way to route requests to the backend without relying on a directly exposed application-server address.
The frontend API configuration was updated to use the appropriate backend endpoint, allowing requests to reach the Express API from the deployed web application.
The tunnel configuration and access policies remain important parts of the deployment's security and availability.
5. Verifying the Deployment
Deploying the components was only part of the work. I also verified that the services could communicate correctly.
The main checks included:
- API health: Tested the backend health endpoint to confirm that the API was responding.
- Database connectivity: Confirmed that the backend could connect to the RDS PostgreSQL database.
- PostGIS availability: Checked that the PostGIS extension was available for geospatial operations.
- Database migrations: Executed and checked the eight migrations required by the application.
- Frontend connectivity: Checked that the hosted frontend was configured to communicate with the deployed backend.
These checks helped validate the core deployment path from the user-facing web application to the backend and database.
6. AirPulse Deployment Architecture
The resulting architecture separates the main application components:
User → AWS Amplify frontend → Cloudflare Tunnel HTTPS endpoint → Amazon EC2 backend → Amazon RDS PostgreSQL with PostGIS
Each component has a distinct responsibility:
- AWS Amplify: Builds and hosts the frontend.
- Amazon EC2: Runs the Express backend on Ubuntu.
- PM2: Manages the Node.js application process.
- Amazon RDS PostgreSQL: Stores application data in a managed relational database.
- PostGIS: Provides spatial data types and geospatial operations.
- Cloudflare Tunnel: Provides the HTTPS route to the backend.
This separation makes the architecture easier to understand, maintain, and evolve as AirPulse grows.
7. What I Learned
Working on this deployment helped me understand that cloud deployment is not just about hosting code. It requires coordinating several independent components and validating the connections between them.
Some important lessons were:
- Separate application layers: Hosting the frontend, backend, and database independently clarifies their responsibilities.
- Use managed database services: Amazon RDS reduces the operational burden of managing the database server itself.
- Validate network connectivity: A healthy backend is not sufficient if the frontend cannot reach it or the backend cannot connect to the database.
- Manage long-running processes: PM2 helps manage Node.js application processes on a virtual machine.
- Treat deployment configuration as part of the application: API URLs, environment variables, database credentials, and tunnel configuration must be managed carefully.
Conclusion
Deploying AirPulse gave me practical experience connecting AWS infrastructure with a full-stack environmental monitoring application.
By combining Amazon EC2, Amazon RDS for PostgreSQL with PostGIS, AWS Amplify, PM2, and Cloudflare Tunnel, I established a deployment architecture that separates frontend hosting, backend execution, database storage, and external HTTPS access.
The experience also reinforced the importance of testing API availability, database connectivity, and geospatial capabilities after deployment.
AirPulse is an ongoing project, and this deployment provides a foundation for further improvements to environmental monitoring, forecasting, geospatial analysis, and cloud operations.
I look forward to continuing to improve the platform and exploring how AWS services can support its future development.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article