# syedahmedullah14/blogging-app-like-medium architecture

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

- Interactive diagram: https://gitdiagram.com/syedahmedullah14/blogging-app-like-medium
- Repository: https://github.com/syedahmedullah14/blogging-app-like-medium

## Overview

##### Project type and purpose
- This is a full-stack blogging application (Medium-style) built as a monorepo.
- Frontend: React + Vite + Tailwind (deployed to Vercel)
- Backend: Cloudflare Workers (TypeScript) using Prisma ORM + PostgreSQL (deployed via Wrangler)
- Common: Shared TypeScript utilities/types across frontend & backend

##### File structure
- Root: README.md points to live demo, tech stack, features
- backend/
- src/index.ts – Worker entrypoint
- src/route/blog.ts, user.ts – HTTP handlers
- prisma/ – schema.prisma + migrations (PostgreSQL schema + connection pooling)
- wrangler.toml – Cloudflare Workers config
- package.json, tsconfig.json – build & typings
- common/
- src/index.ts – shared types or helpers
- dist/ – compiled output for npm linkage
- frontend/
- src/ – React app (App.tsx, pages, components, hooks, config.ts)
- public/index.html – SPA host
- vite.config.ts, tsconfig*, tailwind.config.js – build/tooling
- package.json – dependencies (React, Skeleton UI, Zod client‐side)

##### README for additional insights
- Authentication via JWT
- Zod for validation/type inference
- Skeleton loading in UI for better UX
- Connection pooling in Prisma

a. Main components
1. Client (Browser/SPA)
2. CDN / Vercel (serving static assets)
3. Cloudflare Workers (serverless API)
4. Prisma ORM (hosted within Workers)
5. PostgreSQL Database
6. Shared “common” library (types/validation logic)
7. External services: Cloudflare KV or Secrets (for JWT_SECRET, DB URL)
b. Relationships & data flow
- User → Browser → SPA (React)
- SPA makes HTTP calls to Cloudflare Workers endpoints (/api/user, /api/blog)
- Worker executes route logic → uses shared common code (Zod schemas, types) → Prisma client
- Prisma client communicates with PostgreSQL → returns data
- Worker signs/verifies JWT (using secrets stored in Cloudflare environment)
- JSON response back to SPA → UI renders with Skeleton loaders
c. Architectural patterns & principles
- Monorepo with three packages (frontend, backend, common)
- Serverless backend: each route is an isolated function in Workers
- Shared code: common library for DRY validation/types
- MVC-lite: route handlers (controllers) → Prisma (model) → JSON (view)
- Zero-trust/auth: JWT for session management
d. Key technologies
- React + Vite (SPA build & dev server)
- Tailwind CSS + postcss (UI styling)
- Cloudflare Workers + Wrangler (serverless deployment)
- TypeScript + Zod (static typing & runtime validation)
- Prisma ORM + PostgreSQL (data layer + migrations)
- JWT (authentication)

##### Final pointers
- Layer (UI, API, Data) distinctly.
- External services (Secrets, CDN) to show operational dependencies.
- Authentication flow (JWT issuance & verification).
- Monorepo structure by grouping code artifacts (folders) under each component.
- Don’t overcomplicate: break the system into as many logical components as necessary for clarity.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External User
    User["User (Browser)"]:::external

    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        CDN["Vercel CDN"]:::cloud
        subgraph "React SPA"
            direction TB
            App["App.tsx"]:::frontend
            Pages["pages/"]:::frontend
            Components["components/"]:::frontend
            Main["main.tsx"]:::frontend
            HTML["index.html"]:::frontend
        end
        subgraph "Build Config"
            Vite["vite.config.ts"]:::frontend
            FEpkg["package.json"]:::frontend
            Tailwind["tailwind.config.js"]:::frontend
            PostCSS["postcss.config.js"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        CFWorker["Cloudflare Worker"]:::cloud
        subgraph "Worker Entry & Config"
            Index["src/index.ts"]:::backend
            Wrangler["wrangler.toml"]:::backend
        end
        subgraph "API Routes"
            direction TB
            BlogRoute["blog.ts (/api/blog)"]:::backend
            UserRoute["user.ts (/api/user)"]:::backend
        end
        subgraph "Prisma ORM"
            Schema["schema.prisma"]:::backend
            Migration["20240620091118_init_schema/migration.sql"]:::backend
        end
        Secrets["CF Secrets/KV"]:::backend
    end

    %% Common Library
    subgraph "Common Library (shared)"
        direction TB
        CommonSrc["src/index.ts"]:::common
        DistJS["dist/index.js"]:::common
        DistDT["dist/index.d.ts"]:::common
    end

    %% Database
    Postgres["PostgreSQL"]:::database

    %% Connections
    User -->|"Loads SPA"| CDN
    CDN -->|"Serves static assets"| App
    App -->|"HTTP GET/POST /api/*"| BlogRoute
    App -->|"HTTP GET/POST /api/*"| UserRoute

    BlogRoute -->|"Uses shared types/validation"| CommonSrc
    UserRoute -->|"Uses shared types/validation"| CommonSrc

    BlogRoute -->|"Prisma client queries"| Schema
    UserRoute -->|"Prisma client queries"| Schema

    Schema -->|"SQL queries"| Postgres

    BlogRoute -->|"JWT sign/verify"| Secrets
    UserRoute -->|"JWT sign/verify"| Secrets

    %% Click Events
    click App "https://github.com/syedahmedullah14/blogging-app-like-medium/blob/main/frontend/src/App.tsx"
    click Pages "https://github.com/syedahmedullah14/blogging-app-like-medium/tree/main/frontend/src/pages/"
    click Components "https://github.com/syedahmedullah14/blogging-app-like-medium/tree/main/frontend/src/components/"
    click Main "https://github.com/syedahmedullah14/blogging-app-like-medium/blob/main/frontend/src/main.tsx"
    click HTML "https://github.com/syedahmedullah14/blogging-app-like-medium/blob/main/frontend/index.html"
    click Vite "https://github.com/syedahmedullah14/blogging-app-like-medium/blob/main/frontend/vite.config.ts"
    click FEpkg "https://github.com/syedahmedullah14/blogging-app-like-medium/blob/main/frontend/package.json"
    click Tailwind "https://github.com/syedahmedullah14/blogging-app-like-medium/blob/main/frontend/tailwind.config.js"
    click PostCSS "https://github.com/syedahmedullah14/blogging-app-like-medium/blob/main/frontend/postcss.config.js"
    click Index "https://github.com/syedahmedullah14/blogging-app-like-medium/blob/main/backend/src/index.ts"
    click Wrangler "https://github.com/syedahmedullah14/blogging-app-like-medium/blob/main/backend/wrangler.toml"
    click BlogRoute "https://github.com/syedahmedullah14/blogging-app-like-medium/blob/main/backend/src/route/blog.ts"
    click UserRoute "https://github.com/syedahmedullah14/blogging-app-like-medium/blob/main/backend/src/route/user.ts"
    click Schema "https://github.com/syedahmedullah14/blogging-app-like-medium/blob/main/backend/prisma/schema.prisma"
    click Migration "https://github.com/syedahmedullah14/blogging-app-like-medium/blob/main/backend/prisma/migrations/20240620091118_init_schema/migration.sql"
    click CommonSrc "https://github.com/syedahmedullah14/blogging-app-like-medium/blob/main/common/src/index.ts"
    click DistJS "https://github.com/syedahmedullah14/blogging-app-like-medium/blob/main/common/dist/index.js"
    click DistDT "https://github.com/syedahmedullah14/blogging-app-like-medium/blob/main/common/dist/index.d.ts"

    %% Styles
    classDef frontend fill:#D6EAF8,stroke:#3498DB,color:#154360
    classDef backend fill:#FADBD8,stroke:#E74C3C,color:#641E16
    classDef common fill:#D5F5E3,stroke:#27AE60,color:#145A32
    classDef database fill:#FDEBD0,stroke:#D68910,color:#7E5109
    classDef cloud fill:#F2F4F4,stroke:#95A5A6,color:#424949
    classDef external fill:#FCF3CF,stroke:#F1C40F,color:#7D6608
```
