How darshan98solanki/medium works
Project Type and Purpose
• This is a full-stack, Medium-style blogging platform (“TechLog”) with three key modules:
• Frontend: React + Tailwind CSS app hosted on Vercel
• Backend: Node.js + Hono REST API deployed as Cloudflare Worker
• Common: Shared utilities/constants used by both sides
• Purpose: Allow users to register/login, read, write, edit, delete, and explore articles.
File Structure Analysis
• Top-Level Directories:
• backend/ – REST API routes (src/routes), Prisma ORM (prisma/schema.prisma + migrations)
• frontend/ – React pages/components, styling, Vite config, deployment config (vercel.json)
• common/ – Shared code (src/index.ts), published as npm package for cross-project reuse
• Config & Deployment Files:
• backend/package.json, tsconfig.json, Cloudflare Worker setup via wrangler (implicit)
• frontend/vite.config.ts, vercel.json, Tailwind/postCSS configs
• Prisma migrations under backend/prisma/migrations
README Insights
• Highlights the tech stack: Node.js, Hono, Prisma, JWT, Crypto on the backend; React, Tailwind, Axios on the frontend; PostgreSQL database
• Deployment targets: Vercel for frontend, Cloudflare Worker for backend
• Database schema evolves via Prisma migrations (users, blogs, status column)
a. Main Components
• Client Browser (Chrome/Firefox on desktop/mobile)
• Frontend App (React+Tailwind)
• HTTP/API Layer (Axios on frontend → Hono routes on backend)
• Shared Common Library (npm package used at build time)
• Backend Business Logic (Hono controllers, JWT auth, Crypto hashing)
• ORM Layer (Prisma)
• PostgreSQL Database (hosted on a managed service)
• External Services: Vercel CDN/edge, Cloudflare Worker runtime
b. Relationships & Data Flows
1. User interacts with Frontend UI in the Browser
2. Frontend makes REST calls via Axios to Cloudflare Worker endpoint
3. Hono routes parse requests → invoke controllers using shared utilities from common/
4. Controllers use Prisma client to query/update PostgreSQL
5. Data returned through Hono → Axios promise resolves → UI updates
6. JWT workflows: Login endpoint issues JWT → stored in localStorage or HTTP-only cookie → attached to subsequent requests
c. Architectural Patterns & Principles
• Separation of Concerns: UI vs API vs Data Access
• RESTful API design using Hono
• ORM abstraction with Prisma migrations for schema evolution
• Shared module (common/) to DRY up utilities across frontend & backend
• Edge-deployed backend (low latency) + CDN-served frontend
d. Key Technologies
• Frontend: React.js, Tailwind CSS, Vite, Axios
• Backend: Node.js, Hono, Prisma, JWT, Crypto
• Database: PostgreSQL