NOTE: To enable logging in with google you should normally supply your own client id and secret. These can be supplied by setting the following environment variables: GOOGLE_CLIENT_ID
and GOOGLE_CLIENT_SECRET
.
In this application, it will use my client id and secret which should be sufficient to test the application.
- Run
npm install
to install dependencies. - Run
npm start
to start the application. - To access the application type
http://localhost:3000
in your browser. - Run
npm test
to run all tests with coverage.- Running my tests with full coverage should give about
73%
- Running my tests with full coverage should give about
When running the application, one can either authenticate with Google, sign up with a new Local user, or use any of these premade users:
* username: test
* password: test
* username: test2
* password: test
This is a messaging application where users can either sign up with providing the app a username and password etc, or use Google to sign up/in. The login system is using passport and are both authenticating and storing users in the backend. All navigation is done through the menu at the top.
-
To sign up/in:
- Go to the sign in page. Here you have three choices:
- Sign in if you have an existing user.
- Sign in / up with Google.
- Sign up by clicking the sign up button and filling out the form.
- Go to the sign in page. Here you have three choices:
-
Send a message:
- Go to inbox and click
send new message
and fill out the form and click send. To select recipients you may either select a recipient from the dropdown or type the username in the input field, and then press the plus (+) button. All selected recipients are listet at the top of the form. It is not possible to remove recipients after they are added.
- Go to inbox and click
-
Reply to message:
- Go to inbox and click either
reply
orreply all
below the message you want to reply to.
- Go to inbox and click either
-
Archive a message:
- Go to inbox and click
delete
below the message you want to archive. The message is then removed from your inbox and put into your archive. (NOTE: This does not remove the message from the database)
- Go to inbox and click
-
See your outbox:
- Navigate to the outbox to see your sent messages.
-
See your archive:
- Navigate to the archive to see your deleted messages.
-
Notifications for incoming messages:
- Whenever you receive a message while being logged in, you will get a notification above the menu bar. The notification will be present for about 5 seconds, or until you either click it to go to your inbox or click X to remove it.
An important pillar for the application design is the database structure. I have divided this into three entities:
- Users:
- Stores information about all signed up users.
- Messages:
- Stores the actual messages sent including information about the sender and timestamp.
- Recipients:
- Stores one row per recipient per message. This enables me to have a status on each message per recipient.
I use WebSockets to enable the server to notify the client. These WebSockets are created by the client and the client identifies itself by sending a first message on the WebSocket at login.
Instead of having logged in users creating new accounts to chat with, I decided to implement a more secure system where every individual user can sign up themselves. I have implemented use of Passport for authentication whether you use Google or create a Local user.
The client is developed using React with functional components, and built with parcel. The Server is built with Express.
My focus on the exam has been to make an application where the main functionality is already in place. There has been less focus on layout, styling and "nice-to-have" features. The first things to enhance in this application is the following:
- Form validation on sign up.
- Form validation when composing a message.
- Not being able to choose same recipient multiple times.
- Additional fields such as subject, cc etc.
- Functionality for forwarding a message.
- Being able to add/remove recipients when composing or replying to a message.
- Being able to reply and forward a message from outbox or archive.
- Being able to un-delete a message from the archive.
- Styling
- Client:
- The file structure on the client is very simple. All React components are in the
components
directory, custom hooks inhooks
, http functions inapi
and React context incontexts
.
- The file structure on the client is very simple. All React components are in the
- Server:
- Very simple and easy to understand. All storing of data and database service functions are in the
db
directory. Every route is in theroutes
directory, and all controllers are in thecontrollers
directory.
- Very simple and easy to understand. All storing of data and database service functions are in the
Some of the components and custom hooks used in this exam is heavily inspired by code shown in class.
- 8034