How sanskar9067/skyscanner works
Project Type and Purpose
• This is a single-page front-end web application (a ReactJS SPA) styled with Tailwind CSS.
• Purpose: Detect user location (via browser Geolocation API), fetch real-time weather and time data from two external REST services (OpenWeather API and API Ninjas), and display it. It also supports manual location search (via a geocoding API).
Key Architectural Layers and Components
a. Presentation Layer (Browser / Client)
• index.html (public/index.html) – host container for the React app
• App.js – root React component, applies Context providers and renders Home page
• Home.js (src/pages/Home.js) – orchestrates two tabs: “Current Location” and “Search Location”
• React-Tabs (TabComponent.js) – UI navigation between the two modes
• UI Components under src/components:
– Navbar.js + DarkModeToggle.js (theme switcher)
– Weather.js + WeatherSearch.js (input for manual search)
– Heroes.js (hero banner)
– Spinner.js (loading indicator)
– Footer.js
• DarkModeContext.js (src/context) – React Context and Provider for global theme state
b. Business Logic Layer
• App.js & Home.js orchestrate data retrieval and state updates
• useState/useEffect hooks manage local component state for weather/time data
• Axios (via React) handles HTTP requests to external APIs
c. External Services
• Browser Geolocation API – to fetch user’s latitude/longitude
• OpenWeather API – returns weather and local time details given coordinates
• API Ninjas Geocoding API – converts user-entered location names into coordinates
Relationships and Data Flows
1. User opens the app → index.html loads → index.js renders <App/>
2. App.js wraps children with DarkModeContext Provider → passes down darkMode toggle
3. Home.js renders TabComponent:
• Tab “Current Location”:
– Calls Geolocation API → retrieves coords → Axios → OpenWeather → setState → Weather.js displays data
• Tab “Search Location”:
– WeatherSearch.js captures place name → Axios → API Ninjas → coords → Axios → OpenWeather → state → Weather.js displays
4. DarkModeToggle.js reads/writes theme flag in Context → entire UI re-renders with Tailwind dark mode classes
Architectural Patterns and Principles
• Component-based UI (React functional components)
• Single source of truth for theme (Context API)
• Separation of concerns: Presentation vs Data-fetching logic vs External integrations
• Hook-based state management (useState/useEffect)
Detailed Elements
• Tailwind CSS config (tailwind.config.js) as a styling cross-cutting concern