# david-fernando/medium-posts-api architecture

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

- Interactive diagram: https://gitdiagram.com/david-fernando/medium-posts-api
- Repository: https://github.com/david-fernando/medium-posts-api

## Overview

Medium Posts API exposes a GET endpoint that accepts a Medium username and returns post metadata as JSON. The handler fetches RSS-converted data through rss2json, then formats post fields, sanitizes descriptions, and extracts thumbnails before responding. The README documents the endpoint and placeholder-image behavior; the graph follows the sampled implementation and does not infer the external service’s internal fetching behavior.

Main entry points: [`pages/api/[usermedium].ts`](https://github.com/david-fernando/medium-posts-api/blob/main/pages/api/%5Busermedium%5D.ts) (Username endpoint), [`utils/returnJsonPosts.tsx`](https://github.com/david-fernando/medium-posts-api/blob/main/utils/returnJsonPosts.tsx) (Post formatter), [`utils/returnJsonData.tsx`](https://github.com/david-fernando/medium-posts-api/blob/main/utils/returnJsonData.tsx) (RSS data fetch), [`utils/editText.tsx`](https://github.com/david-fernando/medium-posts-api/blob/main/utils/editText.tsx) (Description cleaner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API"]
  node_endpoint["Username endpoint<br/>[&#91;usermedium&#93;.ts]"]
  node_rss_fetch["RSS data fetch<br/>[returnJsonData.tsx]"]
end

subgraph group_formatting["Post formatting"]
  node_post_formatter["Post formatter"]
  node_description_cleaner["Description cleaner<br/>[editText.tsx]"]
  node_thumbnail_extractor["Thumbnail extractor"]
end

node_client(("API client"))
node_rss2json["rss2json API"]

node_client -->|"requests GET"| node_endpoint
node_endpoint -->|"fetches posts"| node_rss_fetch
node_rss_fetch -->|"requests conversion"| node_rss2json
node_endpoint -->|"formats response"| node_post_formatter
node_post_formatter -->|"cleans descriptions"| node_description_cleaner
node_post_formatter -->|"extracts images"| node_thumbnail_extractor
node_endpoint -->|"returns JSON"| node_client

click node_endpoint "https://github.com/david-fernando/medium-posts-api/blob/main/pages/api/%5Busermedium%5D.ts"
click node_rss_fetch "https://github.com/david-fernando/medium-posts-api/blob/main/utils/returnJsonData.tsx"
click node_post_formatter "https://github.com/david-fernando/medium-posts-api/blob/main/utils/returnJsonPosts.tsx"
click node_description_cleaner "https://github.com/david-fernando/medium-posts-api/blob/main/utils/editText.tsx"
click node_thumbnail_extractor "https://github.com/david-fernando/medium-posts-api/blob/main/utils/returnThumbnail.tsx"

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_endpoint,node_rss_fetch,node_client toneBlue
class node_post_formatter,node_description_cleaner,node_thumbnail_extractor toneAmber
class node_rss2json toneMint
```

## Components

### API

- [Username endpoint](https://github.com/david-fernando/medium-posts-api/blob/main/pages/api/%5Busermedium%5D.ts): `pages/api/[usermedium].ts`
- [RSS data fetch](https://github.com/david-fernando/medium-posts-api/blob/main/utils/returnJsonData.tsx): `utils/returnJsonData.tsx`

### Post formatting

- [Post formatter](https://github.com/david-fernando/medium-posts-api/blob/main/utils/returnJsonPosts.tsx): `utils/returnJsonPosts.tsx`
- [Description cleaner](https://github.com/david-fernando/medium-posts-api/blob/main/utils/editText.tsx): `utils/editText.tsx`
- [Thumbnail extractor](https://github.com/david-fernando/medium-posts-api/blob/main/utils/returnThumbnail.tsx): `utils/returnThumbnail.tsx`

### Other components

- **API client**
- **rss2json API**

## Connections

- API client → Username endpoint: requests GET (evidence: `README.md`)
- Username endpoint → RSS data fetch: fetches posts (evidence: `pages/api/[usermedium].ts`)
- RSS data fetch → rss2json API: requests conversion (evidence: `utils/returnJsonData.tsx`)
- Username endpoint → Post formatter: formats response (evidence: `pages/api/[usermedium].ts`)
- Post formatter → Description cleaner: cleans descriptions (evidence: `utils/returnJsonPosts.tsx`)
- Post formatter → Thumbnail extractor: extracts images (evidence: `utils/returnJsonPosts.tsx`)
- Username endpoint → API client: returns JSON (evidence: `pages/api/[usermedium].ts`)
