Giter Club home page Giter Club logo

wellwellwell's Introduction

About the project

This project is a proof of concept to demonstrate an app with create, read, update, delete (CRUD) functionality.

The idea is to allow users to record their wellbeing in a simple way, and then to show trends.

This project is in its early stages but is functional!

Built with

Backend

  • JavaScript
  • Node
  • Express

Frontend

  • JavaScript
  • React
  • Tailwind CSS
  • Vite

Other tools worthy of mention

  • Docker
  • Git
  • GitHub

Getting started

Starting the backend

In the server folder, run npm i to install dependencies.

Use npm run km to kill any MongoDB instances that may be running.

Download the mongod file and place it in server/data, or modify the sm script to use your global instance of MongoDB (installation instructions).

Use npm run sm to start.

Open up a second terminal and run npm run create-database. Then run npm run nodemon which will initialise the Express instance with a watch script.

Starting the frontend

Open up a third terminal before proceeding.

In the client folder, run npm i to install dependencies.

Run npm run host which will make the Vite server available over the local network.

You should now see the /login page and be able to make a user account.

Roadmap

Please refer to the project's Kanban board to see where I'm up to!

Contributing

Although this project began as a portfolio project, I would be happy to work with others on contributing. Just raise an issue, or comment on one, to get started!

wellwellwell's People

Contributors

parradam avatar

Watchers

 avatar

wellwellwell's Issues

First deployment of application

  • Create Vite production build
  • Add dist to .gitignore
  • Copy dist contents to server/public
  • Add public to .gitignore
  • Add express.static() middleware to render the frontend
  • Create Dockerfile with Node, MongoDB, and source files
  • Add wellwellwell mongodb URL to ENV variables and remove hardcoded versions of mongodb://mongodb-wellwellwell:27017/wellwellwell from Express
  • #69
  • Add reverse proxy (nginx) that handles SSL (LetsEncrypt) and https

Persist `Bearer` token in a secure manner

Definition of done (acceptance criteria)

  • Authentication should be checked by Express before the site is rendered
  • If the user is not authenticated, a 301 redirect to /login should occur
  • Only /login or /register should be accessible to unauthenticated users
  • Once signed in, the Dashboard data should be visible

Subtasks

Backend

  • Implement http cookie to hold JWT

Frontend

  • Remove redundant session storage code
  • Remove Authorization code in api folder

Future work

N/A

Useful resources

N/A

Create side navigation bar

This will hold the detailed links for easy navigation, starting with the dashboard.

Definition of done

  • Navigation bar can be used to navigate from one page to another

Subtasks

  • Build left navigation bar
  • Style with Tailwind CSS
  • Add icons as appropriate
  • Install react-router-dom
  • Implement dashboard route (abstract into routes file)
  • Add Link component to Nav to navigate to dashboard

Acceptance criteria

N/A

Useful resources

MyDay and Dashboard components behave differently when centred

Adding items-center to the Tailwind CSS class of the ContentWrapper centres the h1 tag in MyDay (undesired) but does not in Dashboard (desired).

Components should be refactored and broken up where necessary, with CSS rationalised and Content Wrapper reviewed.

Add "my day" component

Create a component which allows the user to record how they are feeling, and save it to the database.

Definition of done

  • Details can be recorded for the current day and saved to the database

Subtasks

  • Create /my-day route and component
  • Add nav link to /my-day
  • Create ContentWrapper component by composition?
  • Create form
  • Add option to select rating (styled radio button?)
  • Style form (color coding options)
  • Implement service to update database
  • Add link from dashboard

Acceptance criteria

N/A

Useful resources

Implement prop types

Prop types allow validation and type checking to catch bugs.

Definition of done

  • Prop types are implemented as detailed below

Subtasks

  • npm install --save prop-types
  • Implement prop types for TaskList
  • Implement prop types for ContentWrapper

Acceptance criteria

N/A

Useful resources

Enhance mobile navigation experience

Implement a collapsible navigation bar and better layout on mobile devices.

Definition of done

  • Details can be recorded for the current day and saved to the database

