itsme2's avatar
Level 1

How should I design the architecture for a project with multiple applications?

Hey boyz,

I am working on a project that consists of the following applications:

  • A backend site for staff management.
  • A frontend site for customers.
  • A mobile app for customers (built with Kotlin ).

All three applications will share a single database. I plan to use Laravel with Inertia.js and Vue.js for the frontend/backend and MySQL as the database.

Design Question

I'm trying to decide on the best/good architectural approach:

Should the backend handle all core functionality (authentication, authorization, payments, creating appointments, etc.) and expose this functionality via API for the other applications to consume?

OR

Should each application have its own separate codebase, handling its specific logic independently?

My biggest concern is authentication, authorization and payment. If the backend is responsible for everything, how can I ensure secure and efficient handling of authentication/authorization across all applications (especially the frontend and mobile app)?

I have heard of Laravel Sanctum and Laravel Passport but I am not sure which is better suited for my project.

I would appreciate any suggestions or tips :)

0 likes
2 replies
Snapey's avatar

why?

why not one app with client routes, admin routes and an api?

1 like
martinbean's avatar

Hey boyz

The poor ladiez of the forum…

Should each application have its own separate codebase

@itsme2 Absolutely not. That sounds awful. Any time you develop a new feature, you’re going to have to coordinate branching and deploying of three separate codebases and applications, instead of one. And if you did have three separate applications, then which one is things like migrations going to live in…?

Stop over-complicating the problem. Create a Laravel project. Group your controllers and whatnot using namespaces. Create controllers and views for your admin panel; controllers and views for your customer-facing website; and then controllers for the API that the mobile app would use:

  • App\Http\Controllers\Admin\ProductController
  • App\Http\Controllers\Api\ProductController
  • App\Http\Controllers\Frontend\ProductController

This way, you can use the same models, jobs, and other classes across each “part” of the application, instead of having three codebases where you define the same models over and over.

2 likes

Please or to participate in this conversation.