Skip to content

jagadapi240/Angular-Calculator-Using-Java-Script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿงฎ Angular Calculator App

A lightweight, responsive web calculator built with Angular 17, developed and deployed on AWS EC2 instances with Nginx hosting.
This project demonstrates a complete build-and-deploy pipeline using Node.js, Angular CLI, and secure SSH transfer between servers.


๐Ÿ“˜ Project Overview

This project involves:

  • Setting up two EC2 servers (Build & Deploy)
  • Building the Angular application using Node.js and Angular CLI
  • Transferring production build artifacts to the deployment server
  • Hosting the Angular app using Nginx

๐Ÿงฑ Infrastructure Setup

Server Role Purpose
Build Server Development & Build Compiles the Angular app and produces the production-ready build files
Deploy Server Hosting Serves the static files using Nginx
Communication Secure Copy (SCP) .pem key used for SSH and file transfer between instances

โš™๏ธ Build Server Configuration (Ubuntu EC2)

1๏ธโƒฃ Update & Install Essentials

10 ```bash sudo apt -y update sudo apt-get install -y nodejs sudo apt install npm -y ````

2๏ธโƒฃ Clone the Application

11
git clone https://github.com/Ai-TechNov/AngularCalculator.git
cd AngularCalculator
12 13

3๏ธโƒฃ Update Project Files

Manually edited:

  • package.json โ†’ updated to latest Angular dependencies
  • angular.json โ†’ adjusted for modern Angular schema compliance
14

4๏ธโƒฃ Install Angular CLI & Dependencies

npm install
sudo npm install -g @angular/cli@latest

5๏ธโƒฃ Fix Node.js Version Compatibility

When the build showed:

Node.js version v18.19.1 detected.
The Angular CLI requires a minimum Node.js version of v20.19 or v22.12.

Updated Node to the latest version: 15

sudo apt remove -y nodejs
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs

Verify:

node -v   # v20.19.5
npm -v    # 10.8.2

Clean cache and verify Angular CLI:

sudo npm cache clean -f
ng version

Enable autocompletion:

ng completion

๐Ÿ—๏ธ Build Process

Build the Angular app for production:

ng build --configuration production

The build output is generated inside:

/home/ubuntu/AngularCalculator/dist/angularCalc

๐Ÿš€ Deployment Server Configuration (Ubuntu EC2)

1๏ธโƒฃ Secure File Transfer from Build Server

Transfer build files using .pem SSH key:

sudo chmod 400 Linux-Practice.pem
scp -i Linux-Practice.pem /home/ubuntu/AngularCalculator/dist/angularCalc/* ubuntu@13.51.160.159:/home/ubuntu/

2๏ธโƒฃ Install and Configure Nginx

12
sudo apt update -y
sudo apt install nginx -y

3๏ธโƒฃ Move Build Files to Web Directory

sudo mv * /var/www/html/

4๏ธโƒฃ Start and Verify Nginx

sudo systemctl status nginx

Expected output:

nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: enabled)
Active: active (running)

Optional cleanup:

sudo rm -rf /var/www/html/index.nginx-debian.html

โœ… The Angular app is now hosted and accessible via: 16

http://<Deploy-Server-Public-IP>/

๐ŸŒ Example Directory Structure

AngularCalculator/
โ”œโ”€โ”€ dist/
โ”‚   โ””โ”€โ”€ angularCalc/
โ”‚       โ”œโ”€โ”€ index.html
โ”‚       โ”œโ”€โ”€ main.js
โ”‚       โ”œโ”€โ”€ runtime.js
โ”‚       โ”œโ”€โ”€ styles.css
โ”‚       โ”œโ”€โ”€ polyfills.js
โ”‚       โ””โ”€โ”€ assets/
โ”œโ”€โ”€ src/
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ angular.json
โ””โ”€โ”€ README.md

๐Ÿ”’ Security Considerations

  • Only ports 22 (SSH) and 80 (HTTP) were opened.

  • .pem key permissions restricted using:

    chmod 400 Linux-Practice.pem
  • No sensitive environment variables are stored in the codebase.


๐Ÿงฐ Tech Stack

Component Version Purpose
Angular 17.3.x Frontend Framework
Node.js 20.19.x JavaScript Runtime
NPM 10.8.x Package Manager
Nginx Latest Web Server for static hosting
Ubuntu 22.04 LTS OS for EC2 servers

๐Ÿงช Testing the App

Run the app locally:

ng serve

Build for production:

ng build --configuration production

Deploy and test via browser:

http://<your-server-ip>/

๐Ÿงฉ Troubleshooting

Issue Cause Solution
ng: command not found Angular CLI not installed globally sudo npm install -g @angular/cli@latest
Node.js version too low Node < 20 Reinstall Node 20 LTS
Schema validation failed Old angular.json Replace with Angular 17 schema
Port already in use Nginx already running sudo systemctl restart nginx

๐Ÿ‘จโ€๐Ÿ’ป Author

Sivaiah Jagadapi Power BI Developer | Cloud & DevOps Enthusiast ๐Ÿ“ Hyderabad, India ๐ŸŒ GitHub: Ai-TechNov


๐Ÿ License

This project is open-source under the MIT License. You are free to modify, distribute, and reuse the code with attribution.



---

โœ… **Now do this:**
1. Copy everything above (from `# ๐Ÿงฎ Angular Calculator App` to the end).  
2. Paste into your projectโ€™s `README.md`.  
3. Commit and push:  
   ```bash
   git add README.md
   git commit -m "Added detailed project documentation"
   git push

Would you like me to add a visual architecture diagram (Build โ†’ SCP โ†’ Deploy โ†’ Nginx) as Markdown image placeholder at the top of your README?

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published