Building Software to Aid the Asylum Process
Published: 2021-03-01 22:00:27

This past month, I was working with a team to build a web application assisting the Human Rights Foundation (HRF). HRF is an independent advocacy and action organization that challenges America to live up to its ideals. The problem our team is solving is the lack of information that US asylum seekers have going into their trials. The website we are building will feature a public database of different information about US asylum cases. This data will help asylum seekers and their lawyers recognize patterns and prepare for their own cases. Users will also be able to contribute back to this database with their own cases. Going into this project, I was a bit worried because it was the first time I was building software that I knew people would actually use. However, as I started working, that prospect actually just made the work much more fun and exciting. It brought out the best in my programming ability, and I am thankful for the opportunity. 

The Technical Work

The specific part of the project that I worked on was the React-based front-end view of the case database. Specifically, I took the job of building a complex filtering mechanism for the case data. The finished product (shown at the bottom of the post) gives the end-user the ability to pinpoint specific cases that are relevant to them by querying the database with as many fields as they wish. To do this, I created a few different state objects that managed whether the user was searching and if yes, what the user was searching. Based on these state objects, I would alter the UI and determine whether raw or filtered case data would be shown in the table. 


One technical challenge that I encountered during this process was creating successful AND logic for multiple searches. After implementing multiple query options for the user, the filtering algorithm the previous team wrote no longer worked. Getting OR functionality (returning cases with any of the user's queries) was fairly easy, but the stakeholder clearly wanted AND logic. After unsuccessfully working for a while in Javascript, I actually decided to try and write the algorithm in python. Python is the language I used in the "computer science" unit of Lambda School, so it was a language I was more comfortable with solving coding challenges. Sure enough, I was able to figure out a solution in python which I then turned in to Javascript. In the process, I used some old basic concepts like a counter variable but also learned some new JS methods like Object.keys. Pictured below is the finished filtering algorithm. 
`const filter = rows => {
    const returnedRows = [];
    const keysArray = Object.keys(queryValues);
    const filtered = keysArray.filter(key => queryValues[key] !== '');
    if (filtered.length > 0) {
      rows.forEach(element => {
        let counter = 0;
        filtered.forEach(key => {
          const keyValue = element[key].toString();
          if (keyValue.includes(queryValues[key].toString())) {
            counter++;
          }
          if (counter === filtered.length) {
            returnedRows.push(element);
          }
        });
      });
      return returnedRows;
    }
    return rows;
  };`

The Bigger Picture

I am happy with the overall progress that our team made on this project. On the web team, we shipped multiple new features including the filtering system, adding new columns to the case table, and made progress on other features like the administrator-approval view. For Data Science, although I don't fully speak their language, it was clear the team made lots of progress on the PDF scraper and overall case data analysis. Below is the fully built-out user flow of logging in and searching for specific cases. This is something that eventually anyone will be able to do, and it is cool knowing I contributed to the experience of people applying for asylum in the United States. 

Beyond building a cool piece of software, I learned a lot about myself. I learned from my teammates how important communication is and got some personal feedback like how I need to be more open to teammate's ideas. I think that this group working experience will really help further my career goals. Obviously, any paying job involves working in a team, so I'm grateful I was able to get a taste of this in my time at Lambda. The future teams will have a lot to do on this project. I think their number one priority will be to nail down the user flow of individuals uploading cases and administrators reviewing/approving them. This might be challenging when integrating with Okta as there will have to be two different user types. When that is finished and they have more data, they will have the opportunity to get creative on how they display data to the end-user. 

![Screen Shot 2021-03-04 at 10.27.49 AM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oj4i3k0pu1g8cg4isr2n.png)
![Screen Shot 2021-03-04 at 10.27.37 AM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xm01bvru8pqsqmhyax3r.png)
![Screen Shot 2021-03-04 at 10.28.15 AM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r0kdqq5dvrwnvya8q2ud.png)