{"id":20178698,"url":"https://github.com/chanda-abdul/frontend-mentor-ip-address-tracker-angular","last_synced_at":"2026-05-13T04:03:49.536Z","repository":{"id":108539576,"uuid":"557709423","full_name":"Chanda-Abdul/Frontend-Mentor-IP-address-tracker-Angular","owner":"Chanda-Abdul","description":"This is a solution to the IP address tracker challenge on Frontend Mentor.","archived":false,"fork":false,"pushed_at":"2022-11-08T21:27:56.000Z","size":20488,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-13T16:49:20.669Z","etag":null,"topics":["angular","api","observables","regex","rxjs","sweetalert2","typescript"],"latest_commit_sha":null,"homepage":"https://tubular-cheesecake-3b5f91.netlify.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Chanda-Abdul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-26T06:46:07.000Z","updated_at":"2022-11-11T00:10:29.000Z","dependencies_parsed_at":"2023-03-22T00:25:39.085Z","dependency_job_id":null,"html_url":"https://github.com/Chanda-Abdul/Frontend-Mentor-IP-address-tracker-Angular","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chanda-Abdul%2FFrontend-Mentor-IP-address-tracker-Angular","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chanda-Abdul%2FFrontend-Mentor-IP-address-tracker-Angular/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chanda-Abdul%2FFrontend-Mentor-IP-address-tracker-Angular/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chanda-Abdul%2FFrontend-Mentor-IP-address-tracker-Angular/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Chanda-Abdul","download_url":"https://codeload.github.com/Chanda-Abdul/Frontend-Mentor-IP-address-tracker-Angular/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241616683,"owners_count":19991542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","api","observables","regex","rxjs","sweetalert2","typescript"],"created_at":"2024-11-14T02:22:58.196Z","updated_at":"2026-05-13T04:03:49.457Z","avatar_url":"https://github.com/Chanda-Abdul.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Frontend Mentor - IP address tracker\n\n![Design preview for the IP address tracker coding challenge](/src/assets/design/desktop-preview.jpg)\n\nThis is a solution to the [IP address tracker challenge on Frontend Mentor](https://www.frontendmentor.io/challenges/ip-address-tracker-I8-0yYAH0). Frontend Mentor challenges help you improve your coding skills by building realistic projects. \n\n## Table of contents\n\n- [Overview](#overview)\n  - [The challenge](#the-challenge)\n  - [Screenshots](#screenshots)\n  - [Links](#links)\n- [My process](#my-process)\n  - [Built with](#built-with)\n  - [What I learned](#what-i-learned)\n  - [Continued development](#continued-development)\n  - [Useful resources](#useful-resources)\n- [Author](#author)\n- [Acknowledgments](#acknowledgments)\n\n\n# Overview\n\n## The challenge\n\nYour challenge is to build out this IP Address Tracker app and get it looking as close to the design as possible. \n* \u003cs\u003eTo get the IP Address locations, you'll be using the [IP Geolocation API by IPify](https://geo.ipify.org/). \n* To generate the map, we recommend using [LeafletJS](https://leafletjs.com/).\u003c/s\u003e\n\n\n### Users should be able to:\n\n- [x] View the optimal layout for each page depending on their device's screen size\n  - [x] Mobile: `375px`\n  - [x] Desktop: `1440px`\n- [x] See hover states for all interactive elements on the page\n- [x] See their own IP address on the map on the initial page load\n- [x] Search for any IP addresses or \u003cs\u003edomains\u003c/s\u003e and see the key information and location\n\u003c!--  Test IP Addresses\n210.138.184.59\n8.8.8.8\n63.143.82.254 --\u003e\n\n## Screenshots\n\n### Mobile `@375px`\n\u003cimg src=\"./src/assets/screens/mobile.png\" width=\"375\" /\u003e\n\n\n### No one asked but, Tablet `@768px`\n\u003cimg src=\"./src/assets/screens/tablet2.png\"/\u003e\n\n\n### Desktop `@1140px`\n\u003cimg src=\"./src/assets/screens/desktop.png\"/\u003e\n\n#\n### with Input Validation\n#### valid IP address input\nI used \u003cb\u003eRegEx\u003c/b\u003e to validate the input, \n\n```js\ncheckIpAddressRegex = /\\S+@\\S+\\.\\S+/;\n...\nvalidateInput(ipOrDomain){\n  ...\n  this.checkIpAddressRegex.test(ipOrDomain)\n  ...\n}\n```\nif the input \u003ci\u003eIS\u003c/i\u003e valid the user will see the \u003ci\u003e\"success\"\u003c/i\u003e alert below\n\n\u003cimg src=\"./src/assets/screens/success.png\"  width=\"375\" /\u003e\n\n#### invalid IP address input\nif the input \u003ci\u003eIS NOT\u003c/i\u003e valid the user will see the \u003ci\u003e\"error\"\u003c/i\u003e alert below\n\u003cimg src=\"./src/assets/screens/error.png\"  /\u003e\n\n#### valid domain input\n❗️the \u003cb\u003e[IP geolocation API by Abstract](https://app.abstractAPI.com/API/ip-geolocation/documentation)\u003c/b\u003e does \u003ci\u003enot\u003c/i\u003e have a domain query parameter, so I skipped this for now. \n\nI also used \u003cb\u003eRegEx\u003c/b\u003e to check if the input is a valid domain, \n```js\n  checkDomainRegex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9]\n    [0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\\n      .(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\\n        .(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;\n        \n  ...\n\n  validateInput(ipOrDomain){\n    ...\n    (this.checkDomainRegex.test(ipOrDo\n    \n    main));\n    ...\n  }\n```\n\nif so the user will see the \u003ci\u003e\"warning\"\u003c/i\u003e alert below\n\n\u003cimg src=\"./src/assets/screens/warning.png\"  /\u003e\n\n## Links\n\n- Solution URL: [View Solution](https://github.com/Chanda-Abdul/Frontend-Mentor-IP-address-tracker-Angular)\n- Live Site URL: [View Live site](https://tubular-cheesecake-3b5f91.netlify.app)\n\n## My process\n### Design\n- I started by reviewing the starter design files that were included in this project. The \u003ci\u003eSass/CSS\u003c/i\u003e was pretty straightforward.  `styles.scss` for the global styles, `_variables.scss` for re-useable styles, and style sheets for each component.\n- I created a new Angular project and decided on components that would be needed.\n  For components I went with\n  - `\u003capp\u003e` as the entry component. I wanted to keep the code and functionality to a minimum in this component. Within the this component we have\n    - The `\u003capp-search-input\u003e` component, which captures the user's input. Once the input is submitted, it is sent to the `GeoLocationService` so that a new \u003ci\u003eAPI/http request\u003c/i\u003e can be made and the data will be re-rendered.\n    - The `\u003capp-display\u003e` component, to display the current \u003ci\u003eIP Address\u003c/i\u003e, \u003ci\u003elocation\u003c/i\u003e, \u003ci\u003eTimezone\u003c/i\u003e, and \u003ci\u003eInternet Service Provider\u003c/i\u003e. This contains the\n      - `\u003capp-map\u003e`component which handles the \u003ci\u003eAPI/call\u003c/i\u003e for the mapping functionality, which could be moved to a \u003ci\u003eService\u003c/i\u003e later.\n\n#\n### API Selection\n\u003cb\u003eGeolocation API\u003c/b\u003e \n\nTo get the IP Address locations,  I decided to go with the \u003cb\u003e[IP geolocation API by Abstract](https://app.abstractAPI.com/API/ip-geolocation/documentation)\u003c/b\u003e because the\n[IP Geolocation API by IPify](https://geo.ipify.org/docs) has a very small lifetime limit of 1,000 🆓 requests; compared to Abstract's 22,000 🆓 requests per month *and* optional ip address query parameter.\n##### \u003cb\u003e`GET`\u003c/b\u003e request:\n`https://ipgeolocation.abstractapi.com/v1/`\n##### Input parameters: \n`api_key`(required): 🤫\n\n`fields`(optional): `=ip_address,city,region_iso_code,postal_code,longitude,latitude,timezone,connection`\n\n`ip_address`(optional): ex. `210.138.184.59`\n\u003cb\u003eGoogle Maps API\u003c/b\u003e\n\nFor the \u003ci\u003emapping API\u003c/i\u003e, I went with \u003cb\u003e[Maps JavaScript API](https://developers.google.com/maps/documentation/javascript)\u003c/b\u003e. I've used \u003cb\u003e[LeafletJS](https://leafletjs.com/)\u003c/b\u003e before and I wanted to try something new, I also thought that a google \u003ci\u003eAPI\u003c/i\u003e would pair well with \u003ci\u003eAngular\u003c/i\u003e.\n##### \u003cb\u003e`GET`\u003c/b\u003e request:\n`http://maps.googleapis.com/maps/api/js`\n##### Input parameters: \n`key`(required): 🤫\n\n- I also used a custom `Marker` and removed the `disableDefaultUI` controls.\n\n#\n### Reactive Development with RxJs\nThis was a good project to practice \u003cb\u003eReactive development\u003c/b\u003e and \u003cb\u003eRxJs/Observables\u003c/b\u003e.  The data returned from the \u003ci\u003eAPI\u003c/i\u003e calls are \u003ci\u003eObservables\u003c/i\u003e. \n\n## Built with\n### APIs\n\n- \u003cb\u003e[IP geolocation API by Abstract](https://app.abstractAPI.com/API/ip-geolocation/documentation)\u003c/b\u003e to get the IP Address locations.\n-  \u003cb\u003e[Maps JavaScript API](https://developers.google.com/maps/documentation/javascript)\u003c/b\u003e, for the \u003ci\u003emapping API\u003c/i\u003e.\n- \u003cb\u003e[Insomnia](https://insomnia.rest/)\u003c/b\u003e to test \u003ci\u003eAPI endpoints\u003c/i\u003e and \u003ci\u003equery parameters\u003c/i\u003e.\n\n### Frameworks and Librarys\n- \u003cb\u003e[Angular](https://angular.io/)\u003c/b\u003e (\u003cb\u003eJavaScript\u003c/b\u003e framework)\n  - \u003cb\u003e[TypeScript](https://www.typescriptlang.org/)\u003c/b\u003e\n  - \u003cb\u003e[JavaScript](https://www.javascript.com/)\u003c/b\u003e\n  - \u003cb\u003e[RxJs](https://rxjs.dev/)\u003c/b\u003e a library for reactive programming using Observables.\n- \u003cb\u003e[sweetalert2](https://sweetalert2.github.io/)\u003c/b\u003e - A beautiful, responsive, customizable, accessible replacement for JavaScript’s popup boxes. I used this for the \u003ci\u003esweet\u003c/i\u003e input error alerts 😋.\n- \u003cb\u003e[Figma](https://www.figma.com/)\u003c/b\u003e collaborative web application for interface design.\n- \u003cb\u003e[Sass](https://sass-lang.com/)/CSS\u003c/b\u003e custom properties\n  - Mobile-first workflow\n  - Responsive Styling\n  - Flexbox\n- Semantic \u003cb\u003eHTML5\u003c/b\u003e markup\n\n## What I learned\n\u003cb\u003eObservables and RxJs\u003c/b\u003e\n\n  [BehaviorSubject](https://www.learnrxjs.io/learn-rxjs/subjects/behaviorsubject) - I knew that it would be best to use Observables for the \u003ci\u003eAPI\u003c/i\u003e data. I decided to go with a `BehaviorSubject` because multiple components would need to subscribe to the \u003ci\u003eAPI\u003c/i\u003e data and notified when there were changes.\n\n  this is what it looks like... \n  ### 📂 `fetch.geolocation.service.ts`\n\n  ```js\n  private geolocationResult!;\n  \n  private geoBehaviorSubject = new BehaviorSubject(this.geolocationResult);\n\n  readonly geolocation$ = this.geoBehaviorSubject.asObservable();\n  \n  ...\n \n  fetchGeolocation(ipAddress?): void {\n    this.http.get\u003cGeolocation\u003e(\n      `${this.geoURL}?api_key=${environment.IP_GEOLOCATION_API_KEY}`\n      + (ipAddress ? `\u0026ip_address=${ipAddress}` : \"\"),\n      {\n        params: {\n          fields: 'ip_address,city,country,continent,region_iso_code,postal_code,\n          longitude,latitude,timezone,connection'\n        }\n      })\n      .subscribe(\n        res =\u003e {\n          this.geoBehaviorSubject.next(res);\n        }\n      )\n  }\n  ```\n  ### 📂 `display.component.ts`\n\n  ```js\n    geolocation$ = this.fetchGeolocationService.geolocation$;\n    geolocation: Geolocation;\n    ...\n  \n    this.fetchGeolocationService.fetchGeolocation();\n    ...\n\n    this.geolocation$.subscribe(res =\u003e this.geolocation = res); \n  ```\n\n  ### 📂 `display.component.html`\n    \n  ```html\n    \u003cdiv *ngIf=\"geolocation$ | async as geolocation\"\u003e\n      ...\n      \u003cli\u003e\n        \u003ch2\u003eTimezone\u003c/h2\u003e\n        \u003cp\u003e\n          {{geolocation.timezone.abbreviation}} \n          {{this.formatTimezone(geolocation.timezone.gmt_offset)}}:00\n          \u003c/p\u003e\n      \u003c/li\u003e\n      ...\n```\n\u003cb\u003eSelecting an API\u003c/b\u003e\n\n  The most challenging part, for the \u003ci\u003eAPIs\u003c/i\u003e, was just selecting which two \u003ci\u003eAPIs\u003c/i\u003e would be best for this project.  \n  \n  For the \u003ci\u003eGeolocation API\u003c/i\u003e, I started with the recommended, \u003ci\u003e[IP Geolocation APIby IPify](https://geo.ipify.org/)\u003c/i\u003e , but I quickly learned that the lifetime request limit is pretty low.  So I looked into a few other \u003ci\u003egeolocation/ip address APIs\u003c/i\u003e and there weren't very many free \u003ci\u003eAPIs\u003c/i\u003e that would also give me the data I need, and a decent request amount, while being easily incorparated into an \u003ci\u003eAngular\u003c/i\u003e project. I ended up going with the \u003ci\u003e[IP geolocation API by Abstract](https://app.abstractAPI.com/API/ip-geolocation/documentation)\u003c/i\u003e\n  \n  For the \u003ci\u003emapping API\u003c/i\u003e, I skipped \u003ci\u003e[LeafletJS](https://leafletjs.com/)\u003c/i\u003e, because I've used it before and I wanted to try something new, and it also doesn't seem to work well with Angular at the moment. I went with the \u003ci\u003e[Maps JavaScript API](https://developers.google.com/maps/documentation/javascript)\u003c/i\u003e, but i'm not sure if this is the best long-term option.\n## Continued development\n- [ ] implement search by domain input functionality, may need to use a different \u003ci\u003eAPI\u003c/i\u003e?\n\n## Useful resources\n\n- [Get data from a server](https://angular.io/tutorial/toh-pt6) - This is an amazing article which helped me finally understand XYZ. I'd recommend it to anyone still learning this concept.\n- [Integrating Google Maps API w/ Angular 7+](https://medium.com/@jkeung/integrating-google-maps-\u003ci\u003eAPI\u003c/i\u003e-w-angular-7-e7672396ce2d) - This helped me for XYZ reason. I really liked this pattern and will use it going forward.\n- [How to Display Spinner...](https://www.geeksforgeeks.org/how-to-display-spinner-on-the-screen-till-the-data-from-the-\u003ci\u003eAPI\u003c/i\u003e-loads-using-angular-8/) - This is an amazing article which helped me finally understand XYZ. I'd recommend it to anyone still learning this concept.\n- [PluralSight Course - RxJS in Angular: Reactive Development\nby Deborah Kurata](https://app.pluralsight.com/library/courses/rxjs-angular-reactive-development) 💯 - This is an amazing article which helped me finally understand XYZ. I'd recommend it to anyone still learning this concept.\n- [Learn RxJs - BehaviorSubject](https://www.learnrxjs.io/learn-rxjs/subjects/behaviorsubject) - This helped me for XYZ reason. I really liked this pattern and will use it going forward.\n- [Maps JavaScript \u003ci\u003eAPI\u003c/i\u003e \u003e Markers](https://developers.google.com/maps/documentation/javascript/markers) - This is an amazing article which helped me finally understand XYZ. I'd recommend it to anyone still learning this concept.\n\n## Author\n\n- Frontend Mentor - [@Chanda-Abdul](https://www.frontendmentor.io/profile/Chanda-Abdul)\n- Website - [Chanda Codes](https://chandacodes.com/)\n- GitHub - [github.com/Chanda-Abdul](https://github.com/Chanda-Abdul)\n\n## Acknowledgments\n\n\u003c!-- This is where you can give a hat tip to anyone who helped you out on this project. Perhaps you worked in a team or got some inspiration from someone else's solution. This is the perfect place to give them some credit. --\u003e\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanda-abdul%2Ffrontend-mentor-ip-address-tracker-angular","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchanda-abdul%2Ffrontend-mentor-ip-address-tracker-angular","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanda-abdul%2Ffrontend-mentor-ip-address-tracker-angular/lists"}