Skip to content

A full-stack blog application built with modern web technologies, featuring a React frontend, Cloudflare Workers backend, and PostgreSQL database.

Notifications You must be signed in to change notification settings

Mrunal112/devlogs-blog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CodeLogs Blog

A comprehensive full-stack blog application built with modern web technologies, featuring a React frontend with advanced theming, Cloudflare Workers backend, and PostgreSQL database with intelligent content management.

🎯 Quick Preview

Feature Screenshot
🏠 Homepage Home
πŸ“ Publishing Publish
πŸ” Authentication Auth
πŸ“š Blog Discovery Blogs

πŸš€ Features

🎨 User Experience

  • Advanced Theme System - Dark/light mode with system preference detection and smooth transitions
  • Responsive Design - Mobile-first design with Tailwind CSS v4 and optimized layouts
  • Real-time Feedback - Loading states, error handling, success notifications, and visual feedback
  • Interactive UI - Hover effects, smooth animations, and intuitive navigation

πŸ” Authentication & Security

  • JWT Authentication - Secure user sessions with token-based authentication
  • Protected Routes - Route guards for authenticated-only content
  • User Management - Sign up, sign in, and profile management

πŸ“ Content Management

  • Rich Blog Publishing - Intuitive blog creation form with real-time validation
  • Draft Management - Auto-save drafts to localStorage with manual save/clear options
  • Blog CRUD Operations - Create, read, update, and delete blog posts
  • Content Search - API integration for blog discovery and listing

🏷️ Smart Content Features

  • Intelligent Tag Extraction - Automatic tag generation from blog content with proper capitalization
  • Read Time Estimation - Dynamic reading time calculation based on content length
  • Author Attribution - Complete author information display
  • Content Metadata - Publication dates, update tracking, and content statistics

🎯 Technical Excellence

  • API Integration - Seamless backend integration with comprehensive error handling
  • Type Safety - Full TypeScript support across the entire stack
  • Serverless Architecture - Deployed on Cloudflare Workers for global edge performance
  • Database Management - Prisma ORM with PostgreSQL and migration support
  • Mock Data Fallbacks - Graceful degradation with mock content for development

πŸ—οΈ Architecture

This is a monorepo containing three main packages:

Frontend (/frontend)

  • React 19 with TypeScript for modern component architecture
  • Vite 7 for lightning-fast development and optimized builds
  • Tailwind CSS v4 with @tailwindcss/vite plugin for advanced styling
  • React Router v7 for sophisticated client-side routing
  • Context API for global state management (theme, authentication)
  • Custom Hooks for reusable logic (useAuth, useTheme)
  • Component Library - Comprehensive UI components with dark mode support
  • Advanced Features:
    • Smart tag extraction and capitalization
    • Draft management with localStorage persistence
    • Real-time content validation
    • Loading skeletons and error boundaries
    • Responsive design patterns

Backend (/backend)

  • Hono - Fast, lightweight web framework for Cloudflare Workers
  • Prisma 6 - Type-safe database ORM with Accelerate for global performance
  • PostgreSQL - Production-ready database with full ACID compliance
  • JWT Authentication - Secure user sessions with token-based auth
  • Cloudflare Workers - Serverless deployment with edge computing
  • RESTful API - Comprehensive endpoints for blog and user management
  • Database Migrations - Version-controlled schema management
  • Type Safety - End-to-end TypeScript integration

Common (/common)

  • Zod - Runtime type validation
  • Shared Types - TypeScript interfaces for API contracts
  • NPM Package - Published as @mrunal121/codelogs-blog-common

πŸ“¦ Tech Stack

Frontend Technologies

  • React 19.1.1 - Latest React with concurrent features
  • TypeScript - Type safety and enhanced developer experience
  • Vite 7.1.2 - Next-generation frontend tooling
  • Tailwind CSS 4.1.12 - Utility-first CSS framework with v4 features
  • React Router DOM 7.8.0 - Advanced routing with nested routes
  • Context API - Built-in state management solution

Backend Technologies

  • Hono 4.7.10 - Modern web framework for edge computing
  • Prisma 6.8.2 - Next-generation ORM with type safety
  • Cloudflare Workers - Serverless compute platform
  • PostgreSQL - Advanced relational database via Prisma Accelerate
  • JWT - Industry-standard authentication tokens

Development & Build Tools

  • ESLint - Code linting and quality enforcement
  • PostCSS - CSS processing and optimization
  • Wrangler - Cloudflare Workers CLI and development tools
  • TypeScript - Static type checking across the stack
  • Vite - Fast build tool with HMR and optimizations

