SkillSwap has two frontend applications:
- Web Application (React SPA)
- Mobile Application (React Native with Expo)
- React 18.3.1 - Component-based UI library
- React Router DOM 6.28.0 - Client-side routing
- React Scripts 5.0.1 - Build tooling (Create React App)
- Tailwind CSS 3.4.18 - Utility-first CSS framework
- Framer Motion 11.15.0 - Animation library
- Custom Glass Morphism Design - Modern UI aesthetic
- Axios 1.7.9 - Promise-based HTTP client
- Request/Response Interceptors - Automatic auth handling
- React Context API - Global state management
AuthContext- User authentication stateNotificationContext- Real-time notifications
- React Native 0.81.5 - Cross-platform mobile framework
- Expo ~54.0.0 - Development platform
- Expo Router ~6.0.15 - File-based routing
- Expo Location ~19.0.7 - Native geolocation API
- Expo Image Picker ~17.0.8 - Photo upload functionality
- AsyncStorage 2.2.0 - Local data persistence
- NativeWind 4.2.1 - Tailwind CSS for React Native
- React Native Reanimated ~4.1.1 - Smooth animations
The app uses a custom glass morphism design system with:
Color Palette:
- Primary Background:
#0a0a15(Dark blue-black) - Glass Cards:
rgba(139, 92, 246, 0.08)with backdrop blur - Accent Colors:
- Primary Purple:
#a855f7 - Secondary Pink:
#ec4899 - Tertiary Blue:
#3b82f6
- Primary Purple:
Key Design Elements:
- Backdrop Blur:
blur(20px)for glass effect - Gradient Backgrounds: Multi-color gradients for depth
- Asymmetric Cards: Custom clip-path for unique shapes
- Glow Effects: Box shadows with purple/pink glows
Custom theme extends Tailwind with:
- Glass color system (bg, border, text, accent)
- Custom gradients (primary, secondary, glass)
- Custom animations (fade-in, slide-up, float, glow)
- Custom shadows (glass, glass-lg, glow effects)
App.js
βββ AuthProvider (Context)
βββ Router
β βββ NotificationProvider (Context)
β βββ ProtectedRoute
β βββ Pages (Discover, Profile, Matches, Messages)
β βββ Components (Navbar, DiscoverCard, NotificationToast)
AuthContext:
- Manages user authentication state
- Provides
login(),logout(),updateUser()methods - Stores user in
localStorage(web) orAsyncStorage(mobile) - Provides
getCurrentUserId()helper
NotificationContext:
- Polls for new matches and messages
- Provides real-time notification updates
- Auto-refreshes every 30 seconds
Centralized API client (services/api.js):
- Axios instance with base URL configuration
- Request interceptor for auth tokens
- Response interceptor for error handling
- Modular API exports (userAPI, profileAPI, etc.)
ProtectedRoute component:
- Checks authentication status
- Redirects to
/loginif not authenticated - Wraps protected pages (Discover, Profile, Matches, Messages)
The app uses two geolocation approaches:
- Browser/Device Geolocation API - For precise location
- Nominatim OpenStreetMap API - For geocoding and reverse geocoding
Web Implementation (Profile.js):
navigator.geolocation.getCurrentPosition(
async (position) => {
const lat = position.coords.latitude;
const lon = position.coords.longitude;
// Reverse geocode using Nominatim
const response = await fetch(
`https://nominatim.openstreetmap.org/reverse?format=json&lat=${lat}&lon=${lon}&addressdetails=1`,
{ headers: { 'User-Agent': 'SkillSwap/1.0' } }
);
const data = await response.json();
// Extract city and state
const city = data.address.city || data.address.town || '';
const state = data.address.state_code || data.address.state || '';
const locationText = `${city}, ${state}`;
// Save to backend
await profileAPI.updateLocation(profileId, {
latitude: lat,
longitude: lon,
location: locationText
});
}
);Mobile Implementation (profile.js):
// Request permission
const { status } = await Location.requestForegroundPermissionsAsync();
// Get current position
const location = await Location.getCurrentPositionAsync({
accuracy: Location.Accuracy.Highest,
});
// Reverse geocode using Expo
const [address] = await Location.reverseGeocodeAsync({
latitude,
longitude
});Features:
- β High accuracy GPS coordinates
- β Automatic reverse geocoding to city/state
- β Saves coordinates to both User and Profile tables
- β
Privacy control with
showLocationflag
Service: GeolocationService.java
Key Methods:
Converts city names to coordinates:
public Map<String, Double> geocodeCity(String cityName) {
// Tries multiple query formats for accuracy:
// 1. "City, State, USA"
// 2. "City, State"
// 3. "City, State, United States"
// Uses Nominatim API with:
// - addressdetails=1 for better matching
// - countrycodes=us to prioritize US locations
// - Scoring algorithm to find best match
}Scoring Algorithm:
- +10 points for US locations
- +20 points for city name match
- +15 points for state match
- +5 points for city/town type
Autocomplete for location input:
public List<String> getCitySuggestions(String query) {
// Returns up to 8 suggestions
// Format: "City, State"
// Prioritizes US cities and towns
// Filters by featuretype=city,town
}Frontend Integration:
- Debounced input (300ms delay)
- Shows dropdown with suggestions
- Updates as user types
Haversine formula for distance between coordinates:
public double calculateDistance(double lat1, double lon1,
double lat2, double lon2) {
// Returns distance in kilometers
// Uses Earth radius: 6371 km
}Frontend Usage:
- Calculates distance between users
- Filters by max distance (5-200 km)
- Shows distance in discover cards
- Manual Input: Type city name with autocomplete
- Precise Location: Button to use GPS coordinates
- Location Privacy: Toggle to show/hide location
- Location Filter: Show only nearby users
- Distance Display: Shows distance in kilometers
- Max Distance Slider: 5-200 km range
- User Table: Stores coordinates and privacy setting
- Profile Table: Stores coordinates and privacy setting
- Indexed Queries: Optimized location-based searches
1. User clicks "Use My Location" button
β
2. Browser requests GPS permission
β
3. navigator.geolocation.getCurrentPosition()
β
4. Get coordinates (lat, lon)
β
5. Reverse geocode via Nominatim API
β
6. Extract city and state
β
7. POST to /api/profiles/{id}/location
β
8. Backend saves to database
β
9. UI updates with success message
1. User enables location filter on Discover page
β
2. Frontend gets current user's coordinates
β
3. Fetches all users from /api/users
β
4. Calculates distance using Haversine formula
β
5. Filters users within max distance
β
6. Sorts by distance (closest first)
β
7. Displays filtered results
1. User types "Atl" in location field
β
2. Debounce timer (300ms) starts
β
3. After 300ms, calls /api/profiles/cities/suggestions?q=Atl
β
4. Backend queries Nominatim API
β
5. Returns: ["Atlanta, GA", "Atlanta, TX", ...]
β
6. Frontend displays dropdown
β
7. User selects "Atlanta, GA"
β
8. Field updates, geocoding happens automatically
- Mobile-first approach with Tailwind breakpoints
- Flexible layouts using CSS Grid and Flexbox
- Touch-friendly buttons and inputs
- Debounced API calls for location suggestions
- Lazy loading of images
- Memoized calculations for distance
- Efficient re-renders with React hooks
- Smooth animations with Framer Motion
- Loading states for async operations
- Error handling with user-friendly messages
- Accessibility with focus states and ARIA labels
- Location privacy toggle - Users control visibility
- HTTPS required for geolocation API
- Permission handling - Graceful degradation
- Data validation - Server-side checks
| Category | Technology | Version | Purpose |
|---|---|---|---|
| Framework | React | 18.3.1 | UI components |
| Routing | React Router | 6.28.0 | Navigation |
| Styling | Tailwind CSS | 3.4.18 | Utility-first CSS |
| Animations | Framer Motion | 11.15.0 | Smooth transitions |
| HTTP Client | Axios | 1.7.9 | API communication |
| State | Context API | Built-in | Global state |
| Geolocation | Browser API | Native | GPS coordinates |
| Geocoding | Nominatim OSM | External | Address β Coordinates |
| Mobile | React Native | 0.81.5 | Cross-platform |
| Mobile Framework | Expo | ~54.0.0 | Development platform |
-
"We built a modern, responsive web application using React 18..."
- Component-based architecture
- Reusable UI components
- Single Page Application (SPA)
-
"For styling, we implemented a custom glass morphism design system..."
- Tailwind CSS for rapid development
- Custom theme with purple/pink gradients
- Backdrop blur effects for modern look
-
"State management is handled through React Context API..."
- AuthContext for user sessions
- NotificationContext for real-time updates
- No external state library needed
-
"Animations are powered by Framer Motion..."
- Smooth page transitions
- Card hover effects
- Loading animations
-
"We implemented a dual-approach geolocation system..."
- Browser API for precise GPS coordinates
- Nominatim for geocoding and reverse geocoding
-
"Users can set their location in three ways..."
- Manual city input with autocomplete
- GPS-based precise location
- Privacy control to show/hide
-
"The backend uses a smart geocoding service..."
- Multiple query formats for accuracy
- Scoring algorithm for best matches
- US location prioritization
-
"Location-based features include..."
- Distance calculation between users
- Filter by proximity (5-200 km)
- Location privacy controls
.glass-card {
background: rgba(139, 92, 246, 0.08);
backdrop-filter: blur(20px);
border: 1px solid rgba(139, 92, 246, 0.2);
}navigator.geolocation.getCurrentPosition(
(position) => {
const { latitude, longitude } = position.coords;
// Reverse geocode and save
}
);const distance = calculateDistance(
currentLat, currentLon,
userLat, userLon
); // Returns kilometers- API Base URL: Configurable via
REACT_APP_API_URLenvironment variable - CORS: Configured to allow all origins in development
- Error Handling: Comprehensive try-catch blocks with user feedback
- Loading States: Spinner animations during async operations
- Form Validation: Client-side validation before API calls
- Show the glass morphism design - Navigate to Profile page
- Demonstrate location features - Use "Use My Location" button
- Show autocomplete - Type in location field
- Display distance filtering - Enable location filter on Discover
- Highlight animations - Navigate between pages
This document provides a comprehensive overview of the frontend technologies and geolocation implementation for your presentation!