Subtasks

  • Create mobHidden state for navigaiton visibility
  • Hide navigation on mobile only when mobHidden is true
  • Show navigation on screen size md: and above in all cases
  • Add toggleMobHidden function and Tailwind CSS classes to allow navigation to be hidden
  • Customise text on mobile to make it clear that navigation can be shown/hidden

Acceptance criteria

N/A

Useful resources

N/A

Implement React Query (Tanstack)

Implement React Query and update API calls to use it.

Definition of done

  • React Query calls services for GET and POST.

Subtasks

  • Install package: npm i @tanstack/react-query
  • Install ESLint Plugin Query: npm i -D @tanstack/eslint-plugin-query
  • Implement QueryClientProvider
  • Implement for Heatmap (GET)
  • Implement for MyDay (POST)

Acceptance criteria

  • All queries in the app should use React Query.

Useful resources

Refactor TaskList component

Refactor the TaskList component, adding a Tasks component above. and React Query. This will make handling the isLoading and isError states simpler.

Definition of done

  • The same functionality is achieved with smaller, individual components.

Subtasks

  • Group Tasks components into a common folder
  • Rename TaskList to Tasks
  • Extract TaskList from Tasks
  • Clean up components

Acceptance criteria

  • N/A

Useful resources

  • N/A

Refactor Heatmap component

Break up the Heatmap component into smaller components which are fed directly by React Query. This will make handling the isLoading and isError states simpler.

Definition of done

  • The same functionality is achieved with smaller, individual components.

Subtasks

  • Group Heatmap components into a common folder
  • Extract HeatmapGrid
  • Extract HeatmapCard and render them using a map from HeatmapGrid and by passing props

Acceptance criteria

  • N/A

Useful resources

  • N/A

Add TaskList component to Dashboard

Create a TaskList component which accepts remaining tasks as props, and shows their status.

Definition of done

  • The TaskList component shows at least one task, and whether it is complete or not. The proposed first task is the completion of the MyDay form.

Subtasks

  • Create a TaskList component that accepts a tasks prop and maps to TaskListItem components
  • Pass the props which should include title, status, path and emoji
  • Add a hard-coded task for testing purposes
  • BLOCKER implement #5 to get access to API
  • Implement react-query for TaskList
  • Ensure task reflects whether the MyDay form has been completed today (based on API)
  • Add styling.

Acceptance criteria

N/A

Useful resources

N/A

Add tagging functionality to MyDay page

After #16

Allow the user to add tags for the current day.

Definition of done

  • User can tag events in the MyDay component by typing
  • Tags can be autofilled if there is a match (e.g. using the tab key or clicking)
  • Tags can be viewed in the Heatmap

Subtasks

  • Add input element to MyDay form
  • Enforce minimum and maximum lengths on tags
  • Add tag on space or tab
  • Display tags with delete option (cross)
  • Enforce maximum number of tags
  • Use flex on the input and row-wrap on the container, with styling, to simulate adding tags
  • Ensure no duplicate tags are stored (show error if so)
  • Ensure API stores tags
  • Display at least one tag on the Heatmap
  • #26
  • #27

Acceptance criteria

N/A

Useful resources

Improve error handling and loading experience for API requests

Implement more user-friendly loading/error messages in the Heatmap and TaskList components.

Definition of done

  • A loading message is displayed for both components while the data is being fetched
  • An error message is displayed for both components when the server is not running

Subtasks

  • BLOCKER: #49
  • Implement loading/error text for HeatmapGrid
  • BLOCKER: #51
  • Implement loading/error text for TaskList

Acceptance criteria

N/A

Useful resources

Install Node.js and create wellness API

Install Node.js and set up wellness API.

Definition of done

  • User can GET wellness data from backend
  • User can POST wellness data to backend

Subtasks

  • Install Node.js
  • Build out skeleton (index, app) and folder structure (routes, controllers, models)
  • Install Mongoose
  • Write tests for Day model
  • Create Day model with existing fields
  • Write tests for day controller
  • Create day controller with create and get functions
  • Write tests for day route (as the routes are simple and mplicitly covered by testing app.js)
  • Create day(s) route with GET and POST for now
  • Write tests for app using supertest
  • Link to frontend

