Welcome to the back end repository for CivicVoicePlus! CivicVoicePlus is a web application built for the Turing School of Software and Design's Mod 3 Consultancy project. Read more about project requirements: https://backend.turing.edu/module3/projects/consultancy/
Table of Contents
CivicVoicePlus ("CV+") is a civic data tool which aims to educate and inform users with relevant legislative information, empowering them to actively participate in civic matters and hold elected officials accountable for their actions. Users can select bill categories for their dashboard feed, search for and track the progress of specific bills, and easily access simplified bill summaries, status, and congressperson information.
The back end application is an API built with the Rails framework. It exposes 12 RESTful endpoints and is responsible for receiving JSON requests, querying the internal database, consuming external APIs, and formatting JSON responses to send data to the front end application.
Our Production Site is available here Or you can watch a Video Walkthrough here:
CVP.Demo.mp4
Github repositories:
CivicVoicePlus uses these integrations:
To demo CivicVoicePlus on your local machine, follow these steps:
- Get a free LegiScan API key here
- Get a free OpenStates API key here
- Clone this repo
git@github.com:jcjurado3/civic_voice_plus_be.git
- Navigate to the local repository:
cd civic_voice_plus_be
- Run:
bundle install
- Run:
rails db:{create,migrate}
- Run:
bundle exec figaro install
- Add
LEGISCAN_KEY
andSTATES_KEY
toconfig/application.yml
file - Run:
rails s
to start Rails server - Visit: http://localhost:3000/
- Clone the front end here
- Follow instuctions in the front end repo
README
- ruby 3.2.2
- Rails Version 7.0.6
bundle exec rspec
will run the entire test suite. All tests passing at time of writing.
GET /api/v1/bills?state=''&query=''
{
"data": [
{
"id": "0",
"type": "bill",
"attributes": {
"state": "FL",
"bill_number": "H1234",
"bill_id": 1234567,
"text_url": "https://legiscan.com/FL/text/H1234/2023",
"last_action_date": "2023-07-07",
"last_action": "Chapter No. 2023-123",
"title": "HealthCare District Chapter, Healthcare",
"status": null,
"description": null,
"sponsors": null,
"texts": null
}
}, ...]}
GET /api/v1/bills/id
{
"data": {
"id": "1722281",
"type": "bill",
"attributes": {
"state": "FL",
"bill_number": "H1234",
"bill_id": 1234567,
"text_url": null,
"last_action_date": null,
"last_action": null,
"title": "HealthCare District Chapter",
"status": 4,
"description": "simple description of bill.",
"sponsors": [
{
"people_id": 2345,
"name": "Taylor Doe",
"first_name": "Taylor",
"last_name": "Doe",
"ballotpedia": "Taylor_Doe"
}, ...],
"texts": [
{
"doc_id": 3456789,
"url": "https://legiscan.com/FL/text/H1234/id/3456789"
}, ...]
}
}
}
GET /api/v1/user_bills?user_id=''
{
"data": [{
"id": "1722281",
"type": "bill",
"attributes": {
"state": "FL",
"bill_number": "H1234",
"bill_id": 1234567,
"text_url": null,
"last_action_date": null,
"last_action": null,
"title": "HealthCare District Chapter",
"status": 4,
"description": "simple description of bill.",
"sponsors": [
{
"people_id": 2345,
"name": "Taylor Doe",
"first_name": "Taylor",
"last_name": "Doe",
"ballotpedia": "Taylor_Doe"
}, ...],
"texts": [
{
"doc_id": 3456789,
"url": "https://legiscan.com/FL/text/H1234/id/3456789"
}, ...]
}
}]
}
POST/api/v1/user_bills?user_id=''&bill_id=''
{
data:{
id: "25",
type: "user_bill",
attributes: {
user_id: 1,
bill_id: 25
}
}
}
DELETE/api/v1/user_bills?user_id=''&bill_id=''
{ }
GET /api/v1/user_categories?user_id=''
{
data: [
{
id: "1",
type: "category",
attributes: {
:name=>"artificial intelligence"
}
},
{
id: "2",
type: "category",
attributes: {
:name=>"climate"
}
}
]
}
POST /api/v1/user_categories?user_id=''&category_id=''
{
data: {
id: "5",
type: "user_category",
attributes: {
user_id: 1,
category_id: 5
}
}
}
DELETE /api/v1/user_categories?user_id=''&category_id=''
{ }
GET/api/v1/categories
{
data: [{
id: "1",
type: "category",
attributes: {
name: "climate"
}
},
...
]
}
GET/api/v1/states
{
data: [{
id: "1",
type: "state",
attributes: {
state_abbr: "ND",
state_name: "North Dakota"
}
},
...]
}
GET/api/v1/user_states?user_id=''
{
data: [{
id: "39",
type: "state",
attributes: {
state_abbr: "ND",
state_name: "North Dakota"
}
},
...]
}
POST/api/v1/user_states?user_id=''state_id=''
{
data: {
id: "1",
type: "user_state",
attributes: {
user_id: 1,
state_id: 39
}
}
}
As part of the Consultancy project requirements, the CivicVoicePlus team challenged ourselves to stretch technologies during the 11-day design and development process. We selected the following based on the challenges we anticipated facing while building out our MVP, and adjusted our choices to reflect our individual and team learning goals as well as blockers that came up during the course of working on the project.
- Challenge: Two of the API endpoints that expose data for the front end of our application rely on both database queries and external API calls, which significantly slowed down the processing time and resulted in a less-than-ideal experience for our users. Additionally, we were hitting rate limits on our API endpoints.
- Solution: We decided cache our bill endpoints and save bills to our database since this is frequent endpoints and there are so many bills to render on both a users dashboard as well as bills show pages. We used the Rails.cache syntax and some helpful documentation to cache these requests on the back end. We decided not to implement caching for other API calls that would change frequently, such as the request to get all saved bills for a specific user.
Additional features, functionality, and potential refactors:
- Consume additional APIs to allow users to find nearest polling/voting stations and dates
- Allow users to create custom search parameters to render on their user digest
- Create functionality to allow users to opt into email or push notification on status updates of their saved bills
- Consume OpenAI API and add functionality to a bills show page to read and summarize the entire bill's text document
- Additional back end database validations
Distributed under the MIT License. See LICENSE.txt
for more information.