We will use a microservice architecture to implement this application. Our main application will be divided into 3 primary services:
- Client
- Server
- Database
The root directory of the project is /LH2020. The codebase will be set up in the following directory structure:
/LH2020
├── server/
├── client/
└── venv/LH2020/server/: Directory which will hold the flask API. All NLP processing will be done inside the flask instance upon request from the frontend.LH2020/client/: Directory which will hold the ReactJS app. All user interactions will be done through here.
It is best to create a virtual enviornment for development as it segrates our codebase dependencies from other projects that could be present on your development device. We will utilize
venvfor it.
To setup virtual enviornment do the following:
- Navigate to the top level directory of this repository.
/LH2020- Create the python virtual enviornment by running the following command
$ python3 -m venv venv- Activate the virtual enviornment. You should see
(venv)on your terminal before the current working directory.
$ . venv/bin/activate- The project has a
requirements.txtfile which lists all the dependencies needed by the flask API. Run the following command (in the root directory with activation ofvenv) to install all dependencies.
(venv) $ pip install -r requirements.txtNOTE:
(venv) $signifies that this command be issues after activating the virtual enviornment.
- The development enviornment has now been set up successfully. Once finished wth development youu can issue the following command to deactivate the virtual enviornment.
$ deactivateAlternatively there is a bash script which will handle all the development enviornemt=ent setup and installing the dependecies for you. YOu can run this script in yout terminal like this
$ ./setupYou might need to give the file permissions to be executable. That can be accomplished by using the
chmodcommand on abashterminal$ chmod 775 setup
- Navigate to the root directory
- Activate
venvand install all dependencies. (Could simply run thesetupscript) - run the following command
$ python server/app.py- Navigate to
http://localhost:5000/