Prompt
I'm building a B2B2C platform and need a customer identity layer across multiple apps
Latest observation
A customer identity layer for a B2B2C platform usually needs to unify people, companies, and app-specific accounts across multiple products while preserving tenancy, consent, and security.
Core goal
You want one identity system that can answer:
- Who is this person?
- Which company do they belong to?
- What apps can they access?
- What is their role in each company/app?
- How do we link logins from different apps/channels to the same person?
Recommended identity model
1) Global person identity
Create a canonical Person record that represents the real human.
Person
person_id(global immutable UUID)- name fields
- primary email(s)
- phone(s)
- verified status
- locale/timezone
- marketing consent
- authentication references
- lifecycle status
This is the anchor across apps.
2) Organization / account / tenant
Model the business customer as Organization.
Organization
org_id- legal/business name
- billing profile
- status
- parent/child relationships if needed
3) Membership / relationship
A person can belong to one or many organizations.
Membership
membership_idperson_idorg_id- role(s)
- status
- source app/channel
- start/end dates
- permissions/entitlements
This is where B2B2C complexity usually lives.
4) App-specific identity links
Each app may have its own user ID, but you link it back to the same canonical person.
IdentityLink
identity_link_idperson_idprovider(Google, Microsoft, email/password, SSO, SMS, etc.)subject_id/ external user idapp_id- confidence / verification level
- created_at
This lets multiple apps share one identity graph without forcing identical user models.
Multi-app architecture pattern
Option A: Central Identity Service + federated apps
Best for most B2B2C platforms.
- One central identity service issues tokens
- Apps delegate auth to it via OIDC/OAuth2
- Each app stores only app-local profile data
- Core identity, consent, and membership stay centralized
Pros
- Unified customer view
- Easier SSO across apps
- Consistent consent/compliance
- Easier account recovery
Cons
- More upfront platform work
- Needs strong tenancy and authorization design
Option B: Shared identity database, app-owned auth
Less ideal, but workable if apps are already separate.
- Apps manage auth locally
- A shared identity registry maps records across apps
- Background sync keeps profiles aligned
Pros
- Less disruptive initially
- Easier migration from legacy apps
Cons
- Drift/inconsistency
- Harder to guarantee SSO and consent accuracy
Key design principles
1) Separate identity from authorization
Identity says who. Authorization says what they can do.
Use:
- Identity service for authentication and person/org linking
- Policy/authorization layer for roles, permissions, entitlements
2) Use stable, opaque IDs
Do not use email as the primary key. Emails change.
Use:
- UUIDs or ULIDs for
person_id,org_id,membership_id
3) Support many identifiers per person
A person may have:
- phone
- enterprise SSO subject
- social login
- magic link
- legacy app username
4) Handle multiple roles and multiple orgs
One person may be:
- consumer in one org
- admin in another
- viewer in a third
Model roles at the membership level.
5) Build for merge and deduplication
You will eventually need to merge duplicate people.
Have:
- survivorship rules
- manual review flow
- audit log of merges/splits
- immutable historical references
Suggested data model
Minimal version:
personsorganizationsmembershipsidentity_linksauthentication_methodsconsentsapp_profilesaudit_events
If you need enterprise B2B features:
rolespermissionsgroupsentitlementsdelegated_adminsinvites
Login and SSO flow
Typical flow:
- User logs into App A
- App A redirects to central IdP
- IdP authenticates user
- IdP returns token with
person_id - App A looks up memberships/roles for that
person_id - App A authorizes actions based on org context
If the same user opens App B, they should get the same person_id and possibly seamless SSO.
Important B2B2C considerations
Tenant context
A user may belong to multiple customers. Every request should include:
- active
org_id - active app
- possibly active workspace/project/account
Consent and privacy
In B2B2C, consent may differ by org and channel. Track:
- marketing consent
- transactional consent
- data sharing consent
- revocation timestamps
- jurisdiction/legal basis
Data minimization
Don’t expose all identity data to every app. Use scopes and claims carefully.
Cross-app profile consistency
Decide which fields are:
- global canonical
- org-specific
- app-specific
Example:
- global: name, primary email, verified phone
- org-specific: job title, department, role
- app-specific: preferences, UI settings
API surface to consider
Identity API
POST /personsGET /persons/{id}PATCH /persons/{id}POST /identity-linksPOST /merge-persons
Org API
POST /organizationsGET /organizations/{id}POST /membershipsPATCH /memberships/{id}
Auth API
- OIDC discovery
/authorize/token/userinfo/introspect
Admin API
- invite user
- assign role
- deactivate user
- audit log
- consent management
Practical recommendation
For a B2B2C platform, I’d usually recommend:
- Central identity service
- Canonical Person model
- Organization + Membership model
- IdentityLink table
- OIDC/OAuth2 for all apps
- Central consent and audit logging
- App-specific profile overlays
- Explicit active org selection in session/token
Common pitfalls
- Using email as the unique ID
- Mixing auth logic into every app
- Not modeling memberships separately
- Ignoring duplicate identity resolution
- Failing to support multiple org affiliations
- Treating consent as a global boolean
- Hardcoding roles instead of policy-based access
If you want, I can next provide one of these:
- a concrete database schema
- an OIDC-based architecture diagram
- a Kafka/event-driven identity sync design
- a migration plan for existing apps
- a reference API spec for the identity layer