Skip to content

cascaritaco/cascarita

Repository files navigation

Cascarita

Welcome to Cascarita! This file provides instructions on how to run important commands and navigate through the project.

Getting Started

Prerequisites

Before you begin, make sure you have the following installed:

  • brew - Make sure brew is installed

Installation

  1. Install Node
brew install node
  1. Setup the MySQL database
# install and activate mysql service
brew install mysql
brew services start mysql

# This will log you into SQL CLI (ie. mysql>)
mysql -u root

# Lastly create the following database
CREATE DATABASE test_db;
  1. Setup the MongoDB database
# Download the official Homebrew formula for MongoDB
brew tap mongodb/brew
# Install MongoDB
brew install mongodb-community@7.0
# Start the MongoDB service
brew services start mongodb-community@7.0
  1. Clone the repository to your local machine
git clone git@github.com:cascaritaco/cascarita.git
  1. Change into the project directory:
cd cascarita
  1. Install project dependencies:
npm install
  1. Create a free MongoDB Atlas cluster here.

  2. Once your cluster is created, get your connection string to extract the username, password, url, and app name.

mongodb+srv://USERNAME:PASSWORD@$URL/?retryWrites=true&w=majority&appName=$APPNAME
  1. Copy .env.example into a new file named .env. Populate the MONGO_* environment variables from .env with the data extracted from the connection string.
# MongoDB cluster configuration
MONGO_CLUSTER_USERNAME=
MONGO_CLUSTER_PASSWORD=
MONGO_CLUSTER_DB_NAME=
MONGO_CLUSTER_URL=
MONGO_CLUSTER_APP_NAME=
  1. If your MySQL database requires a password, make sure you set that password in the .env as well.
DB_NAME=test_db
DB_PASSWORD=your-password

Using Docker

If you haven't done so, please download Docker Desktop, and start the Docker daemon, then run:

# load the environment variables
cp .env.example .env
# build the images
docker-compose build
# start the client and server container
docker-compose up

NOTE: It's important to ensure that for local connections to database from the server container, specify within the .env DB_HOST=host.docker.internal. This will be the way we are planning on deploying our applicaton to the cloud!

1. Start the Development Server

To run the project locally, use the following command:

# load the environment variables
cp .env.example .env
# runs react frontend on port 3000 and backend node server on port 3001
npm run dev

NOTE: In order for this to work you will need to ensure that .env DB_HOST=127.0.0.1.

2. Start the Production Server

To run the project as in production:

# load the environment variables
cp .env.example .env
# builds the `dist` directory used to serve frontend
npm run build
# starts the node server
npm run start

3. Running Tests

To run the Jest tests:

npm run test

4. Running Coverage

To see total testing coverage:

npm run coverage

5. Running ESlint

To identify and fixing problems in our code:

npm run eslint

6. Running DB Migrations

To run any Sequalize migrations:

npm run sequelize:migrate