An application that is built as a donation for Prishtina Municipality as part of Techstituion Program. The app consists of two core parts, the first one is about the administrative part in which Municipality Employees can manage the contracts, datasets, users and directorates. The contract's people in charge can also comment inside of contracts. The second part is the main purpose of this app, the transparency and accountability in which through visualization are displayed the trends of contracts in Prishtina through years and other rich information.
- Server Side Plaform: Node.js
- Backend Framework: Express.js
- Database: MongoDB
- Processing Data Language: Python
- Web Service API: REST
- ODM: Mongoose
- JavaScript Superset: TypeScript
- Frontend Framework: Angular 5
- Responsive Interface: Bootstrap 4
- Visualizations: Highcharts
- NodeJS
- MongoDB 3.6
- Git
- Angular CLI
- Pip (For processing data app)
- Nginx (Only for Production)
- PM2 (Only for Production)
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
To compile and install native addons from npm you may also need to install build tools:
sudo apt-get install -y build-essential
- Import the public key used by the package management sytem:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
- Create a list file for MongoDB Ubuntu 16.04:
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
- Reaload local package database
sudo apt-get update
- Install the MongoDB packages
sudo apt-get install -y mongodb-org
- Enable service to start on startup
systemctl enable mongod.service
sudo apt-get install git
sudo npm install -g @angular/cli@latest
sudo apt-get install python-pip python-dev build-essential
sudo pip install --upgrade pip
sudo pip install --upgrade virtualenv
Clone the project in your local machine.
git clone https://github.com/opendatakosovo/open-contracts-app/
Change directory
cd open-contracts-app
Install back-end dependencies
npm install
Create user in mongodb
use opencontracts
db.createUser({
user: "username",
pwd: "password",
roles: [{
role: "readWrite" , db:"database-name"
}]
});
Create a copy of .env-template file with name .env
cp .env-template .env
Set your values inside the .env file:
DB_HOST=127.0.0.1
DB_NAME=opencontracts
SERVER_PORT=3000
[email protected]
MAIL_PASSWORD=oc-platform
Seed the database with superadmin
node seeds/user.js
In order to seed the database with contracts data from 2010 until 2018, there is a need to process the data from CSV to JSON and import into DB.
Clone the processor app:
git clone https://github.com/opendatakosovo/prishtina-contracts-importer.git
Install the dependencies:
bash installer.sh
Seed the database with old contracts data 2010 - 2016:
bash run-old.sh
Seed the database with new contracts data 2017 - :
bash run.sh
Run the back-end side
node app.js
Change the directory:
cd client
Install dependencies:
npm install
Run the front-end app:
ng serve
Note: The instructions to deploy the app below are written in order to work dedicated on Ubuntu Server 16.04 Server.
- Install with the apt packaging system
sudo apt-get update
sudo apt-get install nginx
- Adjust the firewall It is recommended that you enable the most restrictive profile that will still allow the traffic you've configured. We will only need to allow traffic on port 80.
sudo ufw allow 'Nginx HTTP'
You can verify the change by typing
sudo ufw status
- Check your web server At the end of the installation process Ubuntu starts Nginx. The web server should already be up and running. We can check with the systemd init system to make sure the service is running by typing:
systemctl status nginx
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
To compile and install native addons from npm you may also need to install build tools:
sudo apt-get install -y build-essential
- Import the public key used by the package management sytem:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
- Create a list file for MongoDB Ubuntu 16.04:
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
- Reload local package database
sudo apt-get update
- Install the MongoDB packages
sudo apt-get install -y mongodb-org
- Enable service to start on startup
sudo service mongod start
sudo apt-get install git
sudo npm install -g @angular/cli@latest
sudo apt-get install python-pip python-dev build-essential
sudo pip install --upgrade pip
sudo pip install --upgrade virtualenv
Now install PM2, which is a process manager for Node.js applications. PM2 provides an easy way to manage and daemonize applications (run them in the background as a service).
sudo npm install -g pm2
The startup subcommand generates and configures a startup script to launch PM2 and its managed processes on server boots:
pm2 startup systemd
Change directory to /var/www/
cd /var/www
Clone the project with git:
git clone https://github.com/opendatakosovo/open-contracts-app.git
Change directory in project directory
cd open-contracts-app
Change directory
cd open-contracts-app
Install back-end dependencies
npm install
Open mongo shell
mongo
Create user in mongodb
use opencontracts
db.createUser({
user: "username",
pwd: "password",
roles: [{
role: "readWrite",
db:"opencontracts"
}]
});
Create a copy of .env-template file with name .env
cp .env-template .env
Set your values inside the .env file:
DB_HOST=127.0.0.1
DB_NAME=opencontracts
SERVER_PORT=3000
[email protected]
MAIL_PASSWORD=oc-platform
Seed the database with superadmin
node seeds/user.js
In order to seed the database with contracts data from 2010 until 2018, there is a need to process the data from CSV to JSON and import into DB.
Clone the processor app:
git clone https://github.com/opendatakosovo/prishtina-contracts-importer.git
Install the dependencies:
bash installer.sh
Seed the database with old contracts data 2010 - 2016:
bash run-old.sh
Seed the database with new contracts data 2017 - :
bash run.sh
Change the directory:
cd client
Install dependencies:
sudo npm install
Run the front-end app:
ng build --prod --extract-css=false
Go back in project root folder
cd ..
Run the project with pm2
pm2 start app.js
Open the nginx default config file for editing:
sudo nano /etc/nginx/sites-available/default
Within the server block you should have an existing location / block. Replace the contents of that block with the following configuration. If your application is set to listen on a different port, update the highlighted portion to the correct port number.
. . .
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
This configures the server to respond to requests at its root. Assuming our server is available at example.com, accessing https://example.com/ (or server IP) via a web browser would send the request to app.js, listening on port 3000 at localhost.
Once you are done adding the location blocks for your applications, save and exit.
Configure the file upload limit
#Edit this file:
sudo nano /etc/nginx/nginx.conf
#Add this line inside the http block:
client_max_body_size 100M;
#Then restart Nginx
sudo service nginx restart
Make sure you didn't introduce any syntax errors by typing:
sudo nginx -t
Next, restart Nginx:
sudo systemctl restart nginx
- Arianit Hetemi - Lead Software Developer
- Dorron Zherka - Software Developer
- Kosovare Sahatqija - Quality Assurance
- Leutrim Kosumi - Software Developer
- Florina Ahmeti - Software Developer