Quran-Journey / backend

The main backend service for Quran Journey
5 stars 1 forks source link

Major Refactor of backend #124

Closed osamaramihafez closed 9 months ago

osamaramihafez commented 2 years ago

The backend needs some rethinking for sustainability. In general, we've needed to refactor for a while, but priority on this is bumping up since we have the time (while other nonoverlapping projects are being prioritized). Also, this started to become relevant as we tried to fix auth middleware for https://github.com/Quran-Journey/backend/issues/166

Before this is done we should migrate to typescript somehow.

A summary of what the future structure might look like can be found here: https://chat.openai.com/share/b4ab526c-0037-4fcc-b96e-7919e3e6e579

The models folder would only contain class-based models for every model in Postgres rather than database interactions which would only be kept in the services folder. In our case, this is mostly just renaming the models folder to services and then creating the models themselves. Surprisingly, the chatgpt link I shared above does a good job of explaining things.

The purpose of the model folder would be to only include business logic like sorting, filtering, etc. Services would be database access heavy.

Also, other cleanup tasks to consider:

osamaramihafez commented 11 months ago

Still, some work needs to be done, but I wanted to merge in current work. Everything works so far