Repository navigation
Description
I've described the following separation of concerns in our stack:
-
Authentication/Authorisation functions including storage of personally identifiable information such as social security (NIF), Phone Number, email, (hashed) password, IP address and location data, should be stored on a logically separate and highly secured database instance which regular engineers never need to touch. This adds much needed additional security for mitigating personal data breaches.
-
Business Logic is contained within the Web App which connects with Auth whenever a user data, roles or permissions query is required. All functionality described in the Technical Brief can (should) be built this way. All “Transaction data” (owned by the business) references a user_id owned by Auth service.
-
Analytics & Logging - the lifeblood of any business - is the 3rd separate service. We recommend running an instance of plausible.io or paying for the hosted service (€19/month), it includes all of the core features of Google Analytics without the privacy concerns of leaking personal data. Treating Analytics data as logically separate from Business Logic is best practice because it is not the core functionality of the business so the service should not impact response times of requests for a desk/booking.
-
Comms Service - We deploy a separate Comms Service for handling sending email and notifications. This uses 3rd-party service such as AWS or Twilio to handle the delivery. Having Comms separate from App means engineers never have the Twilio or AWS API Keys on their machine and cannot accidentally leak them (huge headache/cost). The App code just calls the service with a simple request: “Send Booking Confirmed email to user_id:123”.
-
API requests are handled by the Web App without incurring additional complexity; the same endpoints that render HTML can render JSON. The same Auth and WebSockets used by the Web App can be consumed natively by the Mobile Client. When the traffic volume justifies spinning up a dedicated API server, it’s simply an additional instance without any incremental devops overhead.
Todo
- Create a Basic Diagram that illustrates this separation of services.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
nelsonic commentedon Jul 31, 2026
Gonna pick this up in the morning.
But first ... 🛌
nelsonic commentedon Aug 4, 2026
Made a minor detour to update this repo: https://github.com/dwyl/learn-phoenix 🧑💻 ⏳
nelsonic commentedon Aug 7, 2026
Spent way too long refreshing my memory on
mermaiddiagrams to create this:--- config: theme: 'base' themeVariables: primaryColor: '#CEF4EE' primaryTextColor: '#556A72' lineColor: '#F8B229' secondaryColor: '#006100' flowchart: defaultRenderer: "elk" --- graph BT WebClient["<h3>Web Client</h3>(All Devices)"] MobileApp["<h4>Native Mobile App</h4><br/>(iOS / Android)"] WebClient <--> WebApp MobileApp <--> WebApp WebApp["<h2>Phoenix Web App</h2><br /> Handles all Web/API requests involving <b>Business Logic</b>. Serves HTTP, JSON and WebSocket Requests<br/>"] WebApp --> Auth["<h2>Auth</h2><br /> Handles Authentication, Authorization, Permissions via Role-based Access Control"] Auth --> authDb[(Auth DB)] authDb --> authDb2[(Auth Backup)] Auth <--> Comms WebApp <--> Comms["<h2>Comms Service</h2><br /><b>3<sup>rd</sup> Party Services Send Email, SMS & Notifications</b>. Tracks deliverability, open & click-through rate. Dashboards display stats + insights."] Comms <--> AWS["<h3>AWS SES/SNS</h3> Sends Email, SMS and Mobile Notifications"] Comms --> comDb[(Comms DB)] comDb --> backDb WebApp <--> Analytics["<h2>Analytics + Logs</h2> Captures anonymous web/mobile analytics events and logs. Renders metrics dashboards."] Analytics --> anaDb[(Analytics <br />+ Logs DB)] anaDb --> backDb WebApp --> mainDb[("<h2>Main DB</h2>")] mainDb --> backDb[("<h2>Backup DB</h2> Read-only Replica")] classDef entryPoint stroke:#818cf8,fill:#eef2ff classDef WebApp stroke:#2dd4bf,fill:#f0fdfa classDef process stroke:#a78bfa,fill:#f5f3ff classDef tool stroke:#fb923c,fill:#fff7ed classDef db stroke:#336791,fill:#e3edf5 classDef aws stroke:#252F3E,fill:#ffc267 class WebClient,MobileApp entryPoint class WebApp WebApp class Auth process class Comms,Analytics tool class authDb,authDb2,mainDb,backDb,anaDb,comDb db class AWS, awsnelsonic commentedon Aug 7, 2026
Sadly, the
Mermaidrenderer on mylocalhost(insideVSCode) renders the diagram much better thanGitHub:So I think I'm going to have to re-do it manually as another Google Doc. 😢
nelsonic commentedon Aug 8, 2026
Really wanted the
mermaiddiagram to be decent.But sadly, had to resort to
Google Drawing:https://docs.google.com/drawings/d/1ach2TPrH4Qhnvv1GjfU3lru-zT4ZpJEDjLdBliEm_9A/edit
This is what I had in-mind.
@iteles / @LuchoTurtle please review and LMK if you understand what all the "Boxes and Arrows" mean or if anything is unclear. 💬 🙏
add services.md to show separation of App and Services closes #172
LuchoTurtle commentedon Aug 8, 2026
Looks great 🙏 although I'd recommend changing the replicas databases colour scheme so it's easier to differentiate
add explanation of services for #172
nelsonic commentedon Aug 8, 2026
@LuchoTurtle good feedback. Going to make them lighter blue to differentiate. 🧑🎨 🖌️ ⏳ BRB.
nelsonic commentedon Aug 8, 2026
@LuchoTurtle thanks again for the feedback. I've made the replicas lighter for clarity:
update services diagram in response to @LuchoTurtle feedback #172
Merge pull request #174 from dwyl/separation-of-concerns-diagram-#172