Acceptance criteria

  • N/A

Useful resources

Allow users to view other users' profiles

  • Email should only be populated in the backend if the current user is logged in and is viewing their own profile, otherwise email: null should be returned (this would be used when viewing other users' profiles)

Create profile page

Definition of done (acceptance criteria)

A profile page should be accessible from the menu with:

  • username
  • email
  • date joined

Subtasks

Backend

  • Create GETfor Profile route using user ID for data above using req.user object
  • Ensure route is protected

Frontend

  • Create simple Profile page
  • Add Profile to routes - /profile route should display logged on user's profile
  • Style profile page to look consistent
  • Fetch data with useQuery hook and pass to frontend

Future work

Useful resources

N/A

Add an emoji picker with auto-suggest for weather and life events

Allow the user to add emojis for the current day. This is a major enhancement to #24.

Definition of done

  • User can choose emojis and add them similar to the existing tagging functionality (#4)
  • Auto-suggest emojis for matching tags (requires configuration and ability to remove)

Subtasks

  • Add an emoji picker for the weather (sun, rain, wind, thunderstorms, etc.)
  • Add an emoji picker for life events
  • Extend to each category (people, activities, life events)
  • Map certain tags to emojis (see if there is already a mapping)
  • Add configuration to auto-suggest emojis when tags match
  • Ensure ability to remove/re-add emojis (turn grey initially and colour as each one is added)

Acceptance criteria

N/A

Useful resources

Add authentication to allow user login

Install Passport.js and set up authentication/authorisation.

Definition of done

  • Authentication is set up
  • Authorisation is set up
  • Registration form is implemented
  • Login form is implemented

Subtasks

Backend

  • Install Passport.js
  • Create User model in MongoDB
  • Create API endpoints for registration
  • Create API endpoints for login
  • Add check for duplicate usernames
  • Add check for duplicate email addresses
  • #58

Frontend

  • Create Auth page (which will hold either the registration or login forms)
  • Create registration form
  • Link to backend
  • Create login form
  • Link to backend
  • Standardise backend error message codes using Firebase as a model and implement dictionary on front end to decode them (e.g. auth/email-already-in-use)
  • Handle client- and server-side errors the same way
  • Redirect to Login route if not authorised (route guard)
  • Add Logout button
  • #56
  • #57

Future work identified

Acceptance criteria

  • N/A

Useful resources

Add option to add/delete a day to the Heatmap

Definition of done

Days should be added via a modal and and removed via the Heatmap if the user changes their mind.

Subtasks

Backend

  • Create DELETEfor Day route
  • Create removeDay function in Day controller

Frontend

  • Turn MyDay form into modal in the Dashboard
  • #63

Acceptance criteria

  • User can DELETE a day from Dashboard modal using X icon
  • User can PUT (edit) a day from Dashboard modal using pencil icon

Future work

Useful resources

Add an emoji picker for weather and life events

Allow the user to choose an emoji rather than a score for the current day.

Definition of done

  • Replace scores with emojis (#4)

Subtasks

  • Replace MyDay scores with emojis
  • Show emojis on Heatmap
  • Modify Heatmap formatting to ensure responsive design

Note: future enhancements moved to #45.

Acceptance criteria

N/A

Useful resources

Add `user` field to `Day` model to allow filtering of days

Each user should be able to see only their own Day objects, and interact with them.

Definition of done

  • Details can be recorded for the current day and saved to the database for the current user
  • A user cannot edit another user's Day objects

Subtasks

  • Modify daySchema to add a reference to the current user
  • Update each method to ensure that for each day, only the correct user can:
    • POST
    • GET
    • DELETE

Useful resources

N/A

Separate frontend and backend in Docker deployment

  • Modify Dockerfile.server to remove build scripts for frontend
  • Create a Dockerfile.client for the frontend and add build scripts
  • Ensure frontend port is set correctly
  • Check and confirm environment variables
  • Update nginx configuration to serve frontend

Create README

Create a README for the project, including:

  • About the project
  • Built with
  • Getting started
    • Prerequisites
    • Installation
  • Roadmap
  • Contributing
  • Licence

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.