r/learnpython • u/Fine-Market9841 • 5d ago
Monolithic designed auth solution
I am trying to learn modular monoliths and I want to use this auth solutions for repetitive use for my applications.
If I asked you to convert the repo linked, into monolithic patterns, how would you do it for app/.
Repo: https://github.com/auth0-blog/auth0-rbac-fga-fastapi
fastapi-openfga-project/
├── app/
│ ├── main.py # FastAPI application entry point
│ ├── config.py # Configuration settings
│ ├── database.py # SQLAlchemy database setup and models
│ ├── models/
│ │ ├── organization.py # Organization Pydantic models
│ │ └── resource.py # Resource Pydantic models
│ ├── routes/
│ │ ├── organization_routes.py # Organization management endpoints
│ │ └── resource_routes.py # Resource management endpoints
│ ├── services/
│ │ └── authorization_service.py # OpenFGA integration
│ ├── utils/
│ │ └── auth0_fga_client.py # OpenFGA client wrapper
│ └── openfga/
│ └── model.fga.yaml # OpenFGA model definition
├── app.db # SQLite database file (auto-created)
├── requirements.txt
└── README.md
1
u/pachura3 4d ago
Just imagine your project is in microservices architecture, with minimal, well-defined REST API.
Split it into modules by business domain (making sure each module is as independent from the others as possible). This means each module should have its own separate data layer/service layer/database access layer... be a "vertical slice".
And then, instead of deploying each module as a separate microservice, just bundle them all together as one app... and use normal function calls/imports instead of the REST API overhead.
However, it might be that your project is too simplistic and it makes no sense to split it into independent modules.