mikestefanello / pagoda

Rapid, easy full-stack web development starter kit in Go
MIT License
1.39k stars 94 forks source link

PocketBase integration into the administration area #73

Open viktarovich opened 4 days ago

viktarovich commented 4 days ago

I really like what you're doing. I saw that you are going to add an admin part to your starter.

Have you thought about integrating a ready-made solution into starter like https://pocketbase.io/?

I get the impression that it could complement your solution well.

question

mikestefanello commented 4 days ago

Thank you! That's much appreciated.

It's funny you mention Pocketbase. I came across it somewhat recently and took a pretty deep dive into the project and was incredibly impressed. They really did an amazing job with it. That was part of my motivation to switch this project to use SQLite. I also had the same exact thought as you - including this admin panel would be a gigantic improvement. If there's one thing I would most want to include it would be exactly that.

I started on a fork of this project that used Pocketbase as the backend (replacing Ent, custom auth, etc) just to see how it would go. It was a bit difficult to get something working as it's meant to be API-only, it uses the beta v5 of Echo, and extending it from an entity perspective is easy from the UI but not at all easy via code (as far as I can tell). It's possible I didn't spend enough time on it but I felt the disconnect between entities you try to define in code (so you can have the full control you'd want if you were developing more than a bare-bones CRUD app) and those you define via the UI/config was too large and difficult to deal with. I couldn't find a way to even sync up validation logic that I put in code vs the limited set of controls you have via the UI. I can't remember the details but I also faced issues using the hooks, access, querying, etc, with in-code entities. In the end, I felt like it was too frameworky (for lack of a better word) to feel comfortable enough really building on top of. Also, dealing with SSR for everything but the admin panel, which needs to remain API-based, was also a headache. For instance, Echo only has one error handler you can register and for the main app we'd need to return HTML; but that breaks all errors the API returns (which wants JSON).

I'm all for any ideas or proposals that can leverage Pocketbase or something else (custom or not) to provide some form of an admin panel. There's probably no good way to make it completely dynamic/automatic the way Pocketbase does (entity types, filtering/paging/search, forms, validation, access control, etc), but maybe there's a way to provide the groundwork so it's easy enough for someone to plug in their own entities. If you have any thoughts, please let me know.

viktarovich commented 4 days ago

Thanks for the quick reply.

It looks like that if to use PocketBase, then only as a convenient UI for database schema generation, migration tool and possibly database backup. There was a question asked here about this: https://github.com/pocketbase/pocketbase/discussions/489 The author suggested disabling the creation of new tables/collections to eliminate disconnect between entities in production.

Then for example the Ent can generate Ent schemas from the existing SQL database, as described here: https://entgo.io/blog/2021/10/11/generating-ent-schemas-from-existing-sql-databases/

However for me it looks complicated and we lose many PocketBase functions.

mikestefanello commented 2 days ago

One thing we should look in to is how far we can get with Ent alone. I haven't tried so I'm curious if we can dynamically list out all entity types and perhaps create pages/lists of each entity in order to at least create some starting point of an admin dashboard. Or maybe make it really easy to register which entities types you want to appear on the dashboard (then we don't need everything to be so dynamic). Access control, forms, validation, etc, is a challenge but let's start small.