# msdeep14/systemdesign-from-scratch architecture

> Architecture diagram of the GitHub repository msdeep14/systemdesign-from-scratch, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/msdeep14/systemdesign-from-scratch
- Repository: https://github.com/msdeep14/systemdesign-from-scratch

## Overview

PhotoZ is an educational photo-sharing social platform that evolves from an MVP into a more scalable application. Its central user journey is to publish photos and then see relevant photos in a personalized feed; the feed combines followed-user and community content with celebrity content. The sampled sources show feed assembly, Redis caching, photo and user data models, and asynchronous fan-out and notification work. Several web handlers, configuration details, and integrations are unsampled, so those links are left unverified rather than inferred as definite calls.

Main entry points: [`photoz/newsfeed/services.py`](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/newsfeed/services.py) (Feed assembly), [`photoz/bses/urls.py`](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/bses/urls.py) (Request routing), [`photoz/notifications/tasks.py`](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/notifications/tasks.py) (Notification tasks), [`photoz/newsfeed/tasks.py`](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/newsfeed/tasks.py) (Feed fan-out)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Web entry"]
  node_routing["Request routing<br/>[urls.py]"]
  node_photo_views["Photo actions<br/>[views.py]"]
  node_feed_views["Feed requests<br/>[views.py]"]
  node_user_views["Account actions<br/>[views.py]"]
  node_community_views["Community actions<br/>[views.py]"]
  node_notification_views["Notification views<br/>[views.py]"]
end

subgraph group_social["Social features"]
  node_photo_services["Photo services<br/>[services.py]"]
  node_photo_models["Photo records<br/>[models.py]"]
  node_feed_services["Feed assembly<br/>[services.py]"]
  node_user_services["Follow services<br/>[services.py]"]
  node_user_models["Profiles and follows<br/>[models.py]"]
  node_community_services["Community services<br/>[services.py]"]
  node_community_models["Community records<br/>[models.py]"]
  node_notification_models["Notification records<br/>[models.py]"]
end

subgraph group_async["Background work"]
  node_news_signals["Feed signals<br/>[signals.py]"]
  node_feed_tasks["Feed fan-out<br/>[tasks.py]"]
  node_notification_signals["Notification signals<br/>[signals.py]"]
  node_notification_tasks["Notification tasks<br/>[tasks.py]"]
  node_celery["Task workers<br/>[celery.py]"]
end

subgraph group_platform["Data and caching"]
  node_database[("Application database")]
  node_redis[("Redis cache")]
end

node_user(("PhotoZ user"))

node_user -.->|"sends requests"| node_routing
node_routing -.->|"routes to"| node_photo_views
node_routing -.->|"routes to"| node_feed_views
node_routing -.->|"routes to"| node_user_views
node_routing -.->|"routes to"| node_community_views
node_routing -.->|"routes to"| node_notification_views
node_feed_views -.->|"requests feed"| node_feed_services
node_photo_views -.->|"uses photo operations"| node_photo_services
node_feed_services -->|"gets followed users"| node_user_services
node_feed_services -->|"gets memberships"| node_community_services
node_feed_services -->|"gets photo IDs"| node_photo_services
node_feed_services -->|"reads and caches feeds"| node_redis
node_photo_services -->|"queries photos"| node_photo_models
node_photo_services -->|"caches photo data"| node_redis
node_user_services -->|"queries follows"| node_user_models
node_community_services -->|"queries memberships"| node_community_models
node_photo_models -->|"persists records"| node_database
node_user_models -->|"persists records"| node_database
node_community_models -->|"persists records"| node_database
node_notification_models -->|"persists records"| node_database
node_news_signals -->|"calls feed updates"| node_feed_services
node_news_signals -->|"dispatches tasks"| node_feed_tasks
node_feed_tasks -->|"gets followers"| node_user_services
node_feed_tasks -->|"updates feed caches"| node_feed_services
node_notification_signals -->|"dispatches tasks"| node_notification_tasks
node_notification_tasks -->|"creates notifications"| node_notification_models
node_notification_tasks -->|"loads photos"| node_photo_models
node_notification_tasks -->|"loads memberships"| node_community_models
node_feed_tasks -->|"runs as tasks"| node_celery
node_notification_tasks -->|"runs as tasks"| node_celery

