Skip to content

katiaipduarte/weather-webapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weather WebApp

Welcome to my Weather App, where you can enter a location to fetch the current weather or see the weather in you current location. You can also add a new city to the favourites, and also delete it.

Demo at: weather-webapp-three.vercel.app

Project board: https://github.com/katiaipduarte/weather-webapp/projects/1 Design based on: https://dribbble.com/shots/7376567-Weather-App-Website/attachments/263087?mode=media

Design based on: https://dribbble.com/shots/7376567-Weather-App-Website/attachments/263087?mode=media

App created using Next.js 12, TypeScript, styled-components, redux, redux toolkit, firebase and for testing Jest. Thank you for using my app.

There is also a Dockerfile, if you want to run it like that. Be aware, there might me some issues with build using Docker, because of SWC use instead of Babel. Since it will be the new default while NextJS. What work for me was removing the node?modules and the package-lock.json, and re do all of the package installation.

Note: To run this project be sure to have a Node version installed that is 16.x or higher

Table of Contents

Installation

To use this app, first clone from GitHub via 'git clone https://github.com/katiaipduarte/weather-webapp' at your terminal, cd to the new directory, then run npm install. Before running this project, you will need to create a .env.local file, with the same env as the ones in the .env.example. At last, run npm run dev to launch your http server.

Realtime Database

This project uses a realtime database to save the favourite locations. The selected was firebase for the easy of use and integration. You will need to create a firestore database with the collection favourites with the following structure:

{
  "lat": number,
  "lon": number,
  "city": string,
  "name": string
}

API Keys

This project is connected to 2 external API.

Future Work

[ ] Update docker to enable running firebase locally
[ ] Add more unit tests and e2e ones
[ ] Add authentication, to allow multiple users with different favourite locations
[ ] Add better caching
[ ] Add different background and card images, taking into account the location selected

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/katiaipduarte/weather-webapp. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The code is available as open source under the terms of the MIT License.

Folder Structure

weather-webapp/
    .husky/
    .vscode/
    components/
        common/
        templates/
    constants/
    firebase/
    interfaces/
    mocks/
    pages/
    public/
    services/
    store/
    styles/
    utils/

For the project to build, these files must exist with exact filenames:

  • .husky folder containing git hooks for pre-commit and pre-push.
  • .vscode folder containing rules to help start development faster while using vscode.
  • components is the folder that houses all the components used. It's divided for now into 2 modules.
    • common: components that are used all the time when we render a page.
    • templates: pages templates.
  • constants is the folder with all the enums or const objects used in the components.
  • firebase this folder only contains one file with initialize for firebase.
  • interfaces is the folder with all the interfaces/type files used in the components.
  • mocks is the folder with all the mock data need for unit testing.
  • pages is the folder that contains the files with the initial logic used for each route.
  • public the folder only contains the favicon images.
  • services is the folder for all the services.
  • store is the folder with the redux logic.
  • style is the folder with reset, themes and any other style rules shared by all components.
  • utils is the folder with helper functions.

Environment variables

NEXT_PUBLIC_API_KEY=

NEXT_PUBLIC_LOCATION_API_KEY=

NEXT_PUBLIC_FIREBASE_API_KEY=

NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=

NEXT_PUBLIC_FIREBASE_PROJECT_ID=

NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=

NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=

NEXT_PUBLIC_FIREBASE_APP_ID =

Available Scripts

npm run dev

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

npm run build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

npm run start

Runs the app in the production mode.
Open http://localhost to view it in the browser.

npm run docker:build

Creates a docker image containing the app build in production mode.

npm run docker:run

Creates a docker image containing the app build in production mode. After that, runs the docker image.
Open http://localhost:3000 to view it in the browser.

npm run lint

Automatic linting, with rules to work with TypeScript and React. The node_modules and e2e folders are not included.

This is runned each time you do a commit and a push it to your branch.

For more information see the ESLint documentation.

npm run format

Command to format the code according to the rules that can be found in .prettierrc. The node_modules and e2e folders is not included.

This will be automatically run each time you do a commit.

For more information see the Prettier documentation.

npm run test

Runs all the tests founded.
See the section about running tests for more information.

npm run test:watch

Launches the test runner in the interactive watch mode.
See the section about running tests for more information.

npm run test:coverage

Launches the test runner in the interactive watch mode and shows a report with the code coverage for each component.
See the section about running tests for more information.