prez
prez copied to clipboard
Update codebase structure to improve maintenance
The below text originally taken from comment in https://github.com/RDFLib/prez/pull/168#pullrequestreview-1714228261.
I think the PR is fine for now as it addresses the immediate issues with the way we run tests. Nice work! 🎉 I can see that the tests run around 4 times faster, which is a nice bonus.
A follow-up to improve the structure of the codebase for long-term maintenance can look something like this:
/
├── repositories/
│ ├── __init__.py
│ ├── remote_sparql.py
│ ├── pyoxigraph.py
│ └── oxrdflib.py
├── services/
│ ├── __init__.py
│ ├── object.py
│ ├── listing.py
│ └── etc...
└── routers/
├── __init__.py
├── object.py
├── listing.py
├── sparql.py
├── vocprez.py
├── catprez.py
└── spaceprez.py
- Repositories are the interfaces to the data store.
- Services are the business logic for each of facets of functionality within Prez. They only contain business logic and interact with the data store through a repository object.
- Routers are the API endpoints of Prez. They are the entrypoints to each facet of business logic of Prez and only deal with the HTTP layer. The service and repo objects are injected via FastAPI's DI.
I think by having these three layers at a minimum will allow us all to conceptually understand Prez and its implementation details a bit clearer.
Anyway, I think this can probably be followed up in a separate PR as it's more maintenance-related. If you agree with the above's proposed structure, I can create an issue and reference this PR's comment.