Skip to main content
Mostafa Effati

About this platform

A working notebook for engineering practice

This is Mostafa Effati’s personal engineering platform: a place to turn hands-on work into clear writing, structured learning, and useful digital products.

Student collaborator

  • Ms Zahra Ehsani

    Former student · platform contributor

    Ms Zahra Ehsani worked on parts of this platform during her studies and brought thoughtful, practical contributions to its development. I'm glad to recognize her work here.

What you will find

  • Long-form articles, books, tutorials, and practical snippets.
  • Courses and guided learning paths built around real engineering work.
  • Case studies, open-source work, experiments, and product releases.

Built deliberately

  • A bilingual Persian and English experience with native RTL support.
  • Theme-aware, keyboard-friendly interfaces with a focused visual language.
  • Content and product changes developed as one versioned system.

The platform is continuously evolving. Some sections are complete products; others are active experiments that improve as the underlying work develops.

Organizations and Location

Modeling organizations, employees, and geo as domain entities — not free-text fields bolted onto User.
Mostafa Effati3 min readsoftware-architecture

Organizations and Location Belong in Identity

Once Person and User Account are separated, organization membership stops looking like a boolean on a profile row.

A person can be an employee of one company, a contractor of another, and a customer of a third — while using one or more user accounts. Location is not “address string on user” either: devices, people, and orgs all sit in geography.

This chapter is the context layer of the book: who someone is at work, and where things happen.

Organization is not a user with a flag

Organizations have their own lifecycle: industry, type, legal name, tax id, parent org for hierarchies, status history.

Organization
 ├── parent (optional hierarchy)
 ├── industry / type
 ├── legal identity fields
 └── status + history

Employees are the relationship between Person and Organization — with position, department, hire window, and org-scoped contacts.

That mirrors the citizenship lesson: membership is a relationship aggregate, not organization_id alone on Person forever.

Why employee contacts are separate

Work email and work phone are not the same channels as personal contacts on a user account. Modeling organization-employee contacts keeps verification and disclosure boundaries sane when someone leaves a company.

Location as a domain, not a text column

Geo in this service is structured:

LayerRole
Country / subdivision / cityReference data
LocationPoint-ish entity with encrypted coordinates
Search / proximity tokensBlind lookup without plaintext coords in indexes
Device session geo hintsRisk and context, not a second address book

Device sessions can reference country, subdivision, and city. Locations can store encrypted coordinates plus search tokens (rounded coords, proximity hashes) so “near me” features do not require decrypting the world on every query.

What this prevents

ShortcutBill that arrives later
company_name on usersMergers, legal names, multi-entity employers
One address text fieldNormalization, privacy, proximity search
Roles only on JWT claimsNo hire/leave history, no org tree
Orgs in another service too earlySplit-brain identity for the same human

Status history as a pattern

Persons, contacts, sessions, organizations, employees — many aggregates carry status plus a history table driven by shared trigger patterns. Identity is not only the current row; it is why and when state changed.

That matters for KYC, support, and security investigations more than for pretty profile pages.

Takeaway

Identity is the place where real-world structure meets system access. Organizations and geography are part of that structure. Pushing them out as afterthoughts recreates the flat users table — just with more JSON.

Next

The backend can be correct and the product still broken if the edge mishandles two cookie layers. The last chapter is the Next.js session edge.

Continue with Frontend Session Edge.

Related documents

Command menu

↑ ↓to move · Enter to select · Esc to close
Navigation
Actions

Press Esc to close · ⌘K to toggle