Code Monkey home page Code Monkey logo

comunidades-unidas-internal's Introduction

comunidades-unidas-internal

Build Status

The code for comunidades unidas internal website

This project uses Node + Express to interact with a MySQL Database and provide JSON APIs. The frontend is a React SPA that uses Typescript, babel, and webpack.

API Documentation

comunidades-unidas-internal exposes JSON REST APIs at https://database.cuutah.org/api.

API Documentation

Setup

Here are instructions to boot up this project locally so that you can change the code.

First, install the following:

  • Git
  • Docker. This will also install docker-compose.
  • Node. Feel free to use nvm for this if you prefer, but any installation will work.
  • Yarn. If you use Mac, this may require that you first install Homebrew.

Now, run the following commands in a terminal:

git clone [email protected]:JustUtahCoders/comunidades-unidas-internal.git
cd comunidades-unidas-internal
yarn install
yarn fix-everything

Now create a file inside of the comunidades-unidas-internal directory called .env.

# Required for local dev - can be any value
KEYGRIP_SECRET=123

# Only needed if you're testing specific features
# Ask Joel or Leonel for the values to use if you need them

# USE_GOOGLE_AUTH=true
# GOOGLE_CLIENT_ID=<insert_id_here>
# GOOGLE_CLIENT_SECRET=<insert_client_secret_here>
# GOOGLE_CALLBACK_URL=http://localhost:8080/api/auth/google/callback
# GUEST_GITHUB_KEY=<insert_github_key_here>
# JPLS_USERNAME=<juntos_por_la_salud_ventanilla_username>
# JPLS_PASSWORD=<juntos_por_la_salud_ventanilla_password>

Now run the following command:

yarn develop

Now go to http://localhost:8080 in a browser.

Deployments

This project is hosted by AWS Elastic Beanstalk. To deploy the code, simply merge a pull request to master, which will automatically trigger a deployment via Travis CI. You can see all current and previous deployments at https://travis-ci.org/JustUtahCoders/comunidades-unidas-internal.

Database Migrations

If you need to make a change to the database schema, create a database migration by running the following command:

npx db-migrate create name-of-the-migration --sql-file

This will create a directory in the migrations folder that has an "up" and a "down" sql file. The up file should create tables or modify columns, the down file should drop tables and unmodify columns.

After creating a migration, you'll have to run npx db-migrate up to run it against your local database. Alternatively, you can restart your local environment (Ctrl + C and then yarn develop). The migration will automatically run on the production database during the deployment in Travis CI.

Connecting to the database

Local development

From a terminal in the comunidades-unidas-internal directory, run the following commands:

docker-compose exec db bash
mysql -u root -ppassword # yep, it has two p's. The first is for password, the second is for the word password which is the password

# Now you'll be in the mysql shell
use local_db;
show tables;
SELECT * FROM clients;
# etc etc

Production database

Run the following commands in a terminal. Replace $HOSTNAME, $USERNAME, and $PASSWORD with the correct values.

mysql -h $HOSTNAME -u $USERNAME -p$PASSWORD
# OR, if you don't have `mysql` installed on your computer
docker run -it --rm mysql mysql -h $HOSTNAME -u $USERNAME -p$PASSWORD

# Now you'll be in the mysql shell
use ebdb;
show tables;
SELECT * FROM clients;

SSH access

Install ebcli. Then run eb ssh. Our code is inside of the /var/app/current/ directory.

Diagnosing problems / outages

If the production environment is having issues, you'll need access to Comunidades Unidas' AWS account to diagnose. Once you have access, you'll need to install Python3 and ebcli. Then run eb status, eb logs, and other commands to try to diagnose.

comunidades-unidas-internal's People

Contributors

joeldenning avatar meghanbomberger avatar jenseng avatar leoneln avatar

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.