Empowering Kids with Java

Sam Perrin
4 min readMay 27, 2021

I’ve recently been working with a team from Lambda School to build a web app for the Boys & Girls Clubs of Greater Conejo Valley, a group that provides after-school programming for students in southern California. Our web app will help the clubs elicit feedback from the students they serve, allowing kids to select an emoji that represents how they’re feeling about a club’s programs.

We’re using a React app on the front end with a Java Spring / PostgreSQL backend to handle the data so program administrators can identify kids that need extra attention and programs that are not meeting kids’ needs.

The heart of the application is the emoji-selection page, where students can submit their choice, which is then saved to the database with relevant data about their current activity and member id. One problem I solved involved building the endpoints for the database to receive and store students’ reactions from the emoji-selection page.

How I solved the problem

In order to add the endpoints that would allow the front end to post the students’ reactions to the database, we needed to add several files. First, we had to add interfaces extending Java Spring’s CrudRepository for both Members and Reactions to allow us to interact with the database’s tables for Members and Reactions.

The interface for the ReactionRepository, extending Java Spring’s CrudRepository.

Once the repositories were in place, we decided to add some custom service interfaces and classes, one each for Members and Reactions, to handle the business logic for saving new Members and Reactions to the database. Here’s how the Reaction service’s save works for reactions with known IDs: it checks the repository to see if a reaction with the given ID is already present in the database, throwing a custom exception if it isn’t found, otherwise using the CrudRepository to save it to the database.

A snippet of code for the ReactionService’s save method
The ReactionService’s save method.

With the services written, we moved on to write controllers for both Members and Reactions using Java Spring’s @RestController annotation. The controllers expose the new endpoints allowing the front end to post new reactions from the members at the Boys & Girls Clubs. These use the @PostMapping annotation for HTTP POST requests, only allowing authorized users to access the endpoint:

The addNewMember method of the MemberController, exposing an endpoint for the front end to POST new members to the database.

One nice feature of this method is that it constructs a custom HTTP header as part of the response so that the front end has the option of redirecting to a page containing data about the newly created member.

With the major components in place, all that remained was to test it out. To begin our testing, we added some seed data for Members and Reactions so we could explore the endpoints’ functionality using Postman. (Everything worked as expected.)

The Product and its Future

After nearly a month of work on this project, my team has worked hard to put together a great product. (You can see the repos here and here.) In its current iteration, the application has some amazing features:

  • Staff from the Boys & Girls Club can generate an ID badge with a custom QR code for each student.
  • The QR codes can be scanned to quickly identify each student, allowing an ID number to be connected to their emotional rating for a given club program.
  • An emoji-selection page allows students to indicate their emotional sentiment after a program at the club.
  • Students’ reaction data is stored in a PostgreSQL database.
  • Data from the database is accessible in graphs and charts to help club administrators make informed decisions about the success of their programming.

The next cohort to work on the product will extend the functionality of the administrator dashboard to allow more sophisticated insights into student needs. For instance, they might analyze the data in our database to identify students with consistently poor reactions who might need more attention. Or they could identify students with unstable reactions over time. They could even generate recommendations about which programs are successful, or which staff have the greatest impact on the success of a program in the eyes of the club’s students. These kinds of insights would require more expertise in data analysis than my team could bring to bear on the problem.

On the whole, this project has been a great experience for me. I’ve learned a lot about working on a cross-functional team, and I’ve learned some new technical skills just from reading my teammates’ code. I look forward to applying these skills in future projects of my own.

--

--

Sam Perrin
0 Followers

Full stack web developer. Lambda School.