Compfest Hospital

25 July 2021

Intro :flashlight:

Compfest hospital is a “hospital management system” that I made with golang. Though the word hospital is in the name, it functions more like an event organizer’s website, where admins can organize events called “doctor appointments” while the attendants, the “patients” can interact with these appointments.

Where

It’s live on heroku at https://compfesthospital.herokuapp.com/

The code is on github! I also wrote detailed descriptions and specifications there but honestly I’d rather just read about the bigger picture and the cool stuff, which is what I’m writing here!

What for

Aside from me wanting to develop my skills on web development with golang, this project is a task assigned for Compfest Software Engineering Academy students for selection/elimintation.

It’s made according to a list of requirements but I also added a bunch more features to really put myself ahead of the other contestants. I really want to be a good software engineer, the least I can do is get into 1 workshop/academy event.

Front End

I’ll be honest, I don’t like frontend, I love backend all the way. The front end is simply someone else’s template that I chopped into pieces and frankenstein-ed back together and retrofitted with bootstrap elements.

Back End

I started by imagining how I would like a website where I could search and book for doctor appointments, so I made a rough sketch of what the user would experience when using the website. Then I also designed what the database will look like. After a couple of iterations as I go along the project, the end results are these.

Now these are the juiciest parts

Authentication :key:

The requrements stated there are only 2 roles, admin and user. So there won’t be anymore roles, I went with using a column (admin) in the users table to save space and make it easier to query.

Wierdly enough, the requirements wanted to use JWT for the authentication, after a bit of searching, turns out JWT isn’t a good substitute for old school “sessions”, as in making a sessions table in the database and have all the session data be server-side. I thought regular sessions would be a great idea, but the requirements say otherwise, so I went with putting just the username and expiry time in the JWT.

Register

User/patient account creation goes through the usual steps;

  1. check for existing primary key (username)
  2. insert new record (db INSERT)

Admin account creation doesn’t have a UI, so it’s only possible with a manual database insert. One admin account is created by default during build.

Login

  1. checking for existing primary key (db SELECT WHERE)
  2. compare authentication parameter (password hash)

Since both regular and admin users exist in the same database, I used a WHERE clause to differentiate between an admin or regular user, and generate the website functionality based on that.

Logout

We just destroy the session cookie, but since we use JWT, if the JWT cookie isn’t actually deleted then that cookie can still be used to authenticate the user. Which is why the expiry time on the JWT cookie is low (15 mins), no other way around except using regular sessions.

Admin capabilities :cop:

Managing appointments

Managing users

I decided admins may not delete user accounts.

User capabilities :bust_in_silhouette:

Appointments

User data

Conclusion

After the main requirements were fulfilled, I put the website up on heroku, fortunately I was able to set it up, including the postgresql database. Then I continued to add the extra functionalities like pictures and comments.

The requirement itself isn’t that much to be honest, but the wording makes it a bit hard to understand at first, it’s just a 1 page pdf anyway.

Mistakes

During the development I realized too late a bunch of things, like:

The end

I gave it my all, 10+ hours per day for about 1-2 weeks even including weekends. I don’t wanna take any chance, I wanna improve my skills, improve my portfolio, I wanna get in this academy, learn a bunch of things, I wanna be an awesome software engineer, get my first software engineering job, and go to an international software company.

Good thing I also happen to enjoy building things eh :smile: