An easy to use project that allows users to search origin and destination, and display it on a map.
This project was bootstrapped with Create React App
- ReactJS. One of the most popular JS libraries. It makes frontend easier and streamlined, not to mention the plethora of libraries that provide added functionality.
- Bootstrap, for responsive and streamlined styling. The library is extremely to use and very versatile, offering a lot of options for developing various designs that are suited for all sorts of devices.
- Typescript making the project strongly typed and reducing inevitable bugs that would have caused issues at runtime. Not to mention it works extremely well with Eslint, thus killing two birds with one stone.
- Axios for making API calls and handling error states.
- Jest and React Testing Library for better integration and unit testing. RTL provides lots of functionalities to test individual hooks as well as states, which made is useful for this project.
- React Google Maps is a relatively new library and acts as a React wrapper for Google Maps JavaScript Api. This allowed me to streamline a lot of the API interactions.
The bulk of this project exists within ./src/ folder. Here you can find the project broken into various folders:
├───public
└───src
├───App
├───components
│ ├───Alert
│ ├───Map
│ └───Sidebar
├───context
├───definitions
├───helpers
├───hooks
└───tests
├───__mocks__
└───__snapshots__Please make sure you have the prequisites installed:
- node: v16.13.1
- yarn: v1.22.5
This project does not use npm for package management, attempting to use it to install libraries may lead to errors.
Before running the application make sure the .env variables have been set up correctly. Provide the endpoint for the API to REACT_APP_ENDPOINT without any trailing slashes.
A Google API ID is needed to run this project.
- Navigate to
https://console.cloud.google.com/and create a new project. - In the sidepanel, select API and services > Credentials.
- Click Create Credentials > API Key, and set the restrictions as needed. Save this generated key.
- In the search bar at the top, search
Maps JavaScript Api. An option should appear for the Marketplace, select it. - In the newly opened page, enable the API.
You can now use the generated in the project. Set it as REACT_APP_GOOGLE_API_ID value in .env
git clone https://github.com/sankomil/map-frontend.git
cd map-frontend
yarnOnce all packages have been installed, run the application:
yarn startTests:
yarn testTest coverage can be seen with:
yarn test:ciTypeScript checking:
yarn tsc-noEmitThe project can be built for production with:
yarn buildThe root directory of this project also contains a Dockerfile. This can be used to deploy a production build and to see the result as well as the coverage of the tests.
docker build --target test -t map-frontend-test:latest .
docker run map-frontend-test:latestdocker build -t map-frontend:latest .
docker run -p 3000:3000 map-frontend:latest