A React-based Geo Data Dashboard that consumes and visualizes spatial + tabular data. Built with Next.js, shadcn/ui, and Leaflet.
-
Data Table
- Fetch paginated data from mock API
- Columns: Project Name, Latitude, Longitude, Status, Last Updated
- Client-side sorting on all columns
- Real-time search/filtering across multiple fields
- Click row to highlight corresponding marker on map
-
Map Integration
- Interactive map using Leaflet with OpenStreetMap tiles
- Plot markers using latitude/longitude from table data
- Click marker to highlight corresponding row in table
- Visual distinction for selected markers (red) vs default (blue)
- Auto-centering based on data bounds
-
Performance Optimizations
- Handles 5k+ rows efficiently using React.memo
- Memoized filtering and sorting operations
- Optimized re-renders with useMemo and useCallback
- Optional pagination mode for very large datasets
-
State Management
- Local state only (no Redux)
- Proper separation of UI vs data logic
- Clean component architecture
- Node.js 18+
- npm or yarn
- Clone the repository:
git clone <your-repo-url>
cd geo-data-dashboard- Install dependencies:
npm install- Run the development server:
npm run dev- Open http://localhost:3000 in your browser
geo-data-dashboard/
βββ src/
β βββ app/
β β βββ layout.tsx # Root layout
β β βββ page.tsx # Main page (Dashboard)
β β βββ globals.css # Global styles + shadcn/ui variables
β βββ components/
β β βββ ui/ # shadcn/ui components
β β β βββ button.tsx
β β β βββ input.tsx
β β β βββ table.tsx
β β βββ Dashboard.tsx # Main dashboard component
β β βββ DataTable.tsx # Table with sorting/filtering
β β βββ Map.tsx # Leaflet map component
β βββ lib/
β β βββ api.ts # API service functions
β β βββ utils.ts # Utility functions (cn helper)
β βββ types/
β βββ index.ts # TypeScript type definitions
βββ components.json # shadcn/ui configuration
βββ package.json
βββ README.md
- Decision: Used Next.js instead of Vite/CRA for better SSR capabilities and built-in optimizations
- Benefits: Server-side rendering, automatic code splitting, optimized production builds
- Decision: Chosen for its modern, accessible, and customizable components
- Benefits:
- Copy-paste components (not a dependency)
- Built on Radix UI primitives
- Fully customizable with Tailwind CSS
- TypeScript support out of the box
- Decision: Leaflet chosen over Mapbox/OpenLayers for:
- Free and open-source (no API keys required)
- Lightweight and performant
- Excellent React integration via react-leaflet
- Extensive plugin ecosystem
- Tile Provider: OpenStreetMap (free, no API key needed)
- Decision: Utility-first CSS framework
- Benefits: Rapid development, consistent design system, built-in dark mode support
- Decision: No Redux/Context API for global state
- Rationale:
- Simple data flow (fetch β display β interact)
- Component-level state is sufficient
- Better performance with local state
- Easier to understand and maintain
-
React.memo:
- Wrapped DataTable and Map components
- Memoized individual table rows and map markers
- Prevents unnecessary re-renders
-
useMemo:
- Filtered and sorted data computation
- Map center calculation
- Icon creation (prevents recreation on each render)
-
useCallback:
- Event handlers (onRowClick, onMarkerClick, handleSort)
- Prevents child component re-renders
-
Pagination Option:
- Optional pagination mode for datasets > 50 items
- Reduces DOM nodes for better performance with 5k+ rows
The dashboard fetches data from:
https://6986b1548bacd1d773eb8675.mockapi.io/api/geo-data/get-all
The API service (src/lib/api.ts) handles:
- Fetching all geo data
- Pagination support (if API supports it)
- Error handling and data transformation
- Flexible response format handling
- Table β Map: Clicking a table row highlights the corresponding marker (red icon)
- Map β Table: Clicking a marker scrolls to and highlights the corresponding row
- Visual Feedback: Selected items have distinct styling (border, background color)
- Click column headers to sort
- Visual indicators (chevrons) show sort direction
- Supports ascending/descending toggle
- Works with filtered data
- Real-time search across:
- Project Name
- Status
- Latitude
- Longitude
- Client-side filtering for instant results
- Shows filtered count vs total count
- Split-screen layout (table | map)
- Responsive grid (stacks on mobile)
- Scrollable table container
- Full-height map container
- Load Data: Data automatically loads on page mount
- Search: Type in the search box to filter results
- Sort: Click column headers to sort
- Select Row: Click any table row to see marker highlight
- Select Marker: Click any map marker to see row highlight
- Pagination: Toggle pagination mode for large datasets
- 5,000+ rows: Smooth scrolling and interaction
- Filtering: Instant results (< 50ms)
- Sorting: Fast even with large datasets
- Map Rendering: Efficient marker rendering with memoization
-
API Response Format: The mock API response format may vary. The code handles multiple formats but may need adjustment for specific API structures.
-
Map Tiles: Uses OpenStreetMap tiles which may have rate limits. For production, consider:
- Using a tile service with API key
- Implementing tile caching
- Using Mapbox or other commercial providers
-
Large Datasets: While optimized for 5k+ rows, extremely large datasets (10k+) may benefit from:
- Virtual scrolling (react-window)
- Server-side pagination
- Data virtualization
npm run build
npm start- Push code to GitHub
- Import project in Vercel
- Deploy automatically
- Components are modular and easy to extend
- Type definitions in
src/types/index.ts - API functions in
src/lib/api.ts
- shadcn/ui components can be modified in
src/components/ui/ - Global styles in
src/app/globals.css - Tailwind config can be extended as needed
Estimated Time Spent: ~8-10 hours
- Setup and configuration: 1 hour
- Component development: 4 hours
- Map integration: 2 hours
- Performance optimization: 1.5 hours
- Testing and refinement: 1.5 hours
This project is open source and available under the MIT License.
- shadcn/ui for the beautiful component library
- Leaflet for the mapping library
- Next.js for the framework
- Tailwind CSS for styling
Note: This project was built as an assignment demonstrating React skills, component architecture, and performance optimization techniques.