Skip to content

Latest commit

 

History

History
185 lines (142 loc) · 5.88 KB

start_app_locally_doc.md

File metadata and controls

185 lines (142 loc) · 5.88 KB

Running the App Locally

The app can be run as a standalone or using Docker, unless you are working on an machine running linux/ubuntu, it is adviseable to use Docker.

To run the app in production, see here.

For any errors during setup, please see the debugging doc.

Review the project details doc for more information on the technology stack.
Take note of the Client and Server README's.

Table of Contents

Using Docker ( Preferred )

The better/easier way to run the app is to use Docker, which will build both the frontend and the backend with the correct enviroment setup.

Docker Setup

Ensure you have docker & docker-compose installed on your computer, you can check with the following commands:

docker --version
docker-compose --version

If the above commands return an error, please install Docker and Docker-compose.

Running the app

Building the App

To build the app, from the root project directory, run the following command:

docker-compose -f docker-compose.yml up -d --build

Docker should create a container named 'masakhane-web' with the images 'db-1', 'server-1', and 'client-1'.
The server should be active on http://localhost:5000 and the client on http://localhost:3000
Look here for checking these services manually.

Shut down the app

To shut down the app, run the following command to remove the docker container:

docker-compose -f docker-compose.yml down

Add, Update, & Delete Languages

Add a Language

docker-compose -f docker-compose.yml exec server python manage.py add_language en-sw-JW300

The language code parameter en-sw-JW300 represents {src-lang}-{tgt-lang}-{shortform}
So en-sw-JW300 represents English-Swahili using JW300 shortform
Note - A code parameter example without shortform is en-tiv-

Download available languages csv here

Update Langugaes

curl --request GET 'http://127.0.0.1:5000/update'

Check available languages

docker-compose -f docker-compose.yml exec server python manage.py all_languages

Remove a language

docker-compose -f docker-compose.yml exec server python manage.py remove_language en-sw-JW300

Running tests

docker-compose -f docker-compose.yml exec server python manage.py tests

The Database

Look here for more information about accessing the database

As a stand-alone app

In order to run the app, we need to set up the backend and frontend seperately.
Note It is advisable to be working on an linux/ubuntu machine.

Backend Setup

First, ensure you are running Python 3.6.9

Within the src/server directory of the project

Install required packages:

pip install -r requirements.txt

Run the following commands:

export FLASK_APP=core/__init__.py
export FLASK_ENV=development

Run the server:

To start the API and database services, run the command:

python manage.py run

The Database

Look here for more information about accessing the database

Add, Update, & Delete Languages

Add a Language

python manage.py add_language en-sw-JW300

The language code parameter en-sw-JW300 represents {src-lang}-{tgt-lang}-{shortform}
So en-sw-JW300 represents English-Swahili using JW300 shortform
Note - A code parameter example without shortform is en-tiv-

Download available languages csv here

Update Langugaes

curl --request GET 'http://127.0.0.1:5000/update'

Check available languages

python manage.py all_languages

Remove a language

python manage.py remove_language en-sw-JW300

Running tests

python manage.py tests

The API is available at http://localhost:5000, see notable API endpoints here

Frontend Setup

Ensure you have node.js and yarn installed

Within the src/client/ directory of the project: Install required packages:

npm install --legacy-peer-deps

Run the following commands:

npm i webpack webpack-cli --legacy-peer-deps
npm i @babel/core @babel/preset-env @babel/preset-react babel-loader --legacy-peer-deps

Run the client:

To start the client , run the command:

npm run develop

The client is available at http://localhost:3000

Errors during setup

If there was a problem during setup, review this doc for possible errors and solutions.