Empower Your Vote - https://sway.vote
Sway is a platform you can use to engage in the democratic process in the 21st century. With Sway, you can directly influence your elected representatives by voting on the same legislation that they do.
Sway was created to solve several issues of democracy:
-
Years can pass between elections that decide who will represent you.
-
Keeping track of how well your representatives have represented you can be difficult.
Because of these difficulties, it can be challenging to hold elected representatives accountable for their actions.
Sway is a forever free to use and open source application. We do not have ads and we will never.
Sway relies on people like you to support this venture. To get started, please see our contributing guide.
tl;dr
- Create an issue.
- Fork this repo.
- Update code as needed.
- Open a pull request with your changes linked to the aforementioned issue.
Sway is designed to work with and be extended to multiple locations regardless of city, region or country, and anyone and everyone is free to onboard a new municipality or "locale"
into Sway.
- Baltimore City, Maryland, United States -
baltimore-maryland-united_states
- United States Congress -
congress-congress-united_states
To add a new locale, create a new Issue and label it as locale
and include the below files:
-
An SVG image avatar for the locale, usually a flag representing that municipality. See /public/images/avatars/baltimore-maryland-united_states.svg as an example. Wikipedia and Twitter are good sources to get these from.
-
A
.geojson
file named<city>-<region>-<country>.geojson
with locations of each district corresponding to the respective legislator. For example, GeoJSON data for Baltimore City can be found here - other cities may have similar sources. -
Adding new Bills, Organizations and LegislatorVotes requires administrative access to Sway. More importantly it requires a commmitment to selecting, researching and summarizing a Bill of the Week each week for your Sway locale.
-
To add and/or update Legislators in Sway, please provide a
legislators.json
file. For an example of the file structure, see the Baltimore legislators.json file.
Once the above have been assembled, we will work with you to get them into Sway!
NOTE: All the values set here are only used for development and should NOT be commited to git. Values should not include opening and closing "".
You can get the ACCOUNT_SID and AUTH_TOKEN values by clicking "Account" at the top-right and then "API keys & tokens" on the left sidebar.
TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=
TWILIO_VERIFY_SERVICE_SID=
To get a VERIFY_SERVICE_SID you must sign up for Twilio Verify, which Sway uses as one factor in the user authentication flow. To create a Verification Service you can use the Twilio API via the guide here - https://www.twilio.com/docs/verify/api, or you can use the Twilio Console:
-
Click the "Develop" tab on the left sidebar.
-
Click "Explore Products +" on the left sidebar.
-
Scroll down and click "Verify".
-
Create a new Verify service.
GOOGLE_MAPS_API_KEY=
Sway uses Google Maps for geocoding user addresses into latitude/longitude coordinates during registration. These coordinates are then used with a geojson file and Census.gov API to determine a user's representatives in a given SwayLocale.
To create this key:
-
Click on the Navigation menu.
-
Hover over APIs & Services and click 'Enabled APIs & services'
-
Click the "+ ENABLE APIS AND SERVICES" button at the top.
-
Enable the "Maps JavaScript API"
-
On the sidebar, click "Keys & Credentials"
-
Generate an API Key with:
- a website restriction to localhost
- The "Maps JavaScript API" selected
- The "Places API" selected
- The "Geocoding API" selected
VAPID_PUBLIC_KEY=
VAPID_PRIVATE_KEY=
Sway uses these keys to send web push notifications via the web-push ruby gem.
You can generate keys after running bundle install
by opening the rails console with rails c
and running:
irb(main):001> WebPush.generate_key
=> #<WebPush::VapidKey:67d4 :public_key=BDH9S_5CtkeVBJmtGxcrXD7_bXyp4GyxYMiuH4Rlh0RW6dhsj3Arurxkf-0_BI2kLaUBFLcfIi9fi2K8wqxSUq0= :private_key=wsx-vK4_ZFULdXlqSnE2VJPc548k1ihydsfzqZKtDFY=>
Copy the full key, including the =
at the end into each environment variable above.
You can read more about web push notifications here:
-
https://developer.mozilla.org/en-US/docs/Web/API/Push_API/Best_Practices
-
https://web.dev/articles/push-notifications-web-push-protocol
ADMIN_PHONES=1234567890
Only administrators can create new Bills in Sway.
SWAY_DATABASE_PASSWORD=sway2000!!
Just a reminder that this is only used for development.
brew install mkcert nss
mkcert -install
mkcert localhost
mkdir -p config/ssl
mv localhost.pem config/ssl/cert.pem
mv localhost-key.pem config/ssl/key.pem
- In one terminal window/tab/pane:
bundle install
bundle exec rails db:create
bundle exec rails db:migrate
bundle exec rails db:schema:load
# Load seeds including locales and geojson files
bundle exec rails db:seed
bin/rails server -b 'ssl://localhost:3000?key=config/ssl/key.pem&cert=config/ssl/cert.pem&verify_mode=none'
- In a second terminal window/tab/pane:
npm install
./bin/vite dev
Open your browser to https://localhost:3000 to begin working with Sway.
Copyright 2024 Plebeian Technologies, Inc.
Licensed under the GNU General Public License Version 3.0 (or later); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:
https://www.gnu.org/licenses/agpl-3.0.en.html
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Plebeian Technologies, Inc. is a 501(c)(3) not-for-profit corporation.