πŸš€ Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • npm or yarn
  • Cloudflare account (for deployment)

Installation

  1. Clone the repository

    git clone https://github.com/Mrunal112/devlogs-blog.git
    cd codelogs-blogs
  2. Install dependencies for all packages

    # Install frontend dependencies
    cd frontend
    npm install
    
    # Install backend dependencies
    cd ../backend
    npm install
    
    # Install common package dependencies
    cd ../common
    npm install

Development Setup

  1. Set up the database

    cd backend
    # Configure your DATABASE_URL in wrangler.jsonc
    npx prisma migrate dev
  2. Start the backend development server

    cd backend
    npm run dev
    # Backend runs on Cloudflare Workers local development environment
  3. Start the frontend development server

    cd frontend
    npm run dev
    # Frontend will be available at http://localhost:5173
  4. Build the common package (if making changes)

    cd common
    npm run build

πŸ“ Project Structure

codelogs-blogs/
β”œβ”€β”€ frontend/                 # React frontend application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/      # Reusable UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ Auth.tsx     # Authentication form component
β”‚   β”‚   β”‚   β”œβ”€β”€ AuthGuard.tsx # Route protection wrapper
β”‚   β”‚   β”‚   β”œβ”€β”€ BlogCard.tsx # Blog post card with tags and metadata
β”‚   β”‚   β”‚   β”œβ”€β”€ Footer.tsx   # Application footer
β”‚   β”‚   β”‚   β”œβ”€β”€ Header.tsx   # Navigation header with theme toggle
β”‚   β”‚   β”‚   β”œβ”€β”€ Layout.tsx   # Main layout wrapper with theme support
β”‚   β”‚   β”‚   β”œβ”€β”€ ProtectedRoute.tsx # Protected route wrapper
β”‚   β”‚   β”‚   β”œβ”€β”€ Publish.tsx  # Advanced blog publishing form with drafts
β”‚   β”‚   β”‚   β”œβ”€β”€ Quote.tsx    # Inspirational quotes display
β”‚   β”‚   β”‚   └── ThemeToggle.tsx # Dark/light mode toggle button
β”‚   β”‚   β”œβ”€β”€ contexts/        # React Context providers
β”‚   β”‚   β”‚   β”œβ”€β”€ AuthContext.tsx # Authentication state management
β”‚   β”‚   β”‚   β”œβ”€β”€ theme.ts     # Theme type definitions
β”‚   β”‚   β”‚   └── ThemeContext.tsx # Theme state provider with system detection
β”‚   β”‚   β”œβ”€β”€ hooks/           # Custom React hooks
β”‚   β”‚   β”‚   β”œβ”€β”€ useAuth.ts   # Authentication hook with JWT handling
β”‚   β”‚   β”‚   └── useTheme.ts  # Theme management hook
β”‚   β”‚   β”œβ”€β”€ pages/           # Page components
β”‚   β”‚   β”‚   β”œβ”€β”€ Blog.tsx     # Individual blog post page with tag extraction
β”‚   β”‚   β”‚   β”œβ”€β”€ Blogs.tsx    # Blog listing page with API integration and search
β”‚   β”‚   β”‚   β”œβ”€β”€ Signin.tsx   # User sign in page
β”‚   β”‚   β”‚   └── Signup.tsx   # User registration page
β”‚   β”‚   β”œβ”€β”€ routes/          # Route configuration
β”‚   β”‚   β”‚   β”œβ”€β”€ AuthRoutes.tsx    # Authentication-related routes
β”‚   β”‚   β”‚   β”œβ”€β”€ index.tsx         # Main route configuration with guards
β”‚   β”‚   β”‚   β”œβ”€β”€ ProtectedRoutes.tsx # Protected route definitions
β”‚   β”‚   β”‚   └── PublicRoutes.tsx  # Public route definitions
β”‚   β”‚   β”œβ”€β”€ config.ts        # Frontend configuration and API URLs
β”‚   β”‚   └── main.tsx         # Application entry point with providers
β”‚   β”œβ”€β”€ vite.config.ts       # Vite configuration with Tailwind CSS v4
β”‚   └── package.json         # Dependencies and build scripts
β”‚   β”‚   β”‚   β”œβ”€β”€ Blogs.tsx    # Blog listing page with API integration
β”‚   β”‚   β”‚   β”œβ”€β”€ Signin.tsx   # Sign in page
β”‚   β”‚   β”‚   └── Signup.tsx   # Sign up page
β”‚   β”‚   β”œβ”€β”€ routes/          # Route configuration
β”‚   β”‚   β”‚   β”œβ”€β”€ AuthRoutes.tsx    # Authentication routes
β”‚   β”‚   β”‚   β”œβ”€β”€ index.tsx         # Main route configuration
β”‚   β”‚   β”‚   β”œβ”€β”€ ProtectedRoutes.tsx # Protected routes
β”‚   β”‚   β”‚   └── PublicRoutes.tsx  # Public routes
β”‚   β”‚   β”œβ”€β”€ config.ts        # Frontend configuration
β”‚   β”‚   └── main.tsx         # Application entry point
β”‚   β”œβ”€β”€ vite.config.ts       # Vite configuration with Tailwind v4
β”‚   └── package.json         # Dependencies and scripts
β”œβ”€β”€ backend/                 # Cloudflare Workers backend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ routes/          # API route handlers
β”‚   β”‚   β”‚   β”œβ”€β”€ user.ts      # User authentication and profile routes
β”‚   β”‚   β”‚   β”œβ”€β”€ blog.ts      # Blog CRUD operations and bulk fetch
β”‚   β”‚   β”‚   └── auth.ts      # Authentication middleware and utilities
β”‚   β”‚   β”œβ”€β”€ auth/            # Authentication utilities
β”‚   β”‚   β”‚   └── jwt.ts       # JWT token creation and validation
β”‚   β”‚   └── index.ts         # Main server entry point with CORS
β”‚   β”œβ”€β”€ prisma/              # Database schema and migrations
β”‚   β”‚   β”œβ”€β”€ schema.prisma    # Database schema with user and blog models
β”‚   β”‚   └── migrations/      # Database migration files with version control
β”‚   β”‚       β”œβ”€β”€ migration_lock.toml
β”‚   β”‚       β”œβ”€β”€ 20250531144537_init_schema/
β”‚   β”‚       └── 20250531171134_added_username/
β”‚   └── wrangler.jsonc       # Cloudflare Workers configuration and env vars
β”œβ”€β”€ common/                  # Shared types and utilities
β”‚   └── src/
β”‚       └── index.ts         # Exported TypeScript interfaces and Zod schemas
└── README.md               # This comprehensive documentation

