GithubHelp home page GithubHelp logo

mahmoudz / porto Goto Github PK

View Code? Open in Web Editor NEW
1.6K 87.0 183.0 75.49 MB

Porto is a Modern Software Architectural Pattern that scales with your business!

Home Page: http://mahmoudz.github.io/Porto/

License: MIT License

architecture architectural-patterns porto porto-sap software-architecture backend backend-architecture backend-architecture-patterns webdevelopment portosap

porto's Introduction

Porto (Software Architectural Pattern)

Welcome to Porto

Porto is a modern software architectural pattern that provides a comprehensive set of guidelines, principles, and patterns to organize code for high maintainability and reusability. Its primary aim is to facilitate the development of scalable software, enabling developers to start with a clean monolith and easily transition to microservices. Furthermore, Porto's strict adherence to the single responsibility principle enhances its compatibility with AI tools like GitHub Copilot, which thrive on clear, well-defined classes.

"Simplicity is the ultimate sophistication." - Leonardo da Vinci




Porto SAP Documentation




Clear Layers

App code is divided into Containers and Ship layers. Containers encapsulate the business logic, while Ship handles all infrastructure-related code, enabling easy scaling on demand by transitioning from monolithic to microservices.



Clean Components

Business logic in Containers is organized into Actions and Tasks. Actions initiate sequences of Tasks, each with one public function run() for a single responsibility, thereby enhancing maintainability and enabling code reusability.



Author

author image
Mahmoud Zalt
GitHub: Mahmoudz
Twitter: @mahmoudz
LinkedIn: mahmoudzalt
Portfolio: zalt.me

Donations

I appreciate your support. Github Sponsor.

porto's People

Contributors

bit4bit avatar knulledge avatar mahmoudz avatar mohammad-alavi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

porto's Issues

Where can i put the pdf views?

i have noticed, there is mails/templates for mail views and views in web ui for web views.

i have this action that creates pdf. where can i put the pdf views? and for excel export views?

thanks

Relationships between sections

How to organize communication between sections, if we have an order section and a delivery section. They both require a relationship with the User model, which can be found, for example, in the user section.
According to the rules, such a relationship is impossible: A Section MUST be isolated and SHOULD NOT depends on any other Section.

The Ship Layer can hold some business logic?

We are in great doubt here in the company in the implementation of this architecture. Firstly, I would like to congratulate. It's very cool to have such a well-defined line to follow. Congratulations!

Our question is about when it is acceptable for business rules to be within the Ship Layer. Some examples:

  1. We have several routes in the system that can only be accessed if a company has been saved in session.
  2. In every change of route we need to check whether it has new messages or new warnings from other users of the system. Like a notification center.
  3. In every change of route (again) we need to check if the user data fields is completed and alert to the logged user that he needs to fill this data asap.

We understand that these are global resources that can be accessed from anywhere in the system. Would that be a reason why they were inside Ship Layer? On the other hand, in the case of messages and the user data, we will have a Message Container and a User Container. Soon I imagine that this feature of checking new messages should be in their Containers in order to get everything in the domain place.

Would you suggest us a clear way of thinking when deciding if something business could be inside Ship Layer or in Container?

Thank you very much in advance.

Middleware?

Where you put the Middleware level in the picture of "Typical Container Example"?
One for container, or middleware for each API/WEB?
Thanks

Are you planning to provide some examples of this architecture, explaining the most adequate pattern or SOLID principle for each component?
Really good job.

Reusing Action between different callers

Hello there. We've started to develop a new PHP project using the Porto pattern, which (in theory) is the 'answer on all of my questions'. Good job!

However, there is something I'm not sure how to deal with. Let's say we have an Action that do something like attaching roles to a specific user. We have a special route in our API, but also want to have a possibility to do this from console (SSH). And there is a problem: Action receives Request instance as parameter - and we won't create Request while using console.

4 possible solutions that came to my mind:

  1. Let Action method receives simple array of data instead of Request, but it forces us to pick that data in Controller, when in API/Web request.
  2. Create SubAction for every Action that we need to be usable from different sources (API, Console). SubActions can receive simple array as parameters.
  3. Create variant of Action for every source. (duplication of code, makes Actions less reusable, list of use-cases are less readable)
  4. Implement a different methods in Action (console, api), and call them from run() method, which choose the correct method by the type of parameter. (if parameter is Request - call 'api', if Console - call console).

