Table of Contents
Users Map App (usersmapapp) is a web dashboard to mapping registered users based on address location. This is an experimental project to testing the integration of Django & ReactJS with spatial capabilities.
This dashboard was developed by using various kinds of open-source frameworks/libraries. Django (Python) with Django Rest Framework to create API in the back-end consumed by dashboard developed by ReactJS (JavaScript) for front-end. Location of registered users displayed on dashboard map by using Leaflet JS. Database used in this system is PostgreSQL with spatial extension by using PostGIS. All of these components are delivered as containers by using Docker to simplify installation procedure and production deployment. There is also a web server image in the containers which is using NGINX.
This web application is delivered by using Docker container so it need to be installed first. Step to install Docker can be access here
- Clone usersmapapp sourcecode from repository
git clone https://github.com/faizalprbw/usersmapapp.git -b main
cd usersmapapp
- Configure .env files based on your local environment parameters
cp .env.example .env
vi .env
POSTGRES_USER=admin # change this
POSTGRES_PASSWORD=password123 # change this
POSTGRES_DB=usersmapapp_db # change this
DATABASE=postgres # change this
PG_HOST=postgres-db
PG_PORT=5432
SECRET_KEY='Django Secret Key' # change this, can be generated here https://djecrety.ir/
DEBUG=True # change this if in development mode
ALLOWED_HOSTS=localhost 127.0.0.1 usersmapapp-api [::1]
# NOTE:
# PG_HOST, PG_PORT, and ALLOWED_HOSTS have relation to docker-compose.yml,
# changing them will be impact on docker configuration
- Docker Build and Up.. Make sure Docker & Docker Compose already running on your computer / server
docker --version # 20.10.17 on my local env
docker-compose --version # v2.10.2 on my local env
docker-compose up -d --build
- Migrate default table & group into Database
## Migrate
docker-compose exec usersmapapp-api python manage.py migrate --noinput
## Add Fixtures
docker-compose exec usersmapapp-api python manage.py loaddata userprofile/fixtures/group.json
-
Open http://localhost on web browser.. We will be directed into map dashboard page
-
Create superuser account and login to web (http://localhost/admin) as superuser
## Create Superuser Account
docker-compose exec usersmapapp-api python manage.py createsuperuser
- Optionally.. do the following step to populate example users data into database..
# This example will automatically generate 100 fake users with random location coordinate
docker-compose exec usersmapapp-api python populate_datadummy.py 100
Check http://localhost on web browser after run this command, users point location will be populated on map dashboard
This django web application is tested by using pytest. However, this feature is still on development. To do testing, run following syntax on root directory (/usersmapapp)
pytest