Fred Montier Posted March 9 Posted March 9 Exploring Supabase and the Firedac power really got my attention recently Using Supabase with uniGUI is actually a very good architecture for modern Delphi web apps, but the best approach depends on how much you want Supabase to do. Supabase can act as: Database (PostgreSQL) Authentication server Storage Realtime API REST API Edge Functions uniGUI is server-side Delphi, so you normally don't want the browser calling Supabase directly. The best practice is to let uniGUI be the backend gateway. Below are the 3 architectures I recommend, from simplest to most scalable. 1️⃣ Direct PostgreSQL connection (Best for internal systems) Since Supabase is just managed PostgreSQL, the simplest solution is: uniGUI (Delphi) │ │ FireDAC │ Supabase PostgreSQL Implementation Use FireDAC PostgreSQL driver to connect directly. Example: FDConnection1.DriverName := 'PG'; FDConnection1.Params.Values['Server'] := 'db.supabase-project.supabase.co'; FDConnection1.Params.Values['Database'] := 'postgres'; FDConnection1.Params.Values['User_Name'] := 'postgres'; FDConnection1.Params.Values['Password'] := 'your-password'; FDConnection1.Connected := True; Advantages ✔ fastest ✔ simplest ✔ no REST overhead ✔ full SQL control Disadvantages ⚠ requires opening DB connection from server ⚠ bypasses Supabase auth and policies 💡 Best for: internal systems dashboards admin tools 2️⃣ Use Supabase REST API (Best for SaaS / public apps) Supabase automatically exposes tables via PostgREST. Browser │ uniGUI server │ HTTP REST │ Supabase API │ PostgreSQL Delphi calls the API using TNetHTTPClient. Example: var Http: TNetHTTPClient; Resp: IHTTPResponse; begin Http := TNetHTTPClient.Create(nil); Http.CustomHeaders['apikey'] := 'SUPABASE_ANON_KEY'; Resp := Http.Get( 'https://project.supabase.co/rest/v1/users' ); Memo1.Lines.Text := Resp.ContentAsString; end; Advantages ✔ respects Supabase Row Level Security ✔ good for multi-tenant SaaS ✔ no direct DB exposure ✔ easy to scale Disadvantages ⚠ slower than SQL ⚠ JSON parsing required 3️⃣ Hybrid (My recommended architecture) This is what I normally recommend: Browser │ uniGUI │ FireDAC (SQL) │ Supabase PostgreSQL │ Supabase services ├ Auth ├ Storage └ Realtime Use: Feature Method Database FireDAC Auth Supabase Auth API Files Supabase Storage Realtime Supabase Realtime This way: SQL remains fast you still benefit from Supabase services 4️⃣ Supabase Authentication with uniGUI Let Supabase handle login. Flow: User → uniGUI login form ↓ uniGUI calls Supabase Auth API ↓ JWT token returned ↓ Store token in UniSession Example request: POST https://project.supabase.co/auth/v1/token Body: { "email": "user@email.com", "password": "123456" } 5️⃣ Storage (great for uniGUI) Instead of storing files locally, use: Supabase Storage Example upload: POST /storage/v1/object/mybucket/file.pdf Benefits: ✔ CDN ✔ scalable ✔ secure 6️⃣ Realtime (very interesting with uniGUI) Supabase uses: Phoenix Channels over WebSockets. You can integrate realtime events into uniGUI for: chat notifications live dashboards collaborative editing 7️⃣ My recommended stack for uniGUI If I were building a modern uniGUI SaaS today: Frontend uniGUI Backend Delphi / FireDAC Database Supabase PostgreSQL Services Supabase Auth Supabase Storage Supabase Realtime 8️⃣ Pro tip (very important) Disable public API access if you use SQL directly. Instead use: service role key server side only Never expose Supabase keys to browser. 💡 My honest opinion Supabase + uniGUI is one of the best combinations today because: PostgreSQL is extremely powerful Supabase replaces Firebase Delphi remains extremely productive 2 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.