πŸ”§ Configuration

Backend Configuration

Update backend/wrangler.jsonc with your:

  • Database URL (Prisma Accelerate)
  • Environment variables
  • Cloudflare Workers settings

Frontend Configuration

Update frontend/src/config.ts with your:

  • Backend API URL
  • Environment-specific settings

πŸ“ API Endpoints

Authentication

  • POST /user/signup - Create new user account with email and password
  • POST /user/signin - User login returning JWT token

Blog Management

  • GET /blog/bulk - Get all published blog posts (with optional auth header)
  • GET /blog/:id - Get specific blog post by ID with full content
  • POST /blog - Create new blog post (authenticated users only)
  • PUT /blog/:id - Update existing blog post (authenticated, author only)
  • DELETE /blog/:id - Delete blog post (authenticated, author only)

Response Features

  • Automatic Tag Extraction - Tags generated from content with proper capitalization
  • Author Information - Complete author details included in responses
  • Metadata - Creation/update timestamps, publication status
  • Type Safety - All responses validated with TypeScript interfaces

πŸš€ Deployment

Backend Deployment (Cloudflare Workers)

cd backend
# Ensure your wrangler.jsonc is configured with production settings
npm run deploy
# Your API will be available at your Cloudflare Workers domain

Frontend Deployment

cd frontend
# Build the optimized production bundle
npm run build
# Deploy the dist/ folder to your preferred hosting service
# Recommended: Vercel, Netlify, or Cloudflare Pages

Environment Variables

Backend (wrangler.jsonc):

  • DATABASE_URL - Prisma Accelerate connection string
  • JWT_SECRET - JWT signing secret

Frontend (config.ts):

  • Update backendUrl for your production API endpoint

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the ISC License. See the LICENSE file for details.

πŸ‘¨β€πŸ’» Author

Mrunal - @Mrunal112

πŸ™ Acknowledgments

  • Inspired by modern blogging platforms
  • Uses cutting-edge web technologies for optimal performance

Happy Coding! πŸš€

About

A full-stack blog application built with modern web technologies, featuring a React frontend, Cloudflare Workers backend, and PostgreSQL database.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published