Giter Club home page Giter Club logo

chit-chat's Introduction

Project Setup Guide

Introduction

In case anyone reads this, this guide is mainly for my reference during development.

Frontend

Starting the Frontend

In the root project directory, you can run:

npm install --prefix client

Next, you can change to the 'client' directory and run:

npm start

To kill all PID's in client directory run:

sudo lsof -ti:4000 | xargs sudo kill -9

Backend

Installing Dependencies

From the chit-chat project directory run:

pip install -r requirements.txt

Managing Dependencies

Check if dependencies are outdated:

pip list --outdated

Upgrade dependencies with:

pip install --upgrade package-name

Uninstall dependencies with:

pip uninstall package-name

PostgreSQL Setup

Change to the server directory: Check if the PostgreSQL server is online by running:

sudo service postgresql status

If it's offline, start the server with:

sudo service postgresql start

Environment Variables

Set up/create environment variables, largely for endpoints:

Set environment variables to development:

source set_env_vars.sh development

Set environment variables to production:

source set_env_vars.sh production

Database Connection

Check PostgreSQL database connection:

Change into the 'server directory' then

python test_db_connection.py

Test password hashing:

 python test_password_hashing.py

Switching between production and development workflow:

Development environment:

The alembic directory and alembic.ini file should be in the server directory. In the env.py file, change the import from import server.models as models to import models as models. Next generate alembic.ini file if needed using script, make sure this alembic.ini is in .gitignore. Run migratiions and check if they run correctly using psql. May have to manually do it using psql commands.

Production environment:

For production development, the alembic directory and alembic.ini file should be in the root project directory. Alembic.ini can be generated using script, does not need to be hidden in .gitignore as no sensitive information is in it. Change import in env.py file to import server.models as models. Run migrations using heroku commands, doing it manually if needed as well.

Generate Alembic.ini file to run migrations

Navigate to 'server' directory:

For local database migrations:

 python localdb_generate_alembic_ini.py

For heroku database migrations:

 python heroku_generate_alembic_ini.py

Run migrations:

Locally:

alembic revision --autogenerate -m "Your migration message here"
alembic upgrade head

With Heroku:

heroku run alembic upgrade head --app chit-chat-backend

Check Heroku database:

heroku pg:psql --app chit-chat-backend

Checking database list and roles:

Enter postgres shell:

```bash
sudo -u postgres psql
```

Check database and roles:

```bash
\du
\l
```

Check users table:

```bash
SELECT table_name FROM information_schema.tables WHERE table_name = 'users';
```

List tables:

```bash
psql -U db-username -d db-name -h localhost -W
```

Enter password for db-username, then:

    ```bash
    \dt
    ```

Running the Backend Server locally

Spin up the backend server in the 'chit-chat' directory with:

gunicorn -w 4 -b 0.0.0.0:5555 server.app:app

If it won't spin up, see if it's already running with:

pgrep gunicorn

Kill these PIDs with:

pkill -9 gunicorn

Then re-run the gunicorn command:

gunicorn -w 4 -b 0.0.0.0:5555 server.app:app

Heroku commands:

Check heroku logs:

 heroku logs --tail --app chit-chat-backend

Scale/run dyno:

heroku ps:scale web=1 --app chit-chat-backend

Stop dyno

heroku ps:scale web=0 --app chit-chat-backend

Restart dyno:

heroku ps:restart --app chit-chat-backend

Setting up awscli version 2 to be used over version 1:

export PATH="/usr/local/bin:$HOME/Development/code/bag-talk/chit-chat:$PATH"

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.