Skip to content

vincenthphung/direct-rep

Repository files navigation

DirectRep

⚡️ Powered by: Google Civics API and OpenAI GPT3 ⚡️

DirectRep is an app that allows US Citizens to write letters to their elected representatives using Artifical Intelligence to generate the body text given a specific "issue" and "stance" on that issue. The user's representatives are gathered using Google Civic Information API and are determined by the Zip Code the user provides on Sign-Up.

This service lowers the barrier-to-entry for citizens to have their voices heard by their elected representatives. Regardless of your literacy, your English proficiency, your ability to articulate your thoughts and opinions, having your voice heard is now easier for everyone to access.



**Disclaimers**
There may be data missing from Google Civics API which may lead to certain representatives not being shown in the results. Always double check and verify your representatives' data.


👾Developers👾

Kim Geraghty -- FullStack Developer

Aaryan Mittal -- FullStack Developer

Vincent Phung -- FullStack Developer

John Gardner -- FullStack Developer



🗺️Diagrams of Architecture🗺️


DirectRep Wireframe Overview

DirectRep wireframe overview

Users-Service Microservice

users-service microservice architecture diagram

Users-Service Endpoints

users-service microservice endpoints diagram

Letters-Service Microservice

letters-service microservice architecture diagram

Letters-Service Endpoints

letters-service microservice endpoints diagram


👥Users-Service Microservice👥 -- :8080



Endpoints

Page Request Type Path Request Shape JSON **Response Shape (JSON)
Signup Page POST localhost:8080/api/accounts {
;"full_name": "string",
"email": "string",
"zipcode": "string",
"password": "string"
}
{
"access_token": "string",
"token_type": "Bearer",
"account":
{
"id": 0,
"full_name": "string",
"email": "string",
"zipcode": "string"
}
}
Login Page POST localhost:8080/token {
"username": "string",
"password": "string"
}
{
"access_token": "string",
"token_type": "Bearer"
}
Get Token GET localhost:8080/token N/A {
"access_token": "string",
"token_type": "Bearer",
"account":
{
"id": 0,
"full_name": "string",
"email": "string",
"zipcode": "string"
}
}
Update Profile Page PUT localhost:8080/api/accounts/$id {
"full_name": "string",
"email": "string",
"zipcode": "string",
"password": "string"
}
{
"access_token": "string",
"token_type": "Bearer",
"account":
{
"id": 0,
"full_name": "string",
"email": "string",
"zipcode": "string"
}
}
Logout Page DELETE localhost:8080/token N/A {
true
}

Database Models

(values in parenthesis are max values. e.g. VARCHAR(255) is a variable character with a max_length of 255 characters)


'user' database table

Field FieldType **options
id SERIAL PRIMARY KEY NOT NULL
full_name VARCHAR(255) NOT NULL
email VARCHAR(255) NOT NULL
zipcode VARCHAR(5) NOT NULL
hashed_password VARCHAR(255) NOT NULL




📨Letters Microservice📨 -- :8090

Endpoints



Letters-Service Endpoints

Page Request Type Path Request Shape (JSON) Response Shape (JSON)
Create Letter POST localhost:8090/api/letters {
"topic": "string",
"stance": "boolean"
}
{
"id": 0,
"topic": "string"
"stance": true,
"content": "string",
"user_id": 0
}
Get ALL Letters for User GET localhost:8090/api/letters N/A {
"id": 0,
"created": "2022-12-12T04:00:12.644Z",
"topic": "string",
"stance": true,
"content": "string",
"user_id": 0
}
Get Single Letter GET localhost:8090/letters/${letter_id} N/A {
"id": 0,
"created": "2022-12-12T04:00:12.644Z",
"topic": "string",
"stance": true,
"content": "string",
"user_id": 0
}
Edit Letter Body PUT localhost:8090/letters/${letter_id} {
"letter_id": 0,
"content": "string"
}
{
"content": "string"
}
Delete Letter DELETE localhost:8090/letters/${letter_id} N/A {
true
}



Issues Endpoints

Page Request Type Path Request Shape (JSON) Response Shape (JSON)
Get ALL issues GET localhost:8090/api/issues N/A {
"string"
}



