Skip to content

jcjurado3/civic_voice_plus_be

Repository files navigation

Logo

Contributors Forks Stargazers Issues MIT License


main page

CivicVoice+

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
  1. About The Project
  2. Getting Started
  3. Testing
  4. DB Design
  5. Endpoints
  6. Technical Solutions
  7. Roadmap
  8. License
  9. Project Contributor Contact Info
  10. Acknowledgments

About The Project

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:

  • Front End: Github
  • Back End: Github

(back to top)

Built With

  • Ruby
  • Rails
  • Tailwind
  • Postgres
  • Render

CivicVoicePlus uses these integrations:

(back to top)

Getting Started

To demo CivicVoicePlus on your local machine, follow these steps:

Back End Repository

  1. Get a free LegiScan API key here
  2. Get a free OpenStates API key here
  3. Clone this repo [email protected]:jcjurado3/civic_voice_plus_be.git
  4. Navigate to the local repository: cd civic_voice_plus_be
  5. Run: bundle install
  6. Run: rails db:{create,migrate}
  7. Run: bundle exec figaro install
  8. Add LEGISCAN_KEY and STATES_KEY to config/application.yml file
  9. Run: rails s to start Rails server
  10. Visit: http://localhost:3000/

Front End Repository

  1. Clone the front end here
  2. Follow instuctions in the front end repo README

Prerequisites

  • ruby 3.2.2
  • Rails Version 7.0.6

(back to top)

Testing

bundle exec rspec will run the entire test suite. All tests passing at time of writing.

(back to top)

DB Design

database design

(back to top)

Endpoints

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
    }
  }
}

(back to top)

Technical Solutions:

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.

Caching

  • 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.

(back to top)

Roadmap

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

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Project Contributor Contact Info

  • Ashley Plasket: Linkedin Github
  • Jeff Redish: Linkedin Github
  • Jimmy Jurado Linkedin Github
  • Julian Beldotti Linkedin Github

(back to top)

Acknowledgments

(back to top)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •