Track your travel memories with an interactive map experience
HappyPlaces is a modern React application that allows users to track and manage their travel experiences on an interactive map. Users can click on locations, add cities to their personal collection, and store memories with notes and visit dates.
will be uploded soon
- Leaflet Integration: Powered by React Leaflet for smooth map interactions
- Click to Add: Click anywhere on the map to add a new city
- City Markers: Visual markers for all visited cities
- Dynamic Positioning: Map automatically centers on selected cities
- Add Cities: Click on map locations to add new cities
- City Details: View detailed information about each visited city
- Visit Notes: Add personal notes about your experiences
- Visit Dates: Track when you visited each location
- Delete Cities: Remove cities from your collection
- Reverse Geocoding: Automatically detect city and country names from coordinates
- BigDataCloud API: Integration for accurate location data
- Emoji Flags: Automatic country flag emojis for visual appeal
- Responsive Design: Works seamlessly on desktop and mobile
- Loading States: Smooth loading indicators throughout the app
- Error Handling: Graceful error management and user feedback
- Navigation: Intuitive routing between different views
- React 19 - Latest React with modern hooks and features
- React Router DOM - Client-side routing and navigation
- React Leaflet - Interactive map components
- React DatePicker - Date selection for visit dates
- Context API - Global state management
- useReducer - Complex state logic management
- Custom Hooks - Reusable stateful logic
- JSON Server - Mock REST API for development
- Leaflet - Open-source map library
- BigDataCloud API - Reverse geocoding service
- Vite - Fast build tool and development server
- ESLint - Code linting and formatting
- CSS Modules - Scoped styling
- Node.js (v18 or higher)
- npm or yarn
-
Clone the repository
git clone https://github.com/Sanskar-Rijal/HappyPlaces.git cd HappyPlaces -
Install dependencies
npm install
-
Start the JSON server (in one terminal)
npm run server
-
Start the development server (in another terminal)
npm run dev
-
Open your browser
http://localhost:5173
npm run dev- Start development servernpm run build- Build for productionnpm run preview- Preview production buildnpm run server- Start JSON server for APInpm run lint- Run ESLint
src/
βββ components/ # Reusable UI components
β βββ City/ # City-related components
β βββ Country/ # Country list components
β βββ Map/ # Map and location components
β βββ Form/ # City addition form
β βββ ...
βββ contexts/ # React Context providers
β βββ CitiesContexts.jsx
βββ hooks/ # Custom React hooks
β βββ useUrlPosition.js
β βββ useGeoLocation.js
βββ pages/ # Main application pages
β βββ Homepage.jsx
β βββ AppLayout.jsx
β βββ ...
βββ data/ # JSON data files
βββ cities.json
const initialState = {
cities: [],
loading: false,
currentCity: {},
error: "",
};
function reducer(state, action) {
switch (action.type) {
case "cities/loaded":
return { ...state, cities: action.payload, loading: false };
case "city/created":
return {
...state,
cities: [...state.cities, action.payload],
currentCity: action.payload,
};
// ... more cases
}
}<MapContainer center={mapPosition} zoom={10}>
<TileLayer url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" />
{cities.map((city) => (
<Marker position={[city.position.lat, city.position.lng]}>
<Popup>
{city.emoji} {city.cityName}
</Popup>
</Marker>
))}
<DetectClick />
</MapContainer>const [cityName, setCityName] = useState("");
const [country, setCountry] = useState("");
const [date, setDate] = useState(new Date());
const [notes, setNotes] = useState("");
// Fetch location data from coordinates
useEffect(() => {
async function fetchCityData() {
const res = await fetch(`${BASE_URL}?latitude=${lat}&longitude=${lng}`);
const data = await res.json();
setCityName(data.city || data.locality || "");
setCountry(data.countryName);
}
fetchCityData();
}, [lat, lng]);- useUrlPosition: Extract coordinates from URL parameters
- useGeoLocation: Get user's current location
- useCities: Access cities context throughout the app
- Nested routes for different app sections
- URL state management for map coordinates
- Protected routes and navigation guards
- Component lazy loading
- Efficient re-renders with proper dependency arrays
- Optimized map rendering
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- React Leaflet for excellent map components
- OpenStreetMap for free map tiles
- BigDataCloud for reverse geocoding API
- JSON Server for quick API prototyping