Giter Site home page Giter Site logo

ambitious-messenger's Introduction

A modern web messaging application

Run Database container

Clone the project

  git clone https://github.com/briantwene/ambitious-bishes.git

Go to the database folder

  cd database

Create a docker volume called db_data

  docker volume create db_data

Then, start the container

  docker compose up

The database should be running

Next, is to get prisma working, the schema is there already

Install dependencies (make sure that you're in /backend)

  npm install

now run the following to generate the prisma client

  npx prisma generate

OR

You probably wont have to do this, but @briantwene will let you know

if the prisma schema has changed (if a table has been added or modified) run this

  npx prisma migrate dev

Then

One last thing would be to create an .env file in /backend and add the following:

# Database configuration
DATABASE_URL=postgresql://username:password@localhost:5432/databasename?schema=public

The username, password and database can be found in docker-compose.yml

React app setup

  1. Install dependencies
  cd frontend
  npm install
  1. Run dev build
  npm run dev

Notes

Sass variables

Here is a list of the current Sass variables:

$color-primary: #0881a3;
$color-primary-bright: #84d2e8;
$color-primary-dark: #125067;

$color-secondary: #adadad;
$color-secondary-bright: #f7f7f7;
$color-secondary-dark: #363636;

$color-text: #111111;
$color-text-bright: #33373d;

$color-invalid: #dd1c1a;

$font-light: 300;
$font-regular: 400;
$font-semibold: 600;
$font-bold: 800;

$font-small: 0.85rem;

To use them just import the variables.scss file in the modules.scss file, for example:

@import "./sass_utilities/variables.scss";

ambitious-messenger's People

Contributors

briantwene avatar klavzars avatar linchenchn avatar

Watchers

 avatar

Forkers

linchenchn

ambitious-messenger's Issues

Implement Storage Bucket for application

Description

The idea here is to create a service that will handle the storage of things such as images, videos and files. Could also be used to store the profile pictures and voice messages themselves then have a pointer in the database

this will be a separate server like the webRTC server which I, @briantwene is working on.

For this a service called Minio will be used which is an open source self hosted AWS S3 like bucket. Virtually anything can be stored in it and it works for a small scale project like this.

TODO

  • Create a folder at the root of the project called "storage-service"
  • Follow the docs and setup a docker container (or docker-compose container)

Once you have it you can follow the instructions to login and create a bucket

Then you can make a function that would upload the file that is sent to the main server to the storage server
Also make a function that would get a file based on the reference that is stored in database.

This function can then be used for messages where a user has an attachment (video, image, other files)

Once you test it and it works we could then start adding different message types (I think you still have the code for that from when you first implemented message domain). It can also be used to store profile pictures that user uploads.

The process would go like this:

  1. user upload file on frontend
  2. server gets this file
  3. stores the name or some reference (into the database) (depends on if it is an attachment to a message or profile pic)
  4. store the file in the storage server
  5. All done

And for downloads:

  1. get data from db with reference to file
  2. use reference to get file from storage
  3. send the file back to the user

some links:

Yeah this is a lot to read but we don't have time and I have been thinking about this for weeks (was all in my head ๐Ÿคฃ ) so you don't have to worry. If you do have any issues let me know ๐Ÿ™‚

[BACKEND] - Add isEdited to message model

@douzi-001 task
on the message model of prisma, just add an isEdited column that is a boolean (true/false)

this will be false by default but set to true when a user updates a message

[BACKEND] - User Authentication

Description

The aim here is to use passport.js combined with JWT to provide authentication

This is also for adding multiples integrations later on.

User sends login

create JWT and send it like normal

Make middle ware that uses passport to sign the user in

for generating a more secure secret

    node -e "console.log(require('crypto').randomBytes(256).toString('base64'));"

Some links

[BACKEND][MVP] - Messages Domain Setup

so for messages we will have 4 operations based of CURD

domain endpoint /message

  • create message - /create - HTTP (POST)
  • delete message -/delete - HTTP (DELETE)
  • update message - /update - HTTP (PUT)
  • read message - /read - HTTP (GET)

read message can be for getting all the messages that are in a chat (for when a user opens a chat)

when doing the message.dao.js make a class and put the functions to do each of these and then return them

can use prisma client

WebSocket Implementation

Implement the WebSocket domain in the backend that will be used
to enable Realtime communications and messages to users

The NPM socket.io package will be used here

[BACKEND] - Folder setup

Description

Just to add the general folder structure using the NodeJS best practices

Folder Structure

Image

[DEVOPS] Setup basic DevOps fllow

Description

@briantwene's task

The aim here is to come up with a basic DevOps flow of some sort using GitHub actions

The main pipelines that will be made will be for building and deploying

Build Pipeline

This pipeline will run tests and package the application so that it can be deployed by the other script

Frontend

For the frontend a simple linting test can be done to ensure the code written based of ESlint rules

Backend

For the backend tests will be done in the following areas:

  • Linting
  • Prisma database: ensuring the main DAO functions work as expected with a mock Prisma client and DB
  • API Layer tests: can start with simple postman tests before doing full on unit tests
  • Lib functions: generic functions that are used accross the app should be tested too
  • coverage: aim for 50% code coverage with tests

Deploy Pipeline

After building and everything going well, on push to main the deploy pipeline can be triggered. This can copy the repo to the production environment and then deploy the container

Notes

DigitalOcean will be used to deploy the application.

Some links:

[BACKEND] - User Domain setup

Description

Create the following files based off the project structure for the user domain, you can do this once @briantwene has done
"[BACKEND] - Folder Setup"

  • api.js: express routes will go here

  • controller.js functions that handle the express routes will go here

  • dao.js: database related functions will go here

Then

in user.api.js you can add the express router and create the following routes:

/profile/:id

  • This will be a HTTP GET endpoint
  • this will take in an id parameter which will be the id of a user profile
  • this is for getting back infomation on a profile

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.