cpsc455-bugstorm / TravelersTea

A Trip Planning App that tailors travel itineraries based on user preferences and providing detailed information about destinations; making travel planning less daunting and more enjoyable.
https://travelerstea-906d.onrender.com
MIT License
6 stars 2 forks source link

[AL-1] Proposing to use Controller -> Service -> Repo pattern #1

Closed AndyLiang1 closed 11 months ago

AndyLiang1 commented 12 months ago

Hi. I am proposing we use a Controller -> Service -> Repo pattern for the BE.

Controller is responsible for dealing with api route stuff.

Service is responsible for dealing with business logic.

Repo is responsible for dealing with getting information (say from DB)

Model folder is for when we have mongo set up.

ExampleController.js calls ExampleService.js which calls ExampleRepo.js. All services are combined together in a collective services.js file (this is in the future, for if we need services to call other services, it is nicer to have one where we can always access).

vee-16 commented 12 months ago

@AndyLiang1 I've been used to MVC approach so can you tell me more about the how adding repo layer would be good to incorporate to the project?

AndyLiang1 commented 12 months ago

The repo layer is purely responsible for CRUDing stuff in the DB. If for whatever reason someday, we wanna change our DB to SQLServer or smt, we won't have to change the service layer (imo, changing the service layer is very costly cus it has all the business logic).

Also, my coops companies did that so I follow them ahah

L0Lmaker commented 11 months ago

Will make decision after speaking with TAs

L0Lmaker commented 11 months ago

@AndyLiang1 Move this to issues closing for now