React frontend for MatchApp - A real-time location-based matching application with Google Maps integration and beautiful mobile-first design.
- Interactive Maps with Google Maps integration
- Real-time Updates via Socket.io
- SMS Authentication flow with beautiful UI
- Location Tracking with GPS integration
- Match System with animated modals
- Mobile-First Design with responsive layouts
- Smooth Animations with Framer Motion
- Modern UI/UX inspired by popular social apps
- React 18 - Modern React with hooks
- React Router - Client-side routing
- Google Maps API - Interactive maps and geocoding
- Socket.io Client - Real-time communication
- Framer Motion - Smooth animations
- Styled Components - CSS-in-JS styling
- Axios - HTTP client
- React Toastify - Beautiful notifications
- Node.js (v16 or higher)
- Google Maps API key with Maps JavaScript API enabled
- Backend API server running
# Navigate to frontend directory
cd matching-app/frontend
# Install dependencies
npm install# Copy environment template
cp .env.example .env
# Edit with your configuration
nano .envRequired Environment Variables:
# API Configuration
REACT_APP_API_URL=http://localhost:5000/api
REACT_APP_SOCKET_URL=http://localhost:5000
# Google Maps (REQUIRED)
REACT_APP_GOOGLE_MAPS_API_KEY=AIzaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# Optional
REACT_APP_APP_NAME=MatchApp
GENERATE_SOURCEMAP=false- Go to Google Cloud Console
- Create a new project or select existing
- Enable these APIs:
- Maps JavaScript API
- Places API
- Geocoding API (optional)
- Create API Key with restrictions:
- Application restrictions: HTTP referrers
- Add your domain:
http://localhost:3000/* - API restrictions: Select enabled APIs only
# Start the development server
npm startApplication will open at http://localhost:3000
- Beautiful animated loading screen
- 2-second duration with app branding
- Smooth transition to authentication
Login/Register β SMS Verification β Map View
- Basic Info: Name and phone number
- Details: Gender, address, bio
- SMS Verification: 6-digit code input
- Success: Auto-login to map view
- Phone Input: Enter registered phone number
- SMS Verification: Receive and enter code
- Success: Access to main application
- Header: Profile avatar, app name, connection status, actions
- Map: Full-screen Google Maps (70% of screen)
- User Panel: Expandable bottom panel (30% when open)
- Floating Elements: Match requests, location refresh
- Current User Pin: Distinctive marker for user's location
- Other Users: Clickable pins for nearby users
- Info Windows: User profiles on pin click
- Real-time Updates: Live location tracking
- Meeting Points: Special markers for confirmed meetings
Click User Pin β View Profile β Send Match Request β Wait for Response
Receive Request β View Details β Accept/Decline β Meeting Coordination
Match Accepted β Get Directions β Arrive at Location β Confirm Meeting
Primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%)
Secondary: #2ed573 (success), #ff4757 (error)
Background: #f8f9fa
Text: #333 (primary), #666 (secondary), #999 (muted)Font Family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif
Headers: 700 weight, -0.5px letter-spacing
Body: 400 weight, 1.5 line-height
Small: 600 weight, 0.5px letter-spacing (uppercase)Base Unit: 4px
Small: 8px, 12px, 16px
Medium: 20px, 24px, 32px
Large: 40px, 60px, 80px- Primary: Gradient background with shadow
- Secondary: White background with colored border
- Outline: Transparent with colored border
- Danger: Red gradient for destructive actions
- Backdrop: Blurred background
- Content: Rounded corners, smooth animations
- Header: Gradient background with close button
- Actions: Flexible button layout
- Inputs: Rounded, with focus animations
- Labels: Uppercase, small font, colored
- Validation: Real-time with smooth error messages
frontend/
βββ public/
β βββ index.html # HTML template
β βββ manifest.json # PWA manifest
βββ src/
β βββ components/ # React components
β β βββ auth/ # Authentication components
β β βββ common/ # Shared components
β β βββ map/ # Map-related components
β β βββ matching/ # Matching system components
β β βββ profile/ # User profile components
β βββ contexts/ # React contexts
β β βββ AuthContext.js # Authentication state
β β βββ LocationContext.js # Location management
β β βββ SocketContext.js # Real-time communication
β βββ hooks/ # Custom React hooks
β βββ services/ # API and external services
β β βββ api.js # HTTP API client
β β βββ googleMaps.js # Google Maps service
β βββ styles/ # CSS modules
β βββ utils/ # Utility functions
β βββ App.js # Main App component
β βββ index.js # React entry point
βββ package.json
<AuthProvider> // Authentication state
<LocationProvider> // GPS and location state
<SocketProvider> // Real-time communication
<App />
</SocketProvider>
</LocationProvider>
</AuthProvider>App
βββ SplashScreen
βββ Auth Components
β βββ Login
β βββ Register
β βββ SMSVerification
βββ MapView
β βββ UserPanel
β βββ Map Controls
βββ Modals
β βββ MatchRequestModal
β βββ MatchResponseModal
β βββ MeetingModal
β βββ ProfileModal
βββ Profile Components
// Auto-connect on authentication
useEffect(() => {
if (user && token) {
socket = io(SOCKET_URL, { auth: { token } });
}
}, [user, token]);// Location updates
socket.on('userLocationUpdate', (data) => {
updateMapMarker(data.userId, data.location);
});
// Match notifications
socket.on('newMatchRequest', (data) => {
showNotification(`New match request from ${data.requester.name}`);
});// Request permission and start tracking
const startLocationTracking = () => {
navigator.geolocation.watchPosition(
(position) => {
const { latitude, longitude } = position.coords;
updateLocation(latitude, longitude);
},
(error) => handleLocationError(error),
{ enableHighAccuracy: true, maximumAge: 60000 }
);
};// Initialize map with custom styling
const map = new google.maps.Map(element, {
center: { lat, lng },
zoom: 15,
styles: customMapStyles,
disableDefaultUI: true
});const pageVariants = {
initial: { opacity: 0, y: 20 },
animate: { opacity: 1, y: 0 },
exit: { opacity: 0, y: -20 }
};const modalVariants = {
hidden: { opacity: 0, scale: 0.8 },
visible: { opacity: 1, scale: 1 },
exit: { opacity: 0, scale: 0.8 }
};<motion.button
whileHover={{ scale: 1.02 }}
whileTap={{ scale: 0.98 }}
transition={{ type: "spring", damping: 25 }}
>frontend/
βββ src/
β βββ __tests__/
β β βββ components/
β β βββ contexts/
β β βββ services/
β β βββ utils/
β βββ setupTests.js
# Run all tests
npm test
# Run tests with coverage
npm run test:coverage
# Run specific test file
npm test -- Login.test.js- Jest - Test runner and assertion library
- React Testing Library - Component testing utilities
- User Event - User interaction simulation
/* Mobile First Approach */
@media (max-width: 768px) {
.component { /* Mobile styles */ }
}
@media (min-width: 769px) {
.component { /* Desktop styles */ }
}- Large Touch Targets - Minimum 44px
- Swipe Gestures - Pan and dismiss modals
- Pull to Refresh - Map data updates
- Haptic Feedback - On important actions
- Code Splitting - Lazy load components
- Image Optimization - WebP format with fallbacks
- Bundle Analysis - Regular size monitoring
- Service Worker - Offline functionality
- JWT Tokens - Secure storage in httpOnly cookies
- HTTPS Only - All production traffic encrypted
- CORS - Restricted to backend domain only
- Location Privacy - Only shared after mutual consent
- Input Validation - Client-side validation for UX
- XSS Prevention - Sanitize all user inputs
- Google Maps - API key restrictions by domain
- Rate Limiting - Prevent API abuse
- Error Boundaries - Graceful error handling
import { getCLS, getFID, getFCP, getLCP, getTTFB } from 'web-vitals';
getCLS(console.log);
getFID(console.log);
getFCP(console.log);
getLCP(console.log);
getTTFB(console.log);# Analyze bundle size
npm run analyze
# Preview production build
npm run previewTarget scores:
- Performance: 90+
- Accessibility: 95+
- Best Practices: 95+
- SEO: 90+
npm start
# Serves on http://localhost:3000
# Hot reload enabled
# Source maps availablenpm run build
# Creates optimized build in /build
# Minified and compressed
# Service worker generated- Netlify - Automatic deployments from git
- Vercel - Optimized for React applications
- GitHub Pages - Free hosting for open source
- AWS S3 - Scalable cloud storage
# Build with public path
PUBLIC_URL=https://cdn.example.com npm run build# Development
REACT_APP_API_URL=http://localhost:5000/api npm start
# Staging
REACT_APP_API_URL=https://staging.api.matchapp.com npm run build
# Production
REACT_APP_API_URL=https://api.matchapp.com npm run build# API Endpoints
REACT_APP_API_URL=http://localhost:5000/api
REACT_APP_SOCKET_URL=http://localhost:5000
# Google Maps
REACT_APP_GOOGLE_MAPS_API_KEY=your_api_key_here
# App Configuration
REACT_APP_APP_NAME=MatchApp
REACT_APP_VERSION=1.0.0
# Build Configuration
GENERATE_SOURCEMAP=false
INLINE_RUNTIME_CHUNK=falseconst FEATURES = {
CHAT_MESSAGING: process.env.REACT_APP_ENABLE_CHAT === 'true',
PUSH_NOTIFICATIONS: process.env.REACT_APP_ENABLE_PUSH === 'true',
ADVANCED_FILTERS: process.env.REACT_APP_ENABLE_FILTERS === 'true'
};-
Google Maps Not Loading
# Check API key console.log(process.env.REACT_APP_GOOGLE_MAPS_API_KEY) # Check browser console for errors # Verify APIs are enabled in Google Cloud Console
-
Location Permission Denied
// Must use HTTPS in production // localhost works for development // Check browser location settings
-
Socket Connection Failed
# Check backend server is running # Verify CORS settings # Check network connectivity
-
Build Failures
# Clear cache and reinstall npm run clean npm install # Check for TypeScript errors npm run lint
- Component inspector
- Props and state viewer
- Performance profiler
// Enable React debugging
window.__REACT_DEVTOOLS_GLOBAL_HOOK__// API call logging
axios.interceptors.request.use(request => {
console.log('Starting Request', request);
return request;
});npm start- Start development servernpm run build- Create production buildnpm test- Run test suitenpm run eject- Eject from Create React Appnpm run lint- Check code stylenpm run analyze- Bundle size analysisnpm run serve- Serve production build locallynpm run clean- Clean dependencies and build
// themes/default.js
export const theme = {
colors: {
primary: '#667eea',
secondary: '#764ba2',
success: '#2ed573',
error: '#ff4757'
},
fonts: {
primary: '-apple-system, BlinkMacSystemFont, sans-serif'
},
spacing: {
xs: '4px',
sm: '8px',
md: '16px',
lg: '24px',
xl: '32px'
}
};// Customize button styles
const CustomButton = styled(Button)`
background: linear-gradient(45deg, #fe6b8b 30%, #ff8e53 90%);
border-radius: 3px;
border: 0;
color: white;
height: 48px;
padding: 0 30px;
box-shadow: 0 3px 5px 2px rgba(255, 105, 135, .3);
`;MIT License - see LICENSE file for details.
- Fork the repository
- Create feature branch (
git checkout -b feature/name) - Follow code style guidelines
- Add tests for new features
- Update documentation
- Commit changes (
git commit -am 'Add feature') - Push to branch (
git push origin feature/name) - Create Pull Request
- Use functional components with hooks
- Follow React best practices
- Use TypeScript for type safety (if enabled)
- Write meaningful component names
- Add PropTypes or TypeScript interfaces
- Keep components small and focused
Built with β€οΈ for seamless user experiences