This guide provides step-by-step instructions on how the IP Address Tracker project was built.
The project was initialized using Vite with the React and TypeScript template:
npx create-vite ip-address-tracker --template react-ts
This command sets up a new Vite project with React and TypeScript pre-configured.
Next, we installed the necessary dependencies for the project:
npm leaflet react-leaflet
leaflet
andreact-leaflet
for displaying interactive maps.
The project was structured into several directories:
src/components
: This directory contains all the React components.src/services
: This directory contains the service for making API requests.src/types
: This directory contains the TypeScript types used throughout the project.
The main components of the application are:
Header
: This component displays the header of the application.DetailsCard
: This component displays the details of the IP address.LocationMap
: This component displays the location of the IP address on a map.
Each of these components was built with React and TypeScript.
The getGeolocation
function in src/services/api.ts
is used to fetch data from the IP Geolocation API. This function is called in the App
component and the returned data is stored in the state.
The data fetched from the API is passed as props to the DetailsCard
and LocationMap
components, which display the data.
The application was styled using Tailwind CSS. The configuration for Tailwind CSS is in the tailwind.config.js
file.
ESLint was set up for linting, and Prettier was set up for code formatting. The configuration for ESLint is in the .eslintrc.cjs
file, and the configuration for Prettier is in the prettier.config.js
file.
The application can be built and run using the scripts in the package.json
file:
npm run dev # to start the development server
npm run build # to build the application for production
That's it! This is a high-level overview of how the IP Address Tracker project was built. For more detailed information, please refer to the code in the repository or feel free to reach me @ Yakin T.