A "feature request" is a request for a new feature that will be added onto an existing piece of software. Assume that the user is an employee at IWS who would be entering this information after having some correspondence with the client that is requesting the feature.
- Users can create an account, log in and logout.
- Users can add new features from their clients.
- Users can view all the features available.
- Features, of a particular client, are reasigned their priorities based on the priority of the newly added one.
- Users can edit the features that have already been added.
- OS: Ubuntu
- Server Side Scripting: Python 3.6+
- Server Framework: Flask
- ORM: Sql-Alchemy
- JavaScript: JQuery
I used the MVC pattern of programming whose flow is outlined below.
- The user makes a request along a route, let’s say /index.
- The controller receives this request and gives a specific set of orders that are related to that route. These instructions could either be for the view to update or serve a certain page, or for the model to perform specific logic. If this request has some logic associated with it, then the model carries out the logic, pulls from a database and sends back a consistent response based on the controller’s instructions.
- The controller then passes this data to the view to update the user interface.
Used gcloud to deploy the project. Below are the steps taken.
-
Create a google VM instance that runs Ubuntu 18.04 LTS
-
Update the local apt package index:
sudo apt-get update
-
Install nginx, postgres, pip and additional libraries:
sudo apt-get install python3-pip python3-dev libpq-dev postgresql postgresql-contrib nginx
and then run:sudo apt-get install build-essential libssl-dev libffi-dev python-dev
-
Install apache:
sudo apt install apache2
-
Install and configure git
-
Generate ssh keys and add public key to github
-
Login into Postgres:
sudo -u postgres psql
-
Create database called featureapp:
CREATE DATABASE featureapp;
-
Create user for the database:
CREATE USER yourusername WITH PASSWORD 'yourpassword';
and then:GRANT ALL PRIVILEGES ON DATABASE featureapp TO yourusername;
-
Git clone: git clone https://github.com/sharonmalio/feature-request-app.git and change in to the project directory
-
Install python VENV from the terminal sudo apt-get install python3-venv
-
Delete the virtual env in the project folder. (look for a folder called featurequestenv within the root directory of the project): sudo rm -R featurequestenv
-
Create another venv called featurequestenv or a name of your choice. python3 -m venv featurequestenv
-
cd into the virtual environment:
cd featurequestenv
-
Activate the virtual environment:
source featurequestenv/bin/activate
-
Install dependencies (contained in a file called requirements.txt in the root directory of the project):
pip install -r requirements.txt
-
Initialize the db
python manage.py db init
migrate the db:python manage.py db migrate
and then run:python manage.py db upgrade
to apply the upgrades -
Create Gunicorn systemd service file:
sudo nano /etc/systemd/system/gunicorn.service
-
Add the following to the file
[Unit]
Description=gunicorn daemon
After=network.target
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=replace-user-here
Group=www-data
WorkingDirectory=/home/replace-user-here/myproject
ExecStart=/home/replace-user-here/your-project-name/your-env/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/replace-user-here/your-project-name/your-project-name.sock wsgi:app
[Install]
WantedBy=multi-user.target
-
Start and enable Gunicorn:
sudo systemctl start gunicorn
and run:sudo systemctl enable gunicorn
-
Configure Nginx:
sudo nano /etc/nginx/sites-available/project-name
-
Add to the file
server {
listen 80;
server_name server_domain_or_IP;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/replace-user-here/project-name;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/replace-user-here/project-name/project-name.sock;
}
}
-
Enable file:
sudo ln -s /etc/nginx/sites-available/project-name /etc/nginx/sites-enabled
-
Restart Nginx:
sudo systemctl restart nginx
- PYTHON: Install python. To check whether you have python installed, run the command:
python3
- PostgreSQL:Install PostgreSQL :(https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-18-04)
- PIP: Install pip:
sudo apt install python3-pip
Verify the installation:pip3 --version
Follow this url to access the application in your browser: (http://35.240.3.36)
-
Git clone:
git clone https://github.com/sharonmalio/feature-request-app.git
and change in to the project directory -
Install python VENV from the terminal
sudo apt-get install python3-venv
-
Delete the virtual env in the project folder. (look for a folder called featurequestenv within the root directory of the project):
sudo rm -R featurequestenv
-
Create another venv called featurequestenv or a name of your choice.
python3 -m venv featurequestenv
-
cd into the virtual environment:
cd featurequestenv
-
Activate the virtual environment:
source featurequestenv/bin/activate
-
Install dependencies (contained in a file called requirements.txt in the root directory of the project):
pip install -r requirements.txt
-
Login into PostgreSQL in the terminal.
-
Create a database called featureapp:
CREATE DATABASE featureapp;Exit;
-
Initialize the db
python manage.py db init
migrate the db:python manage.py db migrate
and then run:python manage.py db upgrade
to apply the upgrades -
Start the application:
flask run -p 5000
or using gunicorngunicorn --bind 0.0.0.0:8000 wsgi:app
-
Open your web browser and navigate to the address:(http://127.0.0.1:5000) or gunicorn: (http://0.0.0.0:8000)
-
Install docker in your machine: (https://docs.docker.com/install/linux/docker-ce/ubuntu/)
-
To verify that docker is up and running use the command below, you should get a hello from docker message
sudo docker container run hello-world
-
Install docker-compose:
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
If you have issues with curl you could use pip:pip install -U docker-compose
-
Apply executable permissions to the binary:
sudo chmod +x /usr/local/bin/docker-compose
-
You can also create a symbolic link to /usr/bin:
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
-
Test the installation.
docker-compose --version
-
Change the directory to the project folder:
cd feature-request-app
activate the virtual env:source featurequestenv/bin/activate
build the docker image:docker-compose build
-
launch the application:
docker-compose up
-
Navigate to the address:(http://0.0.0.0:5000)
I added register to ease the site interractio. Otherwise the IWS admin should be the one adding her employees to the system
- In the navigation bar click on login
- Below the login page there is a link that says "Click to Register"
- Follow the link and fill the information as required.
- click on the register button when done. Below is a an image that shows the view of the register page.
This assumes that you already exist in the application and you got the login credentials.
- In the navigation bar click on login.
- Fill in the information as required.
- Click on the sign in button once done.
Below is a screenshot of the login view
This step requires that you are logged in user.
- In the navigation bar click on New Feature.
- in the form presented fill in the details as required.
- Click on the submit button once done.
- A successful message will show.
- Click on the All Features in the navigation bar.
- The features available in the database will show here.
Below is a screenshot of the view.