How m0hammedk/skycast works
Project type and purpose
• This is a full-stack, server-rendered React application built with Next.js (App Router).
• It provides a user interface for searching weather and forecast data by city, fetches that data from external weather APIs, and displays it in various UI panels and tables.
File structure to extract components
• src/app → Next.js front-end: routing (layout.tsx, page.tsx), global CSS, components
• src/app/api → two serverless API routes: /api/weather and /api/forecast
• src/server → fetch helper (Get.tsx) encapsulating external API calls
• src/utils → utility functions (Weather.tsx) for building requests/parsing responses
• src/models → TypeScript schemas and interfaces for Weather, Forecast, etc.
• src/app/components
• GlobalStates/CityContext.tsx → React Context for sharing selected city
• UI → Navbar, Footer, Panel, Table
• Tests (jest & cypress) and config files are ancillary QA components.
README for architecture hints
• A standard create-next-app setup on Vercel, no databases, no microservices.
• Focus is on serverless functions and front-end component hierarchy.
Main components and their relationships
a. Browser / User Interface
• Next.js pages (page.tsx) and layout
• UI components (Navbar, Footer, Panel, Table)
• React Context (CityContext)
b. API Layer (Next.js serverless functions)
• /api/weather
• /api/forecast
c. Server / Fetch Helper
• src/server/Get.tsx – centralizes fetch logic to external weather API
d. External Weather Service
• Third-party REST API (e.g., weatherapi.com)
e. Shared Data Models
• TypeScript schemas in src/models
Architectural patterns & principles
• Component-based UI (React)
• Serverless API routes (Next.js App Router)
• Single source of truth for city selection via React Context
• Separation of concerns:
• UI layer (components)
• API layer (route handlers)
• Data-fetch layer (Get.tsx)
• Data modeling (schemas)
• Browser / User
• Next.js UI (page.tsx + components + context)
• API Routes (route.tsx handlers)
• Fetch Helper (Get.tsx) + Utils & Models
• External Weather Service