Skip to content

samstalhandske/chas_malmo_weather

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chas Academy Malmö Weatherclient

This project is a work in progress weatherclient that is currently being written in C90

What the WeatherClient does

This project is a console-based weather application written in C. It allows users to interactively select cities, fetch weather reports, and manage a local cache of city data. If the data is older than 15 minutes, the application fetches new information. The application features an interactive command-line interface, supports adding, removing, and editing city entries, and retrieves weather data (from an API via HTTP requests). City and weather data are serialized to and loaded from JSON files.

Key Features:

  • Interactive console UI for selecting cities and viewing weather
  • Local cache of cities managed via JSON files
  • Modular structure: distinct components for city management, weather retrieval, HTTP communication, and UI
  • Uses libcurl for HTTP requests and cJSON for JSON serialization/deserialization
  • Custom utilities for string manipulation, input handling, and file operations

Technical Stack:

  • Language: C, with Makefile for build automation
  • Libraries: cJSON (for JSON handling), libcurl (for HTTP requests) - working on support for Jansson
  • Code is organized for maintainability and extensibility

Typical Usage Flow:

  1. User starts the program and is greeted with a menu.
  2. User selects a city or manages the city list (add, edit, remove).
  3. Weather data is fetched and displayed for the selected city.
  4. Data is cached locally to speed up subsequent access and reduce API calls.
  5. To exit the program the user only has to type 'Q', 'Quit', 'E' or 'Exit'.

Demo

$ ./chas_malmo_weather
<===================# Welcome to the Weather App! #===================>

Stockholm      Göteborg      Malmö        Uppsala        Västerås
Örebro         Linköping     Helsingborg  Jönköping      Norrköping

Options(O/0) for options, Exit(E/Q) to exit.
Select a city: Malmö

Weather report has expired (cached 671388 seconds ago).
Retrieving new weather data...

City:                   Malmö (Lat: 55.6050 Lon: 13.0038)
Temperature:            13 °C
Windspeed:              2.40 m/s
Wind direction:         West
Description:            Overcast
Precipitation:          0.00 mm
Time stamp:             202510070945

Prerequisites to build

  • gcc
  • libcurl
  • cJSON (included in src/mcore/cJSON)
  • make

Building

Designed for Ubuntu and Fedora. Working on extended support!

Ubuntu

  1. sudo apt install make gcc libcurl4-openssl-dev
  2. git clone https://github.com/samstalhandske/chas_malmo_weather.git
  3. cd chas_malmo_weather
  4. make

Fedora

  1. sudo dnf install make gcc libcurl-devel
  2. git clone https://github.com/samstalhandske/chas_malmo_weather.git
  3. cd chas_malmo_weather
  4. make

Usage

  1. Start the app:
    ./chas_malmo_weather
  2. Select a city from the list or add your own.
  3. View weather reports, manage your city list, or exit.

Project Structure

src/
├── main.c                # App entry point
├── ui/ClientUI.c         # Console UI logic
├── city/City.c           # City management
├── city/LinkedListCity.c # Handles the LinkedList and all other Cityfunctions
├── weather/Weather.c     # Weather fetching & display
├── ui/ClientUI.c         # The Client management
├── mcore/http/http.c     # HTTP requests (libcurl)
├── mcore/json/cJSON/     # JSON parsing library
└── ...                   # Utilities and helpers

How to Contribute

  1. Clone repo and create a new branch: $ git checkout https://github.com/samstalhandske/chas_malmo_weather -b new_branch_not_yet_named.
  2. Make changes and test.
  3. Submit pull request with clear and descriptive change notes

Acknowledgments

Maintainers

Donations

This is a project from the Malmo-branch of CHAS Academy and we are all students working on this project and as of now this is just a school project, so we are not accepting any donations. But be on the lookout for more upcoming projects over the next two years

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors