Skip to content

Codice full-stack application built with Nodejs + PostgreSQL + Express + Vue + R

Notifications You must be signed in to change notification settings

edgar8acas/codice

Repository files navigation

Códice

Full stack web application, aimed at aiding deaf people to improve their vocabulary through interactive readings.

Built with

  • Node
  • R
  • Vue
  • PostgreSQL

Required OS

Tested in Windows 10 and Linux, though it should work in Mac OS as well.

Required software (latest stable versions)

Software Download links
Node Windows
Yarn (package manager) Windows
PostgreSQL Windows
Docker (recommended) Windows
R (not required if docker is going to be used, read below) Windows

Setup

R

The R code has been moved to a separate repo that you can find here.

Using docker (recommended)

The scripts can now run inside a docker container exposing the processing function via an API for consumption as a web service.

When running the container one must specify the port that will be used in the host to hit the API. More instructions on how to do this are available on the new repository containing the R code.

After starting the container, you should create a file containing an environment variable indicating the url where the R service will be available. The file must be called .env and placed in the root folder of this repository. Take a look at the example file named .env.example.

Without docker

You can still bootstrap the server by directly installing R in the host machine and executing the following scripts in order:

  • install_deps.R to install the necessary dependencies
  • plumber.R to start the server

An .env file should still be placed as indicated above.

PostgreSQL

When installing PostgreSQL, we are asked to enter the password that will be used for the default role.

After the installation is completed, we need to open the interactive terminal in order to execute the necessary commands to create the database. The terminal is available in Windows as "SQL Shell" while in Linux we can use the psql command.

Right now, we have a default role called postgres. Which can be used to connect the node application and the database server, though it's not recommended for security reasons. Therefore, we are going to create a new role:

CREATE ROLE codice1 WITH LOGIN CREATEDB PASSWORD 'codice1';

And a new database:

CREATE DATABASE codice_dev WITH OWNER codice1;

NOTE: we can customize the role, password and database name, but we will also need to change the corresponding data in config/database.config.js file.

We can now close the shell and re-enter with our new credentials.

The database structure as well as the example data can be generated by executing the SQL scripts present in the src/server/database folder. A more convenient option is to run the command yarn migrate after installing the project dependencies as shown in the Project setup.

The script create-tables.sql contains the table creation commands and the scripts starting with insert-* contain commands to populate the database with example data.

Node

Installing dependencies inside the project root folder:

yarn install

The nodemon package is useful for development, we can install it as a dependency or globally with:

yarn global add nodemon

To start the development server, we need to execute the command:

yarn dev

This command will start both frontend and backend services in different ports. The server will be available in localhost:5000 and the frontend in localhost:3000.

Production setup

The following command will bundle our frontend sources and place them in the src/server/dist folder, (this folder is not included in the source code and will be generated automatically by running the command).

yarn build

The server can now start with:

yarn start

Both server and frontend will be available in localhost:5000.

NOTE: In production, the database connection info should be placed in the .env file located in the root folder and has to be formatted as a connection url:

DATABASE_URL=postgres://{user}:{password}@{hostname}:{port}/{database-name}
Docker

You can put the backend of the app in a docker container, just check the configuration that is present in the Dockerfile and adjust accordingly. You'll likely just want to copy the .env file or find a way to make the variables available inside the container.

About

Codice full-stack application built with Nodejs + PostgreSQL + Express + Vue + R

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages