Digital Citations — A Paperless Parking Citation System (AWS Serverless Cloud Solution)

huan liang
Egen Engineering & Beyond
4 min readJul 25, 2019

The worst part about parking in Los Angeles isn’t trying to find an actual parking spot. It’s finding out you have a $75 parking ticket hanging on your windshield when you come back to get your car.

You Don’t Want To Get This One

And to be honest, you’ll be lucky if the piece of paper with your heavy fine is still there. Often times, the citation falls off the windshield wiper and you’ll never even know you received a ticket in the first place. And let’s be real, sometimes you lose the paper citation or just rip it up because you don’t need that type of negativity in your life right now.

So, we thought this all-paper experience was horrible for LA citizens and wanted to do something about.

Introducing, Digital Citations Finder — Get notified digitally when you receive a ticket.

It Starts With Connecting Data Points

As part of an open data initiative, the city of Los Angeles provides daily file uploads containing parking citations in the LA region. It’s a pretty impressive data file that gives you details on every single citation issued, the location of the ticket, and a timestamp (among other things).

The data pipeline starts with downloading and copying the data file from the original AWS S3 bucket, and placing it on our own S3 bucket.

s3 = boto3.resource(‘s3’)
s3.Object(dest_bucket.name, file_key).copy_from(CopySource = {‘Bucket’: source_bucket.name, ‘Key’: file_key})

This is a really informative data set.

Digital Citations — A Paperless Parking Citation System

We have two powerful use cases from this data:

1) Get a digital notification of your citation. This notification includes all of your parking details as well as information on how to pay the ticket. If we have access to DMV records of vehicle registrations, we can retrieve the contact details of the car owners and send push notifications automatically.

2) Visualize historical citation data so you determine which regions/zip codes you’re most likely to get a ticket in.

To take this further, you can even set up push notifications to let the user know they are parking where many people received parking tickets. Since we have the exact latitude and longitude, this is possible.

Great things happen when you can connect multiple disparate data sets.

Digital Notification Citation System

To create this experience, we need two things to make it work:

1) Original data from the City of Los Angeles (we have that).

2) Matching license plate to email address (for this POC, we created our own database).

It works like this:
You park > You get ticket > You get notified via email and SMS the next morning with the ticket details.

The code snippet below shows how to send emails via AWS SES.

from botocore.exceptions import ClientError
client = boto3.client(‘ses’,region_name=AWS_REGION)
try:
response = client.send_email(Destination={
‘ToAddresses’: [RECIPIENT ],},
Message={‘Body’: {
‘Html’: {…},
‘Text’: {…},
},
‘Subject’: {…},
},
Source=SENDER,
)
except ClientError as e:
print(e.response[‘Error’][‘Message’])

This makes sure every citizen receives their citation information and has easy next steps. This experience would actually make it easier for cities to get paid faster.

Visualizing Historical Data (Insights)

As part of our technical architecture, and all-AWS cloud infrastructure setup, we made it easy to visualize the data over a period of time (not just the daily file). To make the visualizations, first we need to put all data into AWS Redshift.

con = psycopg2.connect(dbname=*, user=*,password=*, port=*, host=*)
MessageBody = json.loads(record[‘body’])
citation =json.loads( MessageBody[‘Message’])
……
cursor = con.cursor()
update_query = “””INSERT INTO public.”ticket_info”
(ticket_id, ticket_time, zip_code)
VALUES (%s, %s, %s) ;”””
cursor.execute(update_query, (ticket_id,ticket_time,zip_code))
con.commit()
This visualization shows where most # of citations are issued in LA.

All-AWS Cloud Native Approach

At Egen, we truly believe startups and corporations will be creating these types of experiences all within the AWS cloud ecosystem.

Using an AWS Native approach, we built a fully automated solution to ingest and transform the Los Angeles Parking CSV data into a data warehouse (AWS Redshift) that makes violation visualizations for each zip code region dynamically, as well as generate citation emails.

The beautiful part of serverless architecture is that you can build applications without worrying about setting up servers (EC2 instances), scaling, and other DevOps-related maintenance. AWS takes care of all of these things so you can focus on the use case.

Technology Stack:

1) Amazon S3 (to store the original CSV files)
2) AWS Redshift (for running analytical queries)
3) AWS QuickSight (for visualization)
4) AWS SES (to send email)
5) AWS SQS (to queue messages)
6) AWS SNS (Simple Notification Service)
7) Lambda functions (for individual use case code execution)
8) CloudWatch Scheduler (to schedule the data refresh)
9) Python (for any scripting)

The architecture looks like this:

Check the origin post in a better format at here: https://egen.solutions/blogs/digital-citations-a-paperless-parking-citation-system-an-all-amazon-serverless-cloud-solution

If you find this blog helpful, be sure to give it a few claps, follow me on LinkedIn

--

--