# Kanal Akses Pendaftaran KP Elektronik _(kape)_ > Internship matchmaking platform for students and companies. ## Table of Contents - [Install](#install) - [Running Development Mode (Classic)](#running-development-mode-classic) - [Running Development Mode (Containerised)](#running-development-mode-containerised) - [References](#references) - [License](#license) ## Install This project uses Python 2 and Node.js v4 for building the backend and frontend, respectively. The backend uses Django Framework and PostgreSQL database, while the frontend is developed using React. You need to install the required dependencies prior to building and contributing to the project. - [Node.js v4.9.1](https://nodejs.org/en/download/releases/) and `npm` package manager. > Note: We recommend `nvm` (Node Version Manager) for installing Node.js. You > can find `nvm` for your OS at the following links: > - [nvm for macOS or GNU/Linux-based OS](https://github.com/creationix/nvm) > - [nvm for Windows](https://github.com/coreybutler/nvm-windows) > > Once `nvm` has been installed, install Node.js and activate it by executing > `nvm install 4.9.1` followed by `nvm activate 4.9.1`. - [Python 2.7.16](https://www.python.org/downloads/release/) and `pip` package manager. > Note: We recommend using _virtual environment_ to isolate project-specific > Python packages from system-level packages. You can install and use > [`virtualenv`](https://virtualenv.pypa.io/en/stable/) package to create the > virtual environment for this project. - [PostgreSQL 9.6](https://www.postgresql.org/download/) and any database client that can interface with PostgreSQL, e.g. `psql`, pgAdmin. > Note: We recommend running the database as container or virtual machine to > avoid cluttering your local development environment. Please consult the > documentation for your container engine (e.g. Docker) or virtualization > platform (e.g. VirtualBox or Hyper-V) on how to provision PostgreSQL > database. If you had to use locally-installed database, make sure your > own data will not interleave with the data generated by this project. Verify that Node.js and Python 2 have been successfully installed. Make sure the interpreter for both platforms can be invoked from the shell. For example, in `bash` shell (macOS or GNU/Linux-based OS): ```bash # Assuming there is a Python virtual environment directory named `env` in # current path $ source env/bin/activate $ python --version # or: python2 --version Python 2.7.16 $ node --version v4.9.1 ``` Now install the packages required by Node.js and Python 2: ```bash npm install pip install -r requirements.txt ``` If you are cloning the project for the first time into your local development environment, you need to create a new database user named `kape` and create a new database with the same name for this project. Do not forget to set the ownership of the new database to `kape` user. Once you have finished setting up the database, perform database migration and seeding: ```bash python manage.py migrate python manage.py loaddata seeder.json ``` > Note: Can't connect to the database? Adjust the database connection settings > at [`settings.py`](kape/settings.py). Finally, verify that the test suites pass: ```bash # Run the test suite for backend python manage.py test ``` To run the test suite for frontend, you need to build the frontend first before running the test suite: ```bash npm run build-production npm run karma ``` ## Running Development Mode (Classic) To run the API (backend) server: ```bash python manage.py runserver ``` To serve the frontend: ```bash npm run webpack # If you don't want live update, run: npm run build # If you want the uglified, zipped, production-ready version, run: npm run build-production ``` You can see the app running by going to `localhost:8080` via your favourite Web browser. ## Running Development Mode (Containerised) If you have installed Docker and Docker Compose, you can build the app into a container image and run it with container-based database and Web server: ```bash docker-compose up --build --detach docker-compose run --rm app python manage.py migrate docker-compose run --rm app python manage.py loaddata seeder.json ``` > Explanation: > 1. Rebuild the application (the frontend + backend), then start it along with > the database (`postgres`) and Web server (`nginx`). > 1. Perform database migration > 1. Perform database seeding Before you can see the app, you need to know the port in the host that mapped to the port in the Web server container: ```bash # The following is just an example. The output may vary in your environment. $ docker-compose ps Name Command State Ports --------------------------------------------------------------------------- kape_app_1 gunicorn --bind 0.0.0.0:80 ... Up 8001/tcp kape_db_1 docker-entrypoint.sh postgres Up 5432/tcp kape_web_1 nginx -g daemon off; Up 0.0.0.0:32770->80/tcp ``` In the above example, port 32770 is mapped to port 80 in the Web server container. Thus, you can see the app via Web browser by opening `http://localhost:32770`. > Note: Running the app and its dependencies as containers are convenient, but > you will not be able to see any changes to the codebase in real-time. If > you want to see changes in the codebase reflected in real-time, follow the > classical approach for running the development mode. ## References - [The original README file](README.old.md). - [The original (_upstream_) GitLab project repository](https://gitlab.com/PPL2017csui/PPLA1). ## License Copyright (c) 2017 PPLA1 Team & Faculty of Computer Science Universitas Indonesia. This project is licensed under [ISC](LICENSE) license.