click node_routing "https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/bses/urls.py"
click node_photo_views "https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/photos/views.py"
click node_feed_views "https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/newsfeed/views.py"
click node_user_views "https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/users/views.py"
click node_community_views "https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/communities/views.py"
click node_notification_views "https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/notifications/views.py"
click node_photo_services "https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/photos/services.py"
click node_photo_models "https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/photos/models.py"
click node_feed_services "https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/newsfeed/services.py"
click node_user_services "https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/users/services.py"
click node_user_models "https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/users/models.py"
click node_community_services "https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/communities/services.py"
click node_community_models "https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/communities/models.py"
click node_notification_models "https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/notifications/models.py"
click node_news_signals "https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/newsfeed/signals.py"
click node_feed_tasks "https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/newsfeed/tasks.py"
click node_notification_signals "https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/notifications/signals.py"
click node_notification_tasks "https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/notifications/tasks.py"
click node_celery "https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/bses/celery.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_routing,node_photo_views,node_feed_views,node_user_views,node_community_views,node_notification_views,node_user toneBlue
class node_photo_services,node_photo_models,node_feed_services,node_user_services,node_user_models,node_community_services,node_community_models,node_notification_models toneAmber
class node_news_signals,node_feed_tasks,node_notification_signals,node_notification_tasks,node_celery toneMint
class node_database,node_redis toneRose
```

## Components

### Web entry

- [Request routing](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/bses/urls.py): `photoz/bses/urls.py`
- [Photo actions](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/photos/views.py): `photoz/photos/views.py`
- [Feed requests](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/newsfeed/views.py): `photoz/newsfeed/views.py`
- [Account actions](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/users/views.py): `photoz/users/views.py`
- [Community actions](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/communities/views.py): `photoz/communities/views.py`
- [Notification views](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/notifications/views.py): `photoz/notifications/views.py`

### Social features

- [Photo services](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/photos/services.py): `photoz/photos/services.py`
- [Photo records](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/photos/models.py): `photoz/photos/models.py`
- [Feed assembly](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/newsfeed/services.py): `photoz/newsfeed/services.py`
- [Follow services](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/users/services.py): `photoz/users/services.py`
- [Profiles and follows](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/users/models.py): `photoz/users/models.py`
- [Community services](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/communities/services.py): `photoz/communities/services.py`
- [Community records](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/communities/models.py): `photoz/communities/models.py`
- [Notification records](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/notifications/models.py): `photoz/notifications/models.py`

### Background work

- [Feed signals](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/newsfeed/signals.py): `photoz/newsfeed/signals.py`
- [Feed fan-out](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/newsfeed/tasks.py): `photoz/newsfeed/tasks.py`
- [Notification signals](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/notifications/signals.py): `photoz/notifications/signals.py`
- [Notification tasks](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/notifications/tasks.py): `photoz/notifications/tasks.py`
- [Task workers](https://github.com/msdeep14/systemdesign-from-scratch/blob/main/photoz/bses/celery.py): `photoz/bses/celery.py`

### Data and caching

- **Application database**
- **Redis cache**

### Other components

- **PhotoZ user**

## Connections

- PhotoZ user → Request routing: sends requests
- Request routing → Photo actions: routes to
- Request routing → Feed requests: routes to
- Request routing → Account actions: routes to
- Request routing → Community actions: routes to
- Request routing → Notification views: routes to
- Feed requests → Feed assembly: requests feed
- Photo actions → Photo services: uses photo operations
- Feed assembly → Follow services: gets followed users (evidence: `photoz/newsfeed/services.py`)
- Feed assembly → Community services: gets memberships (evidence: `photoz/newsfeed/services.py`)
- Feed assembly → Photo services: gets photo IDs (evidence: `photoz/newsfeed/services.py`)
- Feed assembly → Redis cache: reads and caches feeds (evidence: `photoz/newsfeed/services.py`)
- Photo services → Photo records: queries photos (evidence: `photoz/photos/services.py`)
- Photo services → Redis cache: caches photo data (evidence: `photoz/photos/services.py`)
- Follow services → Profiles and follows: queries follows (evidence: `photoz/users/services.py`)
- Community services → Community records: queries memberships (evidence: `photoz/communities/services.py`)
- Photo records → Application database: persists records (evidence: `photoz/photos/models.py`)
- Profiles and follows → Application database: persists records (evidence: `photoz/users/models.py`)
- Community records → Application database: persists records (evidence: `photoz/communities/models.py`)
- Notification records → Application database: persists records (evidence: `photoz/notifications/models.py`)
- Feed signals → Feed assembly: calls feed updates (evidence: `photoz/newsfeed/signals.py`)
- Feed signals → Feed fan-out: dispatches tasks (evidence: `photoz/newsfeed/signals.py`)
- Feed fan-out → Follow services: gets followers (evidence: `photoz/newsfeed/tasks.py`)
- Feed fan-out → Feed assembly: updates feed caches (evidence: `photoz/newsfeed/tasks.py`)
- Notification signals → Notification tasks: dispatches tasks (evidence: `photoz/notifications/signals.py`)
- Notification tasks → Notification records: creates notifications (evidence: `photoz/notifications/tasks.py`)
- Notification tasks → Photo records: loads photos (evidence: `photoz/notifications/tasks.py`)
- Notification tasks → Community records: loads memberships (evidence: `photoz/notifications/tasks.py`)
- Feed fan-out → Task workers: runs as tasks (evidence: `photoz/newsfeed/tasks.py`)
- Notification tasks → Task workers: runs as tasks (evidence: `photoz/notifications/tasks.py`)
