A comprehensive React application that displays detailed information about countries worldwide using static country data. This app features search functionality, region filtering, detailed country views, and a responsive design with dark/light mode support.
- Repository Basics
- Features
- Technologies Used
- Directory Structure
- Code Understanding
- Setup & Installation
- Application Architecture
- User Flow
- Data Structure
- Usage Examples
- Contributing
- Troubleshooting
This React application serves as a comprehensive country information portal that allows users to explore detailed data about all world countries. The app provides an intuitive interface for searching, filtering, and viewing country-specific information including demographics, geography, currencies, languages, and neighboring countries.123
Key Capabilities:
- Search Functionality: Find countries by name (common or official names)4
- Regional Filtering: Filter countries by continent (Africa, Americas, Asia, Europe, Oceania)4
- Detailed Views: Navigate to individual country pages with comprehensive data4
- Border Navigation: Click on border countries to explore neighboring nations4
- Theme Support: Toggle between light and dark modes4
- Responsive Design: Optimized for all device sizes4
Before setting up this project, ensure you have the following installed:
- Node.js: Version 14.x or higher5
- npm: Version 6.x or higher5
- Git: For repository management
- Code Editor: VS Code, Sublime Text, or similar
# Clone the repository
git clone https://github.com/RAJAN-115/RestCountryAPP.git
# Navigate to project directory
cd RestCountryAPP
# Install dependencies
npm install
# Start development server
npm start# Clone the repository
git clone https://github.com/RAJAN-115/RestCountryAPP.git
# Navigate to project directory
cd RestCountryAPP
# Install dependencies
npm install
# Start development server
npm start- π Comprehensive Country Database: Access information for all world countries
- π Smart Search: Search by country name with real-time filtering
- π Region Filtering: Filter countries by geographic regions
- π± Responsive Design: Works seamlessly on desktop, tablet, and mobile
- π Dark/Light Mode: Toggle between themes for better user experience
- πΊοΈ Interactive Navigation: Click country cards to view detailed information
- π Border Country Links: Navigate between neighboring countries
- β‘ Fast Performance: Static data loading for quick response times
- Frontend Framework: React 18.2.01
- Routing: React Router DOM 6.10.01
- Bundler: Parcel 2.8.31
- Styling: Pure CSS with CSS Custom Properties6
- Data Source: Static JSON data (REST Countries API format)7
- Deployment: Netlify4
RestCountryAPP/
βββ π .parcel-cache/ # Parcel build cache
βββ π components/ # React components
β βββ CountriesList.jsx # Main countries list container[^10]
β βββ CountryCard.jsx # Individual country card[^11]
β βββ CountryDetail.jsx # Detailed country view[^12]
β βββ Header.jsx # App header with theme toggle[^8]
β βββ SearchBar.jsx # Search input component[^13]
β βββ SelectMenu.jsx # Region filter dropdown[^14]
βββ π dist/ # Production build output
βββ π node_modules/ # Dependencies
βββ π .gitignore # Git ignore rules
βββ π App.css # Main stylesheet[^15]
βββ π App.jsx # Root application component[^4]
βββ π CONTRIBUTING.md # Contribution guidelines
βββ π countriesData.js # Static country data[^7]
βββ π index.html # HTML entry point[^5]
βββ π index.jsx # React entry point[^6]
βββ π INSTALLATION.md # Setup instructions[^9]
βββ π netlify.toml # Netlify deployment config
βββ π package.json # Project dependencies[^2]
βββ π package-lock.json # Dependency lock file
βββ π PREVIEW.md # App screenshots
βββ π README.md # This documentation
βββ π _redirects # Netlify routing rules
| File | Purpose | Key Features |
|---|---|---|
| App.jsx | Main application component | State management, routing, filtering logic4 |
| countriesData.js | Static data source | Contains 23,956 lines of country data7 |
| App.css | Styling system | CSS variables, responsive design, theming6 |
| index.html | Entry HTML file | Root element, meta tags8 |
| package.json | Dependencies config | Scripts, dependencies, metadata1 |
1. HTML Entry Point (index.html)8
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Countries API</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="index.jsx"></script>
</body>
</html>2. React Entry Point (index.jsx)9
import {createRoot} from 'react-dom/client'
import App from './App'
const root = createRoot(document.querySelector('#root'))
root.render(<App />)Core Application Logic (App.jsx)4
The main App component manages the application's state and routing:
const App = () => {
const [countries, setCountries] = useState(countriesData);
const [searchTerm, setSearchTerm] = useState('');
const [selectedRegion, setSelectedRegion] = useState('');
const [isDarkMode, setIsDarkMode] = useState(false);
// Filtering logic
useEffect(() => {
let filteredCountries = countriesData;
if (searchTerm.trim()) {
const searchLower = searchTerm.trim().toLowerCase();
filteredCountries = filteredCountries.filter(
country =>
country.name.common.toLowerCase().includes(searchLower) ||
country.name.official.toLowerCase().includes(searchLower)
);
}
if (selectedRegion) {
filteredCountries = filteredCountries.filter(
country => country.region === selectedRegion
);
}
setCountries(filteredCountries);
}, [searchTerm, selectedRegion]);Header Component (Header.jsx)10
- Displays app title and theme toggle button
- Manages dark/light mode switching
- Clean, responsive header design
- SearchBar.jsx: Real-time country name search11
- SelectMenu.jsx: Region-based filtering with preset options12
- CountriesList.jsx: Maps through filtered countries array13
- CountryCard.jsx: Individual country preview cards with navigation14
- CountryDetail.jsx: Comprehensive country information page15
- Static Data Loading:
countriesData.jscontains pre-loaded country information7 - State Management: App.jsx manages search, filter, and theme states4
- Component Communication: Props passed down for data and callbacks up for actions
- Routing: React Router handles navigation between list and detail views4
Styling System (App.css)6
The application uses a sophisticated CSS system with:
- CSS Custom Properties: Dynamic theming support
body {
--background-color: white;
--text-color: black;
--elements-color: white;
}
body.dark {
--background-color: hsl(207, 26%, 17%);
--text-color: white;
--elements-color: hsl(209, 23%, 22%);
}- Responsive Design: Mobile-first approach with media queries
- Component-Specific Styles: Organized CSS classes for each component
- Smooth Transitions: Hover effects and animations
git clone https://github.com/RAJAN-115/RestCountryAPP.git
cd RestCountryAPP2. Install Dependencies5
npm installThis installs:
3. Start Development Server5
npm startApplication runs at: http://localhost:1234
4. Build for Production5
npm run buildCreates optimized build in dist/ folder
No environment variables required - the app uses static data for optimal performance.
Currently no test suite is configured. Consider adding:
- Jest for unit testing
- React Testing Library for component testing
- Cypress for end-to-end testing
1. Component-Based Architecture16
- Modular Design: Each component has a single responsibility
- Reusability: Components can be easily reused and extended
- Maintainability: Clear separation of concerns
2. Container-Component Pattern17
- Smart Components: App.jsx manages state and logic
- Dumb Components: UI components receive props and render
- Performance: Pre-loaded data eliminates API calls
- Reliability: No network dependencies
- Speed: Instant search and filtering
- Application Initialization
index.jsxrendersApp.jsxcountriesData.jsloads static data- Initial state set with all countries
- User Interaction Handling
- Search input triggers
handleSearchChange - Region selection triggers
handleRegionChange - Filter effects update displayed countries
- Search input triggers
- Navigation Flow
- Country card click navigates to detail route
- React Router handles URL changes
- Detail page loads specific country data
- User visits homepage
- Views all countries in card layout
- Uses search or region filter
- Clicks country card for details
- Explores related countries via borders
- User enters search term
- Real-time filtering displays results
- Can combine search with region filter
- Results update instantly
- Click country card
- View comprehensive country data
- Click border countries to explore neighbors
- Use back button to return to main view
The application uses the REST Countries API data format:
{
"name": {
"common": "United States",
"official": "United States of America"
},
"flags": {
"svg": "https://flagcdn.com/us.svg",
"png": "https://flagcdn.com/w320/us.png"
},
"population": 329484123,
"region": "Americas",
"subregion": "North America",
"capital": ["Washington, D.C."],
"currencies": {
"USD": {
"name": "United States dollar",
"symbol": "$"
}
},
"languages": {
"eng": "English"
},
"borders": ["CAN", "MEX"],
"tld": [".us"],
"cca3": "USA"
}| Property | Type | Description | Usage |
|---|---|---|---|
name.common |
String | Common country name | Display, search |
name.official |
String | Official country name | Search, detail view |
flags.svg |
String | SVG flag URL | Country cards, details |
population |
Number | Population count | Demographics display |
region |
String | Geographic region | Filtering |
borders |
Array | Border country codes | Navigation links |
currencies |
Object | Currency information | Economic data |
languages |
Object | Spoken languages | Cultural information |
// Search functionality in action
const handleSearchChange = (value) => {
setSearchTerm(value);
// Triggers useEffect to filter countries
};// Region filtering implementation
const handleRegionChange = (value) => {
setSelectedRegion(value);
// Updates displayed countries list
};// Country card navigation
const handleClick = () => {
navigate(`/country/${encodeURIComponent(name)}`);
};// Dark/light mode toggle
const toggleDarkMode = () => {
setIsDarkMode(!isDarkMode);
// Updates CSS custom properties
};git clone https://github.com/YOUR-USERNAME/RestCountryAPP.git
cd RestCountryAPPgit checkout -b feature/new-feature-name- Follow existing code patterns
- Update documentation if needed
- Test thoroughly
- Describe changes clearly
- Include screenshots for UI changes
- Reference any related issues
import React from 'react';
export default function ComponentName({ props }) {
// Component logic here
return (
<div className="component-class">
{/* JSX content */}
</div>
);
}.component-name {
/* Component base styles */
}
.component-name__element {
/* Element-specific styles */
}
.component-name--modifier {
/* Modifier styles */
}- API Integration: Connect to live REST Countries API318
- Testing Suite: Add Jest and React Testing Library
- Performance: Implement virtualization for large lists
- Accessibility: Enhanced ARIA labels and keyboard navigation
- Features: Add favorites, comparison tool, maps integration
- PWA: Add service worker for offline functionality
1. Installation Problems5
React Router Version Issues:
npm uninstall react-router-dom
npm install react-router-dom@6.10.0Parcel Cache Issues:
npm cache clean --force
rm -rf .parcel-cache # Linux/macOS
rmdir /s /q .parcel-cache # Windows
npm startCountries Not Displaying:
- Check if
countriesData.jsis properly imported - Verify data structure matches expected format
- Check browser console for JavaScript errors
Search Not Working:
- Ensure search term state is updating
- Check filter logic in
useEffect - Verify case-insensitive comparison
Navigation Issues:
- Check React Router setup
- Verify route paths match navigation calls
- Ensure
encodeURIComponentis used for country names
Theme Not Switching:
- Check if CSS custom properties are defined
- Verify
isDarkModestate updates - Ensure body class toggle works
Responsive Issues:
- Test media query breakpoints
- Check viewport meta tag
- Verify flexible layout properties
Browser Compatibility5
Supported Browsers:
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
Minimum Requirements:
- ES6+ support
- CSS Custom Properties
- Fetch API (or polyfill)
- Static Data: Eliminates network requests for faster loading
- Component Memoization: Consider
React.memofor expensive components - Virtual Scrolling: For handling large country lists
- Image Optimization: Lazy loading for flag images
- Bundle Splitting: Code splitting for better loading performance
The application is deployed on Netlify with the following configuration:
- Build Command:
npm run build - Publish Directory:
dist - Redirects: SPA routing handled via
_redirectsfile
This project is open source and available under the MIT License.
- REST Countries API: For providing comprehensive country data23
- React Community: For excellent documentation and tools
- Netlify: For free hosting and deployment
- Flag Icons: Country flag resources
Last Updated: August 2025
Repository: github.com/RAJAN-115/RestCountryAPP Live Demo: nationpalette.netlify.app
Footnotes
-
https://github.com/RAJAN-115/RestCountryAPP/blob/main/package.json β© β©2 β©3 β©4 β©5 β©6 β©7 β©8 β©9
-
https://github.com/RAJAN-115/RestCountryAPP/blob/main/App.jsx β© β©2 β©3 β©4 β©5 β©6 β©7 β©8 β©9 β©10 β©11
-
https://github.com/RAJAN-115/RestCountryAPP/blob/main/INSTALLATION.md β© β©2 β©3 β©4 β©5 β©6 β©7
-
https://github.com/RAJAN-115/RestCountryAPP/blob/main/App.css β© β©2 β©3
-
https://github.com/RAJAN-115/RestCountryAPP/blob/main/countriesData.js β© β©2 β©3
-
https://github.com/RAJAN-115/RestCountryAPP/blob/main/index.html β© β©2
-
https://github.com/RAJAN-115/RestCountryAPP/blob/main/index.jsx β©
-
https://github.com/RAJAN-115/RestCountryAPP/blob/main/components/Header.jsx β©
-
https://github.com/RAJAN-115/RestCountryAPP/blob/main/components/SearchBar.jsx β©
-
https://github.com/RAJAN-115/RestCountryAPP/blob/main/components/SelectMenu.jsx β©
-
https://github.com/RAJAN-115/RestCountryAPP/blob/main/components/CountriesList.jsx β©
-
https://github.com/RAJAN-115/RestCountryAPP/blob/main/components/CountryCard.jsx β©
-
https://github.com/RAJAN-115/RestCountryAPP/blob/main/components/CountryDetail.jsx β©
-
https://www.imensosoftware.com/blog/scaling-react-js-applications-architectural-patterns-and-performance-optimization/ β©