I guess the best one is probably number 4, as all others have some drawbacks, but maybe You already had some thoughts in this case and have good solution?

Can route call controller in another container?

For real problem I have 2 tables district and sub_district.

I've following routes

  • /districts
  • /districts/{id}/sub-districts
  • /sub-districts

I've containers District and SubDistrict.

In /districts/{id}/sub-districts, where do I have controller function named getSubDistrictsByDistrictId ? In District or SubDistrict container?

Fow now I put that function in SubDistrict container, But it makes me to call controller from different container.

tow misspelts

  1. A Task SHOULD NOT accept a Request object in any of its functions. It can take anything in its funtions parameters but never a Request object. This will keep free to use from anwyhere, and can be tested independently.
  2. The secret of making the testing and debugging easy, is not onnly in the organization of the tests and pre defined responsiblity of the components but also in the decoupling of your code.

Can actions have other methods?

For actions, usually will have method run() and all the logic will be there.
I have a big chunk of code which only use in one actions, i want to split it to multiple method to increase readability. For now all the logic only use in one actions. There no need to create a task from it somehow for now.
Can actions have other method than run() ?

Some questions

Hello!
Porto, that's really awesome. I really intresting make my future web app on this architectural pattern. But I have some questions, I hope you'll finf time to answer on thats.

  1. If I will use for example Cookie (from laravel) or GuzzleHttp, do I need to create Abstract Classes for it in the Core and after that create in the Ship layer some folders (Other Folders) and use classes from this folders in Containers? Or do I need to create Abstract Classes in the Core and extends thats in components Cookie and HttpClien in folder Parents in the Ship layer and after that use components (Cookie and HttpClien) in Containers?

  2. I found that in apiato/app/Containers/Authentication/UI/API/Controllers/Controller.php you use Facade to access to Cookie, why it did't moved to the Ship layer in the Core in Abstract Classes? Should I move any connection with the infrastructure (frameworks, composer packages) to the core in Abstract Classes or I can use Facades and Contracts in containers?

  3. If I'll create dashboard in my application do I need to create UI - Admin?

Can I register a different container's task with the provider?

I had one question when I registered the components of that container in the main provider.

The 'Poto' architecture said, action can call the tasks of other containers.

I don't think we can guarantee the order in which to register actions that are dependent on other container tasks from the certain container provider.

I've been looking at an example called apiato, but it's not very helpful because it's.

Is my approach wrong?
Or are there any solutions to this?

Middlewares, Controllers Factories

Hey, when i see Porto/Apiato, i thinks is so amazing... but i have some points to talk about this architeture and like to talk about it, currently yours used what chat to discuss ?

I not like laravel, but not hate me, i try to reproduce this architeture with zend expressive, and if you can response me, on UI have space to factories ?

Bash scripts location

In this architecture where would you put bash scripts called from Node.js for example? I've used a specific folder called bash/ to place those scripts but is there a folder you think could be used in the current organization defined in README of this project?

Actions, SubActions, Tasks re-usability issue

There are so many cases when I have a beautiful class MyFirstTask.php. And also I have MySecondTask.php which I use in some SubAction classes. And I really need (but unfortunately Should not) to use MyFirstTask.php in MySecondTask.php that would perfectly solve everything and rescue the world. What should I do in such multiple cases when I really need to re-use Tasks (or SubActions, or Actions) in similar kind of classes (Tasks in Tasks etc)? Also sometimes there's one super useful SubAction class that would perfectly solve many problems in a Task class.

Lack visual information about Sections

Hi @Mahmoudz

The information about Sections in Porto pattern is well written , but I think is missing a folder structure diagram.
I don't know if Sections is from another pattern, but I was a bit confused if is just a nested folder to set context or something more.

Thanks ๐Ÿ‘

Any success stories?

First of all thank you very much for a very detailed explaination of the approach you propose. I wonder if you have already a list of some big projects who has successfully implemented Porto and also Apiary?

Containers Sections Question

can sections use other sections tasks or actions for example

i have a blog application with Admin Section & Moderator Section , and the Admin can list posts also Moderator can list posts , so in this case the sections can cross boundaries or i duplicate the logic of list posts tasks in both sections?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.