The initial version was developed by contributors at IBM in the summer of 2020, namely: Aakansha Agrawal, Khadija Al-Selini, Parisa Babaali, Boz Bosma, Kimberly Cassidy, Stephanie Daher, Michelle Esselen, Peter Ihlenfeldt, Abiola Jones, Rahul Kalluri, Joe Konathapally, Frank Madden, Henry Nash, Sharon Osahon, Colby Stone, Mark Sturdevant, Tanushree Paul, Bimsara Pilapitiya, Ya Jiao Zheng.
- Truth-Loop
Concerned and impacted citizens don't have a straightforward way of knowing what or how policies, regulations, and legislation (throughout this document referred as either Legislative Artifacts or PR&L) impact them or how they can share their approval, concerns, and/or questions with lawmakers.
What is missing to help communities contribute their feedback related to PR&L, and what this technology was intending to provide, is a means for people to:
- readily understand the PR&L language and intent without being a legal expert
- sort or filter the PR&L efficiently
- digest an understandable summary of PR&L
- explore related or supporting information, advocacy groups, and other PR&L
- make a determination of whether the PR&L will impact them
- engage in the process of providing feedback about PR&L
- communicate the potential effects of these PR&L on their life, family, or community to the author or sponsor of the legislation
- share their stories and experiences with fellow residents and policy makers
- see what other people in the community are saying
- get an idea of the general sentiments people have expressed about the PR&L
- engender dialogue between residents, PR&L authors, and sponsors
The driving idea behind the software is to provide a platform that is capable of storing curated PR&L information, as determined by the community (however large or small) it serves. The platform provides a mobile-friendly way for users to examine PR&L, helping increase their legal awareness and allowing them to communicate their reactions and thoughts with video testimonials. These testimonials are then shared with the community and those responsible for the creation of the PR&L.
This solution combines a media server (currently Watson Media) and distributed database service to hold the curated legislative artifacts and the related metadata.
- The user launches the web app (on either a laptop, desktop, or mobile device) and can view the range of curated legislative artifacts (1). The React app retrieves these by sending a REST request to the API server, which extracts them (3) from the SQL database.
- The user can post their own (video) story to support or challenge the legislated artifacts to the API server, which directs it to the Watson Media services (2). The API server also stores a reference to the video location in the respective legislative artifact in the SQL database (3).
- The user can view other peoples' video stories which are retrieved by sending a REST request to the API server, which, after looking up the ID of the video in the SQL database (3), extracts them from Watson Media services (2).
There is an administrative API interface that allows the site owners to curate the PR&L information, with the following attributes:
- a simple, intelligible summary that makes it easy to understand its potential impact
- categories it pertains to (law enforcement, healthcare, zoning)
- geospatial areas of pertinence (postal codes, cities, counties, and so on)
- the type of the artifact (bill, law, policy, regulation, and so on)
- related PR&L in the system
- legislator, author, and sponsor of the PR&L
- related advocacy groups or digital social communities
- related articles or supporting documentation
- a link to the full text of the PR&L
- IBM Cloud Documentation Home
- Kubernetes in IBM Cloud
- PostgreSQL
- OpenShift
- Node.js
- ExpressJS
- React.js
- Redux
- For the redux we use the ducks pattern as seen here
- TL;DR? That means actionTypes, actions, and reducers are all in a file called
<module-name>.duck.js
- Associated tests should be in
<module-name>.duck.test.js
- Complex selectors ought to be in the .duck file as well
- Consider
useSelector
for simple selectors
- Register for an IBM Cloud account.
- Install and configure IBM Cloud CLI.
- Install React dependencies
- Clone the repository.
- Provision a PostgreSQL instance on the IBM Cloud.
- If you want to use the video services, provision an instance of Watson Media.
- Configuring and run the server.
- Configuring and run the client application.
The server requires an RDMS server and currently only supports PostgreSQL. You can deploy this in the IBM Cloud by logging into the IBM Cloud and provisioning a Postgres instance. Note that this does require a paid plan, however if you have just signed up for a new IBM Cloud account, you will have received cloud credits, which would cover this for a significant time.
- Choose your Databases for Postgres plan. You should choose an appropriate region, give the service a name. You can leave the other settings with their defaults. Click the blue Create button when ready.
- Once your Postgres instance has been created, you need to create a service credential that the API Server can use to communicate with it. By selecting your running Postgres instance, you can choose Service credentials from the left menu. Create a new service credential and give it a name (it doesn't matter what you call it).
- Once created, you can display the credentials by selecting view service credentials, and then copying the credential, so you are ready to paste parts of it into the environment file of the API server in Step 3.
Alternatively, you could deploy your own PostgreSQL instance locally, in a remote VM, or container. In this case, ensure you obtain the equivalent credentials to those described above for Step 3.
Log in to IBM Cloud and provision a Watson Media instance.
- Provision an instance of Watson Media IBM Watson Media. You can use the 30 day free-trial to start.
- Once your Watson Media instance has launched, go to the API/SDK access item, under the Integration & Apps item, in the left menu.
- Create a new credential. You will need to enter an Application Name (you can choose anything) and a Redirect URL. This URL needs to be the prefix of the URL you will run the server on, e.g. http://localhost. Make note of the
client id
andclient secret
, since you will need these in Step 3. - Generate a device username and password to be used by your server, by going to the Device passwords in the Integration & Apps menu. Give your device any name you choose, and then click Create password. Make a note of the username and password that are generated, since you will need these in Step 3.
To set up and launch the server application:
-
Go to the
server
directory of the cloned repo. -
Copy the
.env.example
file, and create a new file named.env
. -
If your PostgreSQL server uses SSL (like the IBM Cloud version), then create a file named
cert.pem
to hold the SSL certificate. For the IBM Cloud version of PostgreSQL, it is shown in thecertificate: certificate_base64
attribute of the service credential you obtained in Step 1. Copy the raw contents of this attribute into the file you have created. -
Update the newly created
.env
file and update theDB_HOST
,DB_USERNAME
,DB_PASSWORD
,DB_PORT
andDB_DATABASE_NAME
with the values from the credentials you obtained in Step 1. If you created a certificate file in the previous action, then also update theDB_CERTFILE
with the location of this file (relative to theserver
directory). For example,DB_CERTFILE=./cert.pem
. -
Also update the
CMS_USERNAME
,CMS_PASSWORD
,CLIENT_ID
andCLIENT_SECRET
with the values from creating your instance of Watson Media, from Step 2. -
Prepare to initialize the database with the correct tables. Scripts are provided that do this using the
psql
CLI, which is recommended that you install:-
macOS:
brew install libpq
- You may also like to link the
psql
command to you local bin directory with brewlink --force libpq
-
Windows:
- Download PostgreSQL for Windows here.
- You will also need to add the path to your PostgreSQL bin directory to your PATH variable in order for the CLI to work.
-
-
To initialize the tables, you can use the
./psql_create_tables.sh
script -
If you would like to install sample data into the database for testing, then use the
./psql_refresh_sample_data.sh
script -
To run the server, from a terminal, in the
server
directory of the cloned repo:- Install the dependencies:
npm install
- Launch the server application locally or deploy to IBM Cloud:
- To run locally:
- Start the application:
npm start
- The server can be accessed at the address give, typically http://localhost:5000
- Start the application:
- To deploy to the IBM Cloud in Cloud Foundry:
- Edit the name value in the
manifest.yml
file to a unique application name (for example, my-legislative-server). - Log in to your IBM Cloud account using the IBM Cloud CLI:
ibmcloud login
- Target a Cloud Foundry org and space:
ibmcloud target --cf
- Push the app to IBM Cloud:
ibmcloud app push
- The server can be accessed at the routes URL displayed in the output of the push command (for example: <my-legislative-server.eu-gb.mybluemix.net>)
- Edit the name value in the
- To run locally:
- Install the dependencies:
Once the server is running, you can test it by accessing the openAPI docs interface using the /api-docs
endpoint. For example, if running locally this will be on http://localhost:5000/api-docs, which should look something like this:
To configure and run the client application:
- Go to the
client
directory of the cloned repo. - Copy the
.env.example
file to a new file named.env
- Edit the newly created
.env
file:- Update the
SERVER_URL
with the URL to the server app launched in the previous step (for example http://localhost:5000).
- Update the
- From a terminal:
- Install the dependencies:
npm install
npm run serve
- Once the development server is running, you should be able to access the client from the URL indicated (typically http://localhost:8080/)
- If you are running a mobile simulator, you can also access the same URL. For example, in the ios simulator, the screen would look something like this:
- Install the dependencies:
Running Truth Loop components as containers allows a simple and fast set-up of the application.
- Install Docker
- Install Docker Compose
- Ensure that your
docker-compose.yml
is up to date with the components you wish to run. - In a terminal, navigate to the
server
directory and rundocker-compose up -d --build
. - Check that all containers are up and running by issuing
docker ps -a
. - Access each as normal component via their
localhost
ports. - Once finished, run
docker-compose down
.
- Any non-tech resources go here (e.g. links/videos to legislation, and the problem being solved)
This solution is made available under the Apache 2 License.
The community welcomes your involvement and contributions to this project. Please read contributing for details on our code of conduct, and the process for submitting pull requests to the community.
There are a significant number of areas where the community is looking for help. Individual issues are raised in the repository, but the following class of assistance is needed:
- Media services: The current approach supports only one media service, Watson Media. Although this provides excellent capabilities, there is a desire to support a broader range of media services for testimonial videos. Various approaches have been researched, including use of a non-streaming solution using Cloud Object Storage to call stored videos to be downloaded and then played back to the user upon loading of the page. As the videos will have a restriction of 60 second time limits, optimization can be made to minimize the overhead of waiting to download the entire video before playback. This implementation is certainly feasible, however it is not scalable when taking into account users with potentially weaker network connections.
- Security: An efficient expansion to secure data storage (particularly regarding the video implementation) is required to ensure all user data is kept safe. Implementation of user accounts that safely store user data may even assist in developing a more convenient solution, however the privacy implications that come with this should also be assessed.
- Privacy considerations around videos and location information: Consideration of the metadata around user testimonials will be essential in providing a solution that focuses on privacy risks.
- Sourcing legislation information: Several data sources will be required to adapt the solution for all locales, therefore expansion of this project will be impacted massively by taking into account the structures of legislation from other countries.
- Policy upload and curation: Thought needs to be given to who would curate the policy data. Would the database population of policy data be automated to pull all newly proposed policies from government sources, requiring an interface to filter suitable policies to then be pushed into the database? Or would the curation be done manually, which allows for more control with the drawback of lower scalability?
- Moderation of uploaded videos/text: How is video or accompanying text reviewed to ensure community guidelines are being followed, and that users are not misusing the application? Applications of moderation can include profanity detection, manual moderation via user admins, or through flagging and reporting of user content. Furthermore, consideration should be made to assess whether these implementations address the spirit of the solution, e.g. how to distinguish this software from social media settings where users already share political views.
- Natural language technology: Work has already begun on refining a pipeline to extract text from video submissions to implement tone analysis, which will help to identify various characteristics and give more meaning to the video testimonials from users. Further expansion can be made to analyze profanity and inappropriate language submitted by users, to address moderation of user content.
Due to the nature of the solution, Personal Information (PI) could be prevalent within an implementation of a Truth Loop system. For implementors, there are a number of important considerations to take into account. Please refer to the Platform Privacy Statement and Application User Guide documents to help you with your implementation.