You are asked to architect the notification and messaging backend for a group chat. A single group can hold up to 500 members, and whenever someone opens the conversation, the most recent 30 to 40 messages must appear with minimal delay.
Walk through the end-to-end design and sketch a system architecture diagram that shows the main components and how messages and notifications flow between them.
As part of the design, explain in detail how you would apply an LRU cache and Redis to make loading those latest messages fast: what each layer holds, how the two work together, and how they stay consistent with the underlying message storage.