This project demonstrates the integration of GPT-4 and React-Leaflet to visualize geographic data. The app fetches coordinates and a location title from GPT-4 based on a user query, and then renders them as markers on a Leaflet map.
The application utilizes GPT-4 for generating coordinates and a title for a location based on the user's request. Once the information is fetched, React-Leaflet is used to mark that location on the map.
- OpenAI SDK
- Next.js
- React.js
- React-Leaflet
- Zustand (state management)
- Node.js
- Install dependencies
pnpm install
- Create
.envfile
cp .env.example .env
- Add your OpenAI API key to a
.envfile
OPENAI_API_KEY=your-api-key-here
- Start the development server
pnpm dev
- Open the application in a browser.
- Enter a query in the input field.
- Hit "Submit" or press Enter to get the coordinates and title which will be displayed on the map.
components/- components that can be re-used in different projects, mainly UI components.modules/- modules that can be re-used in the probject but not re-usable in different projects.app/- Next.js pages. and components that would only be used once in the specific pages.hooks/- re-usable hooks that can be re-used in different projects.services/- services that interact with external APIs. In fact, this is where to manage data/states, organized by domains.utils/- utility functions.