Reps Endpoints

Page Request Type Path Request Shape (JSON) Response Shape (JSON)
Get Reps from API GET localhost:8090/civics N/A {
"office": "string",
"level": "string",
"name": "string",
"party": "string",
"address": "string"
"address": {},
"email": "string"
}
Get All Reps GET localhost:8090/api/reps N/A [
{
"office": "string",
"level": "string",
"name": "string",
"party": "string",
"address": "string",
"address": {},
"email": "string"
}
]
Select Rep POST localhost:8090/api/reps {
"office": "string",
"level": "string",
"name": "string",
"party": "string",
"address": "string",
"address": {},
"email": "string"
}
{
"rep_id" 0,
"office": "string",
"level": "string",
"name": "string",
"party": "string",
"address": "string",
"address": {},
"email": "string",
"letter_id": 0
}
Get SINGLE Rep Selection GET localhost:8090/reps/${rep_id} N/A {
"office": "string",
"level": "string",
"name": "string",
"party": "string",
"address": "string",
"address": {},
"email": "string"
}
Get ALL Rep Selections for SPECIFIC letter GET localhost:8090/reps/letter/${letter_id} N/A [
{
"office": "string",
"level": "string",
"name": "string",
"party": "string",
"address": "string",
"address": {},
"email": "string"
}
]
Delete SINGLE Rep Selection from SPECIFIC letter DELETE localhost:8090/reps/letter/${letter_id} N/A {
true
}




Database Models

(values in parenthesis are max values. e.g. VARCHAR(255) is a variable character with a max_length of 255 characters)




'letter' database table

Field FieldType **options
id SERIAL PRIMARY KEY NOT NULL
created TIMESTAMP `DEFAULT CURRENT_TIMESTAMP
topic VARCHAR(1000) NOT NULL
stance BOOLEAN NOT NULL
user_id INTEGER NOT NULL




'issue' database table

Field FieldType **options
id SERIAL PRIMARY KEY NOT NULL
user_issue VARCHAR(1000) NOT NULL
openai_issue VARCHAR(1000) NOT NULL




'rep' database table

**Field FieldType **options
rep_id SERIAL PRIMARY KEY NOT NULL
office VARCHAR(255) NOT NULL
level VARCHAR(255) NOT NULL
name VARCHAR(255) NOT NULL
address VARCHAR(1000) NOT NULL
email VARCHAR(255) NOT NULL
letter_id INT FOREIGN KEY (letter_id)
REFERENCES (letter_id)
ON DELETE CASCADE




Key Features

Location Dependent Representative Results

Your list of available representatives is pulled from Google Civics API using the Zip Code provided on Sign-Up

AI Generated Text Response

When creating a letter, your "issue" and "stance" are sent to a 3rd party API that then uses a large-language model to generate the letter body the users desires.

User Customization

When the AI returns your letter body, the user can change, add, or remove any part of the letter, making it fully customizable and ensuring the voice accurately represents the user.

Account Dependent Information

After creating an account and creating letters, the letters you see in your Dashboard are only the letters you created

Account Dependent Information

After creating an account and creating letters, the letters you see in your Dashboard are only the letters you created


Getting the App Started


  1. Git clone into your local repository git clone «repo»
  2. cd into it cd direct-rep
  3. Create a new file in the root directory called .env (This is where you'll store your Google Civics API Key and you OpenAI API Key)
  4. Create a volume and name it beta-data docker volume create postgres-data
  5. Build the image and run the container docker compose up --build
  6. Open browser to http://localhost:3000 to make sure it’s running
  7. Once it’s up and running, you can begin with creating an account and confirming that account. Once you confirm the account, you can create a new letter.




FAQ

Who are your customers?

People residing in the United States of America.

What needs/desires does your application satisfy for your customers?

Making contacting your elected officials more accessible

What features/functionality do you plan to have in the application that helps your customers?

  • List of representatives with their details.
  • List of issues.
  • Open AI to draft an automated AI generated letter.
  • Login / logout feature.
  • Email template sent to user’s email with letter draft and rep’s emails list.
  • Keep track of past letter templates / requests

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages