GithubHelp home page GithubHelp logo

amsterdam / amsterdam-app-construction-work Goto Github PK

View Code? Open in Web Editor NEW
0.0 4.0 1.0 14.02 MB

An API server for delivering content to the amsterdam-app-frontend. It's written in Python/Django

License: Mozilla Public License 2.0

Dockerfile 0.13% Python 43.56% Shell 0.27% JavaScript 4.33% CSS 48.17% HTML 0.32% Vue 3.11% TypeScript 0.10%

amsterdam-app-construction-work's Introduction

Build Status Build Status

Technical Architecture

Application overview

The Construction-Work application boasts a robust technical architecture to efficiently manage and disseminate information about construction projects in Amsterdam. Key technologies used include Python and the Django framework for the backend, and Vue.js for the frontend. Let's delve deeper into the various components:

Backend frameworks

The backend of the Construction-Work application is built using Python, a versatile programming language, and Django, a powerful web framework. Django provides a standardized structure for developing web applications, including built-in security layers, ORM (Object-Relational Mapping), and an easy way to define API endpoints. This forms the foundation for data processing and application logic.

Database

The application employs a relational database, such as PostgreSQL, to store data related to construction projects. Django's ORM allows developers to interact efficiently with the database, simplifying project data management.

APIs

The backend offers a set of RESTful APIs that supply the Amsterdam-App with relevant information. These APIs serve as the bridge between the database and the application's frontend. They enable the frontend to fetch data, update project-information, and post messages.

Frontend (Vue.js)

The Construction-Work application's frontend is developed using Vue.js, a progressive JavaScript framework. Vue.js enables the creation of dynamic and interactive user interfaces. The frontend is responsible for displaying project-information, managing user-profiles, and presenting notifications to users.

MBS

The environment manager module (mbs) is a crucial part of the application. Here, authorized users such as environment managers can input and update specific information about construction projects. This includes posting messages, tracking project status changes, and sharing updates with the community.

Notifications

The push notification system is integrated into the Amsterdam-App and utilizes mobile platform notification services (e.g., Firebase Cloud Messaging for Android). Users can opt to receive push notifications when there are updates for the projects they are following.

Moderator interface

The moderation interface is developed using Vue.js and provides administrators with the ability to view, approve, or moderate messages posted by environment managers. This ensures that the shared information remains accurate and relevant to the Amsterdam community.

Data Flow

The data flow within the Construction-Work application starts with IPROX, Amsterdam's content management system, where data about construction projects is collected and stored. This data is retrieved via APIs and loaded into the application's backend. Environment managers can post messages and update project information through the environment manager module, which is then displayed in the Amsterdam-App. Users can choose to receive push notifications on their mobile devices when there are updates.

Summary

In summary, the Construction-Work application is an advanced technological system that streamlines communication and information sharing regarding construction projects in Amsterdam. It leverages modern web technologies and frameworks to provide a seamless experience for both project managers and the Amsterdam community. The Vue.js interface, in this case, is specifically designed for creating environment manager accounts and moderating their messages.

Pre-requisites

Make sure your docker environment is up and running and you have a recent version of docker-compose installed.

API documentation

If the backend is running, you can visit the online api documentation

    http://localhost:8000/api/v1/apidocs

The definition for the api documentation are in the file 'views_swagger_auto_schema.py'

Developer documentation:

README-development.md Here you can find among other settings e.g. how to enable debug mode.

Setup your database credentials

    run: chmod +x set_env.py && ./set_env.py

Example output:

    Please enter your POSTGRES database (default: amsterdam_app_backend): 
    Please enter your POSTGRES username (default: backend): 
    Please enter your POSTGRES password (or use: 94ADsLnM): 
    Save values to environment? (Y/N/A(bort)): N
    Please enter your POSTGRES database (default: amsterdam_app_backend): 
    Please enter your POSTGRES username (default: backend): 
    Please enter your POSTGRES password (or use: flr5fbjH): MyS3cr3t                
    Save values to environment? (Y/N/A(bort)): y

Your environment will look like:

    POSTGRES_PASSWORD=MyS3cr3t
    POSTGRES_USER=backend
    POSTGRES_DB=amsterdam_app_backend

Build and start the Amsterdam-App-Backend

    sudo docker-compose -f docker-compose.yml --env-file ./env up --build --remove-orphans

Note:

The docker must run sudo because the database files are unreadable for normal users. This will prevent the build step from succeeding and hence the docker containers won't start.

Example output:

    sudo docker-compose -f docker-compose.yml --env-file ./env up --build --remove-orphans
    Docker Compose is now in the Docker CLI, try `docker compose up`
    
    Building api-server
    [+] Building 1.1s (15/15) FINISHED                                                                                       
     => [internal] load build definition from Dockerfile                                                                0.0s
     => => transferring dockerfile: 541B                                                                                0.0s
     => [internal] load .dockerignore                                                                                   0.0s
     => => transferring context: 2B                                                                                     0.0s
     => [internal] load metadata for docker.io/library/python:3                                                         0.7s
     => [internal] load build context                                                                                   0.0s
     => => transferring context: 40.85kB                                                                                0.0s
     => [ 1/10] FROM docker.io/library/python:3@sha256:28ba68f41f73354b3cfca4af3e4d55cf553761ae25797c41b303f8fa219e7ad  0.0s
     => => resolve docker.io/library/python:3@sha256:28ba68f41f73354b3cfca4af3e4d55cf553761ae25797c41b303f8fa219e7ade   0.0s
     => CACHED [ 2/10] RUN apt-get update   && apt-get -y install --no-install-recommends cron netcat  && rm -rf /var/  0.0s
     => CACHED [ 3/10] WORKDIR /code                                                                                    0.0s
     => CACHED [ 4/10] COPY requirements.txt /code/                                                                     0.0s
     => CACHED [ 5/10] RUN pip install -r requirements.txt                                                              0.0s
     => [ 6/10] COPY init.sh /code/                                                                                     0.0s
     => [ 7/10] RUN chmod +x /code/init.sh                                                                              0.2s
     => [ 8/10] COPY manage.py /code/                                                                                   0.0s
     => [ 9/10] COPY amsterdam_app_backend /code                                                                        0.0s
     => [10/10] COPY amsterdam_app_api /code                                                                            0.0s
     => exporting to image                                                                                              0.0s
     => => exporting layers                                                                                             0.0s
     => => writing image sha256:bcbb3008b21155c7600f2ced3d345494f43532131ffcd351925eb13a9fea2dda                        0.0s
     => => naming to docker.io/library/amsterdam-app-backend_api-server                                                 0.0s
    
    Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
    Successfully built bcbb3008b21155c7600f2ced3d345494f43532131ffcd351925eb13a9fea2dda
    Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
    Recreating amsterdam-app-backend_db_1 ... done
    Recreating amsterdam-app-backend_api-server_1 ... done
    Attaching to amsterdam-app-backend_db_1, amsterdam-app-backend_api-server_1
    db_1          | The files belonging to this database system will be owned by user "postgres".
    db_1          | This user must also own the server process.
    db_1          | 
    db_1          | The database cluster will be initialized with locale "en_US.utf8".
    db_1          | The default database encoding has accordingly been set to "UTF8".
    db_1          | The default text search configuration will be set to "english".
    db_1          | 
    db_1          | Data page checksums are disabled.
    db_1          | 
    db_1          | fixing permissions on existing directory /var/lib/postgresql/data ... ok
    db_1          | creating subdirectories ... ok
    db_1          | selecting dynamic shared memory implementation ... posix
    db_1          | selecting default max_connections ... 100
    db_1          | selecting default shared_buffers ... 128MB
    db_1          | selecting default time zone ... Etc/UTC
    db_1          | creating configuration files ... ok
    db_1          | running bootstrap script ... ok
    db_1          | performing post-bootstrap initialization ... ok
    db_1          | syncing data to disk ... initdb: warning: enabling "trust" authentication for local connections
    db_1          | You can change this by editing pg_hba.conf or using the option -A, or
    db_1          | --auth-local and --auth-host, the next time you run initdb.
    db_1          | ok
    db_1          | 
    db_1          | 
    db_1          | Success. You can now start the database server using:
    db_1          | 
    db_1          |     pg_ctl -D /var/lib/postgresql/data -l logfile start
    db_1          | 
    db_1          | waiting for server to start....2021-08-17 09:02:19.479 UTC [48] LOG:  starting PostgreSQL 13.4 (Debian 13.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
    db_1          | 2021-08-17 09:02:19.480 UTC [48] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
    db_1          | 2021-08-17 09:02:19.491 UTC [49] LOG:  database system was shut down at 2021-08-17 09:02:18 UTC
    db_1          | 2021-08-17 09:02:19.504 UTC [48] LOG:  database system is ready to accept connections
    db_1          |  done
    db_1          | server started
    db_1          | CREATE DATABASE
    db_1          | 
    db_1          | 
    db_1          | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
    db_1          | 
    db_1          | 2021-08-17 09:02:20.890 UTC [48] LOG:  received fast shutdown request
    db_1          | waiting for server to shut down...2021-08-17 09:02:20.891 UTC [48] LOG:  aborting any active transactions
    db_1          | .2021-08-17 09:02:20.892 UTC [48] LOG:  background worker "logical replication launcher" (PID 55) exited with exit code 1
    db_1          | 2021-08-17 09:02:20.893 UTC [50] LOG:  shutting down
    db_1          | 2021-08-17 09:02:20.918 UTC [48] LOG:  database system is shut down
    db_1          |  done
    db_1          | server stopped
    db_1          | 
    db_1          | PostgreSQL init process complete; ready for start up.
    db_1          | 
    db_1          | 2021-08-17 09:02:21.024 UTC [1] LOG:  starting PostgreSQL 13.4 (Debian 13.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
    db_1          | 2021-08-17 09:02:21.024 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
    db_1          | 2021-08-17 09:02:21.024 UTC [1] LOG:  listening on IPv6 address "::", port 5432
    db_1          | 2021-08-17 09:02:21.027 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
    db_1          | 2021-08-17 09:02:21.048 UTC [76] LOG:  database system was shut down at 2021-08-17 09:02:20 UTC
    db_1          | 2021-08-17 09:02:21.066 UTC [1] LOG:  database system is ready to accept connections
    checking for database -> db alivebase
    api-server_1  | 
    api-server_1  | Initializing Amsterdam-App-Backend
    api-server_1  | 
    api-server_1  | Running DB migrations scripts ... Migrations for 'amsterdam_app_api':
    api-server_1  |   amsterdam_app_api/migrations/0001_initial.py
    api-server_1  |     - Create model Image
    api-server_1  |     - Create model ProjectDetails
    api-server_1  |     - Create model Projects
    api-server_1  | Operations to perform:
    api-server_1  |   Apply all migrations: admin, amsterdam_app_api, auth, contenttypes, sessions
    api-server_1  | Running migrations:
    api-server_1  |   Applying contenttypes.0001_initial... OK
    api-server_1  |   Applying auth.0001_initial... OK
    api-server_1  |   Applying admin.0001_initial... OK
    api-server_1  |   Applying admin.0002_logentry_remove_auto_add... OK
    api-server_1  |   Applying admin.0003_logentry_add_action_flag_choices... OK
    api-server_1  |   Applying amsterdam_app_api.0001_initial... OK
    api-server_1  |   Applying contenttypes.0002_remove_content_type_name... OK
    api-server_1  |   Applying auth.0002_alter_permission_name_max_length... OK
    api-server_1  |   Applying auth.0003_alter_user_email_max_length... OK
    api-server_1  |   Applying auth.0004_alter_user_username_opts... OK
    api-server_1  |   Applying auth.0005_alter_user_last_login_null... OK
    api-server_1  |   Applying auth.0006_require_contenttypes_0002... OK
    api-server_1  |   Applying auth.0007_alter_validators_add_error_messages... OK
    api-server_1  |   Applying auth.0008_alter_user_username_max_length... OK
    api-server_1  |   Applying auth.0009_alter_user_last_name_max_length... OK
    api-server_1  |   Applying auth.0010_alter_group_name_max_length... OK
    api-server_1  |   Applying auth.0011_update_proxy_permissions... OK
    api-server_1  |   Applying auth.0012_alter_user_first_name_max_length... OK
    api-server_1  |   Applying sessions.0001_initial... OK
    api-server_1  | Done.
    api-server_1  | 
    api-server_1  | Removing old cronjobs ... no crontab for root
    api-server_1  | Done.
    api-server_1  | 
    api-server_1  | Setting new cronjobs ...   adding cronjob: (96b481d2adb3bab4fa3be5a2ddc51875) -> ('0 */4 * * *', 'amsterdam_app_backend.cron.run')
    api-server_1  | Done.
    api-server_1  | 
    api-server_1  | Starting Django API server
    api-server_1  | 
    api-server_1  | Watching for file changes with StatReloader
    api-server_1  | Performing system checks...
    api-server_1  | 
    api-server_1  | System check identified no issues (0 silenced).
    api-server_1  | August 17, 2021 - 09:02:25
    api-server_1  | Django version 3.2.6, using settings 'amsterdam_app_backend.settings'
    api-server_1  | Starting development server at http://0.0.0.0:8000/
    api-server_1  | Quit the server with CONTROL-C.
    api-server_1  | [17/Aug/2021 09:14:37] "GET /api/v1/projects/ingest?project-type=kade HTTP/1.1" 200 83
    api-server_1  | Not Found: /favicon.ico
    api-server_1  | [17/Aug/2021 09:14:37] "GET /favicon.ico HTTP/1.1" 404 2230
    api-server_1  | [17/Aug/2021 09:14:54] "GET /api/v1/projects/ingest?project-type=brug HTTP/1.1" 200 83
    api-server_1  | [17/Aug/2021 09:14:58] "GET /api/v1/projects HTTP/1.1" 200 116225
    api-server_1  | [17/Aug/2021 09:15:26] "GET /api/v1/image?id=472ead77645cf72865013a314cb96aa4 HTTP/1.1" 200 62186

Database

The Amsterdam-App-Backend will make use of the postgres database server. Use setenv.sh script for setting your credentials. Database files will be stored in '/data/db' folder in your project root.

Get initial data

Make sure your application is running on port 8000 on your localhost. Now open the url below in your browser of choice to fetch initial data or update existing data. This end-point will disappear in the near future in favour of a cron-job.

    http://localhost:8000/api/v1/projects/ingest
    Valid (mandatory) query parameter: project-type=['brug', 'kade']

API documentation

There is online API documentation available at:

    http://localhost:8000/api/v1/apidocs

There is offline documentation available at:

    /amsterdam_app_api/swagger_views_*.py

Garbage collector

When a content item was seen before but not in the last Iprox scrape, the content item will be marked inactive. If the content item has been marked inactive for over 1 week, the content item and its siblings will be removed.

Siblings are: Warning-messages, News items, Project, Project details, subscriptions for phones, authorizations for project-managers and so forth.

amsterdam-app-construction-work's People

Contributors

frankfe-amsterdam avatar jwesterbeek70 avatar rikschefferamsterdam avatar rikschefferoberon avatar sguldemond avatar spreadtriad avatar yachtcloud-robert avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

masikh

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.