Coder Social home page Coder Social logo

klear-backend's Introduction

Setup

  1. Ensure .env's information is correct from bootstrap for db connection. Follow instructions under "Authentication Service Set Up" to get ACCESS_TOKEN_SECRET
  2. Run ./script/bootstrap.
  3. Make sure you have a MySQL username and password, and make sure the MySQL server is running.
  4. Ensure a database/config/dev.json file is created with the correct information to connect to your local db. This file is used to run db migrations.
    • ONLY IF NOT CREATED PROPERLY: Follow instructions under "Migrations" to set up properly. And then run db-migrate up --config ./database/config/dev.json
  5. Start the mysql server mysql start
  6. Run npm start

Database

Prod database

  • can be accessed through: http://3.142.235.3/phpmyadmin/index.php
  • contact someone on the team to get the proper credentials to access prod db
  • if developing in dev, use your own local database so we don't make changes we don't want to on prod
  • if you want to connect to the prod database go into your .env and change host to the prod host and the user to the correct user instead which would be: 3.142.235.3

Dev database

  • if not working then you might need to add this line in .env and database/config/dev.json: "socketPath": "/var/run/mysqld/mysqld.sock"
  • Make sure to run new migrations if pulling new code that has any db changes.

Migrations

Set up

  • Create a database/config/dev.json file and paste the following:
{
    "dev": {
        "host": "", 
        "user": "",
        "password": "",
        "database": "",
        "driver": "mysql",
        "multipleStatements": true
    }, "sql-file": true
}
  • Fill out the necessary information

To run migrations

  • db-migrate create SQL_ACTION_NAME --config ./database/config/dev.json to create migration files, this will create a .js file and two .sql files with the date and SQL_ACTION_NAME. The .sql file with the name 'up' should contain the migration that you want to run and the 'down' should contain the reverse to undo the migrations ran. The .js file is the logic that runs everything, this does not need to be changed usually.
  • db-migrate up --config ./database/config/dev.json to run all migrations in order
  • db-migrate down --config./database/config/dev.json to drop all migrations
  • mysql -u root -p to log into mysql

To run the CV/ML service

  • Download the file resnet-34_kinetics.onnx from our Google Drive(https://drive.google.com/drive/folders/14O32x--6oFAjRydepzN3o3ghKVzk1EkU) as GitHub has a file size limit
  • Place resnet-34_kinetics.onnx in the folder cvservice
  • Go into the folder cvservice by running cd cvservice
  • Run python3 ./human_activity_reco.py
  • You'll likely have to show the webcam a picture of a child crying on your phone for it to detect and trigger a notification

Testing User

Authentication Serivce Set up

For authentication, we use jwt to create an access token. For dev purposes, each dev will need to set up their own ACCESS_TOKEN_SECRET in their .env file. To do so:

  • run node
  • run require("crypto").randomBytes(64).toString("hex")
  • paste the results in .env file under ACCESS_TOKEN_SECRET Note that each dev's token will be different since it's random. To debug, you can use jwt's website to do so.

Miscellaneous

Debugging:

  • If any issues with connection to your database try adding: "socketPath": "/var/run/mysqld/mysqld.sock" under dev.json

Production

To start or stop the server from running:

  • sudo systemctl start YourAppName.service to start the server
  • sudo systemctl stop YourAppName.service to stop the server

Demo information

Testing User

  • Use [email protected] with the password "pw" to login to a generic account.

  • For demo purposes, clicking on the returning user "Karen" will automatically log in without needing to input password.

klear-backend's People

Contributors

shirleyofhuang avatar mercutaime avatar nat-alie-ho avatar natyho avatar kerryzhu108 avatar

Forkers

kerryzhu108

klear-backend's Issues

Discussion Around Edge Processing

In the pitch feedback, our partner mentioned that 3D res-nets would be too large for most cameras. What are other potential solutions other than the suggested hardware installation?

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.