System Architecture

๐Ÿงฉ Designing Staff Permissions for Shopify-like Stores: Redis, Postgres, or MongoDB?

Published on November 13, 2025

๐Ÿ“– 15 min readโ€ข๐Ÿ—๏ธ Architectureโ€ขโšก Database

Modern SaaS platforms like Shopify allow multiple staff members to manage stores with fine-grained access controls. Admins, managers, support teams โ€” each role needs the right balance between access, security, and performance.

When designing such a system, two questions immediately appear:

  1. 1. How do we authenticate staff (who are they)?
  2. 2. How do we authorize them (what can they do)?

And the big architectural question behind all of this:
Where do we store and fetch those permissions โ€” Redis, SQL, or MongoDB?

In this post, we'll explore how Shopify-like platforms structure staff permissions, compare three backend options โ€”Redis-only, Postgres/MySQL + Redis, and MongoDB + Redis โ€” and finish with a practical recommendation based on cost, performance, and durability.

โš™๏ธ How Staff Authentication & Authorization Work (Shopify Style)

Staff Sign-In
Email, SSO, OAuth
Access Token/JWT
Permission Lookup
Role + Store Scope
Business Action
Read/Write Products, Orders, etc.
  • โ€ข Authentication (AuthN) confirms identity โ€” typically via password, OAuth, or SSO.
  • โ€ข Authorization (AuthZ) defines access โ€” via roles and permissions.
  • โ€ข Audit trail tracks every permission or role change.

Shopify applies Role-Based Access Control (RBAC) layered with Store Scope. Each staff user belongs to one or more roles that define permissions (e.g., read_orders, write_products).

๐Ÿงฑ Design Requirements

When building this for your own SaaS or retail platform, these are your non-negotiables:

Read-heavy: permission checks happen on every request
Write-light: roles change rarely
Strong consistency: permission updates must reflect immediately
Low latency: can't wait 50ms to check permissions on every API call
Durable: data must survive restarts
Auditable: track who changed what and when

๐Ÿš€ Option 1: Redis-Only

API Server
Redis Store
store:{storeId}:user:{userId}:perms

โœ… Pros

  • โ€ข Ultra-fast reads (sub-millisecond)
  • โ€ข Simple โ€” no joins or ORM needed
  • โ€ข Great for prototypes or edge-cache style setups

โŒ Cons

  • โ€ข Durability risk (Redis is memory-first)
  • โ€ข No query power โ€” can't easily list "all staff with X permission"
  • โ€ข Higher memory costs at scale
  • โ€ข Recovery complexity if data lost

๐Ÿงฉ Option 2: Postgres/MySQL + Redis (Recommended)

API Server
Redis Cache
Postgres/MySQL
Durable Storage
Cache Miss โ†’ Database โ†’ Cache โ†’ API

โœ… Pros

  • โ€ข Full durability + ACID transactions
  • โ€ข Easy to audit and query
  • โ€ข Low-latency reads (cached)
  • โ€ข Cost-efficient (Redis only holds hot data)

โŒ Cons

  • โ€ข Cache invalidation logic required
  • โ€ข Slightly more complex architecture

๐ŸŒฟ Option 3: MongoDB + Redis

โœ… Pros

  • โ€ข Flexible schema โ€” evolve quickly
  • โ€ข Ideal for denormalized permission models
  • โ€ข Easier to embed custom scopes per store

โŒ Cons

  • โ€ข Harder to run relational queries
  • โ€ข Multi-document transactions slower
  • โ€ข More ops complexity (clusters, sharding)

๐Ÿ’พ Schema Example (Postgres + Redis)

CREATE TABLE roles (
  id UUID PRIMARY KEY,
  name TEXT NOT NULL
);

CREATE TABLE permissions (
  id TEXT PRIMARY KEY
);

CREATE TABLE role_permissions (
  role_id UUID REFERENCES roles(id),
  permission_id TEXT REFERENCES permissions(id),
  PRIMARY KEY(role_id, permission_id)
);

CREATE TABLE store_role_assignments (
  store_id UUID,
  user_id UUID,
  role_id UUID REFERENCES roles(id),
  scope JSONB,
  PRIMARY KEY(store_id, user_id)
);

Redis Key Pattern

store:{storeId}:user:{userId}:perms

JSON Value Example

{
  "permissions": ["read_orders", "write_customers"],
  "version": 3,
  "expires_in": 300
}

๐Ÿ’ฐ Cost & Performance Snapshot

OptionDurabilityRead SpeedQuery PowerCostRecommended For
Redis-onlyLowโšกโšกโšก๐Ÿ”ธ Minimal๐Ÿ’ธ High (RAM)Prototypes
Postgres/MySQL + RedisHighโšกโšกโœ… Strong๐Ÿ’ฐ BalancedProduction
MongoDB + RedisHighโšกโšกโš™๏ธ Medium๐Ÿ’ฐ+Flexible schemas

๐Ÿ”’ Security Tips

Enforce checks server-side only
Encrypt data in transit and at rest
Rotate access tokens frequently
Log every permission change
Monitor Redis hit ratio & latency

๐Ÿงญ Final Recommendation

โœ… Postgres + Redis = Durability + Performance + Cost Efficiency

Caching is your speed layer
SQL is your truth layer
Durability is your safety net

Together, they form a scalable, Shopify-grade permission backbone.

๐Ÿงฑ MBTEdge Takeaway

Designing staff authorization isn't about the fastest tech โ€” it's about balancing correctness, consistency, and cost.

Author: MBTEdge Engineering Team

Tags: #Shopify #Redis #Postgres #MongoDB #Architecture #MBTEdge #SaaS #AuthZ #RBAC

Need Expert System Architecture?

Our team specializes in designing scalable SaaS architectures, database optimization, and permission systems. Let us help you build robust, secure applications.