# minhelly/fakebook architecture

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

- Interactive diagram: https://gitdiagram.com/minhelly/fakebook
- Repository: https://github.com/minhelly/fakebook

## Overview

Fakebook is a microservices social network. A user signs in through the React app and Keycloak, then uses the gateway-backed APIs for profiles, friendships, posts, media, comments, reactions, and a personalized feed. Post events drive feed fan-out and comment-side post-cache updates; realtime events reach the gateway and browser. README-level infrastructure links are shown where documented; the supplied source excerpts are partial, so uncertain implementation-level calls are omitted.

Main entry points: [`gateway/src/main/java/com/minh/fakebook/gateway`](https://github.com/minhelly/fakebook/tree/staging/gateway/src/main/java/com/minh/fakebook/gateway) (API gateway), [`frontend/src/App.tsx`](https://github.com/minhelly/fakebook/blob/staging/frontend/src/App.tsx) (React application), [`userService/src/main/java/com/minh/fakebook/user`](https://github.com/minhelly/fakebook/tree/staging/userService/src/main/java/com/minh/fakebook/user) (Profiles and friends), [`commentService/src/main/java/com/minh/fakebook/comment`](https://github.com/minhelly/fakebook/tree/staging/commentService/src/main/java/com/minh/fakebook/comment) (Comments and reactions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User experience"]
  node_frontend["React application<br/>[App.tsx]"]
  node_browser_realtime["Realtime browser client<br/>[realtimeService.ts]"]
end

subgraph group_edge["Gateway and identity"]
  node_gateway["API gateway"]
  node_keycloak["Keycloak IAM"]
  node_auth["Auth service"]
end

subgraph group_social["Social domain services"]
  node_user["Profiles and friends"]
  node_post["Posts and reactions"]
  node_comment["Comments and reactions"]
  node_media["Media service"]
  node_feed["Personalized feed"]
end

subgraph group_events["Events and realtime"]
  node_kafka["Kafka event stream"]
  node_realtime["Realtime event hub"]
end

subgraph group_state["Persistence and media"]
  node_mariadb[("Service databases")]
  node_redis[("Redis cache")]
  node_cloudinary["Cloudinary storage"]
end

node_person(("Social user"))

node_person -->|"uses"| node_frontend
node_frontend -->|"authenticates"| node_keycloak
node_frontend -->|"calls APIs"| node_gateway
node_gateway -->|"routes requests"| node_user
node_gateway -->|"routes requests"| node_post
node_gateway -->|"routes requests"| node_comment
node_gateway -->|"routes requests"| node_media
node_gateway -->|"routes requests"| node_feed
node_gateway -.->|"routes requests"| node_auth
node_post -->|"publishes post events"| node_kafka
node_kafka -->|"delivers post events"| node_feed
node_kafka -->|"delivers post events"| node_comment
node_kafka -.->|"delivers events"| node_realtime
node_realtime -->|"streams updates"| node_browser_realtime
node_frontend -->|"subscribes"| node_browser_realtime
node_comment -.->|"checks friendship"| node_user
node_user -->|"reads and writes"| node_mariadb
node_post -->|"reads and writes"| node_mariadb
node_comment -->|"reads and writes"| node_mariadb
node_media -->|"reads and writes"| node_mariadb
node_feed -->|"reads and writes"| node_mariadb
node_user -->|"caches data"| node_redis
node_feed -->|"caches timeline"| node_redis
node_media -.->|"stores files"| node_cloudinary

click node_frontend "https://github.com/minhelly/fakebook/blob/staging/frontend/src/App.tsx"
click node_gateway "https://github.com/minhelly/fakebook/tree/staging/gateway/src/main/java/com/minh/fakebook/gateway"
click node_auth "https://github.com/minhelly/fakebook/tree/staging/authService/src/main/java/com/minh/fakebook/auth"
click node_user "https://github.com/minhelly/fakebook/tree/staging/userService/src/main/java/com/minh/fakebook/user"
click node_post "https://github.com/minhelly/fakebook/tree/staging/postService/src/main/java/com/minh/fakebook/post"
click node_comment "https://github.com/minhelly/fakebook/tree/staging/commentService/src/main/java/com/minh/fakebook/comment"
click node_media "https://github.com/minhelly/fakebook/tree/staging/mediaService/src/main/java/com/minh/fakebook/media"
click node_feed "https://github.com/minhelly/fakebook/tree/staging/feedService/src/main/java/com/minh/fakebook/feed"
click node_realtime "https://github.com/minhelly/fakebook/tree/staging/gateway/src/main/java/com/minh/fakebook/gateway/realtime"
click node_browser_realtime "https://github.com/minhelly/fakebook/blob/staging/frontend/src/services/realtimeService.ts"

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_frontend,node_browser_realtime,node_person toneBlue
class node_gateway,node_keycloak,node_auth toneAmber
class node_user,node_post,node_comment,node_media,node_feed toneMint
class node_kafka,node_realtime toneRose
class node_mariadb,node_redis,node_cloudinary toneIndigo
```

## Components

### User experience

- [React application](https://github.com/minhelly/fakebook/blob/staging/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Realtime browser client](https://github.com/minhelly/fakebook/blob/staging/frontend/src/services/realtimeService.ts): `frontend/src/services/realtimeService.ts`

### Gateway and identity

- [API gateway](https://github.com/minhelly/fakebook/tree/staging/gateway/src/main/java/com/minh/fakebook/gateway): `gateway/src/main/java/com/minh/fakebook/gateway`
- **Keycloak IAM**
- [Auth service](https://github.com/minhelly/fakebook/tree/staging/authService/src/main/java/com/minh/fakebook/auth): `authService/src/main/java/com/minh/fakebook/auth`

### Social domain services

- [Profiles and friends](https://github.com/minhelly/fakebook/tree/staging/userService/src/main/java/com/minh/fakebook/user): `userService/src/main/java/com/minh/fakebook/user`
- [Posts and reactions](https://github.com/minhelly/fakebook/tree/staging/postService/src/main/java/com/minh/fakebook/post): `postService/src/main/java/com/minh/fakebook/post`
- [Comments and reactions](https://github.com/minhelly/fakebook/tree/staging/commentService/src/main/java/com/minh/fakebook/comment): `commentService/src/main/java/com/minh/fakebook/comment`
- [Media service](https://github.com/minhelly/fakebook/tree/staging/mediaService/src/main/java/com/minh/fakebook/media): `mediaService/src/main/java/com/minh/fakebook/media`
- [Personalized feed](https://github.com/minhelly/fakebook/tree/staging/feedService/src/main/java/com/minh/fakebook/feed): `feedService/src/main/java/com/minh/fakebook/feed`

### Events and realtime

- **Kafka event stream**
- [Realtime event hub](https://github.com/minhelly/fakebook/tree/staging/gateway/src/main/java/com/minh/fakebook/gateway/realtime): `gateway/src/main/java/com/minh/fakebook/gateway/realtime`

### Persistence and media

- **Service databases**
- **Redis cache**
- **Cloudinary storage**

### Other components

- **Social user**

## Connections

- Social user → React application: uses
- React application → Keycloak IAM: authenticates
- React application → API gateway: calls APIs
- API gateway → Profiles and friends: routes requests
- API gateway → Posts and reactions: routes requests
- API gateway → Comments and reactions: routes requests
- API gateway → Media service: routes requests
- API gateway → Personalized feed: routes requests
- API gateway → Auth service: routes requests
- Posts and reactions → Kafka event stream: publishes post events
- Kafka event stream → Personalized feed: delivers post events
- Kafka event stream → Comments and reactions: delivers post events
- Kafka event stream → Realtime event hub: delivers events
- Realtime event hub → Realtime browser client: streams updates
- React application → Realtime browser client: subscribes
- Comments and reactions → Profiles and friends: checks friendship
- Profiles and friends → Service databases: reads and writes
- Posts and reactions → Service databases: reads and writes
- Comments and reactions → Service databases: reads and writes
- Media service → Service databases: reads and writes
- Personalized feed → Service databases: reads and writes
- Profiles and friends → Redis cache: caches data
- Personalized feed → Redis cache: caches timeline
- Media service → Cloudinary storage: stores files
