Skip to content

akshitsutharr/BlogTorch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”₯ BlogTorch

Where Code Meets Storytelling

Next.js React TypeScript MongoDB Prisma Tailwind CSS

A premium developer-focused blogging platform that combines technical writing, code presentation, and storytelling into a unified, notebook-style experience.

Demo β€’ Documentation β€’ Report Bug β€’ Request Feature

Check This Out


πŸ“– Table of Contents


🎯 About

BlogTorch is a modern, full-stack blogging platform designed specifically for developers, engineers, and technical writers. It bridges the gap between traditional blogging platforms and interactive developer notebooks, enabling you to create rich, narrative-driven posts that seamlessly integrate code, outputs, visualizations, and prose.

Why BlogTorch?

  • 🧩 Block-Based Architecture - Compose content with flexible, reorderable blocks
  • πŸ““ Notebook-Style Presentation - Familiar interface for developers showcasing code and results
  • 🎨 Developer-First UX - Syntax highlighting, markdown support, and code-focused design
  • 🀝 Built-in Social Features - Engage with the community through likes, comments, and follows
  • ⚑ Modern Tech Stack - Built with the latest web technologies for optimal performance

Perfect For

  • πŸ‘¨β€πŸ’» Software developers sharing tutorials and insights
  • πŸ€– ML practitioners documenting experiments and results
  • πŸ“Š Data scientists showcasing analyses and visualizations
  • πŸ“š Technical educators creating learning content
  • πŸš€ DevOps engineers documenting workflows
  • πŸ’‘ Open source contributors building their portfolio

✨ Key Features

🎨 Rich Content Editor

  • Multiple Block Types: Markdown, Code, Output, Image, Embed, Divider, Callout
  • Drag & Drop Reordering: Intuitive content organization with @dnd-kit
  • Real-time Preview: See your content as you write
  • Auto-save to Drafts: Never lose your work
  • Syntax Highlighting: Powered by Shiki with multi-language support

πŸ‘₯ Social Engagement

  • Like System: One-click appreciation for posts
  • Threaded Comments: Rich discussion with parent-child relationships
  • Bookmarks: Save posts for later reading
  • Follow System: Build your network and stay updated
  • User Profiles: Showcase your work and statistics

πŸ” Content Discovery

  • Explore Page: Browse and search all published posts
  • Tag-based Navigation: Find content by topics and technologies
  • Language Filtering: Discover posts by programming language
  • View & Like Tracking: See what's trending
  • Author Profiles: Connect with content creators

πŸ” Authentication & Security

  • Clerk Integration: Industry-standard authentication
  • Role-based Access: User and Admin roles
  • Protected Routes: Middleware-based protection
  • Input Validation: Zod schemas for runtime type safety
  • Content Sanitization: XSS prevention with rehype-sanitize

🎭 Theme System

  • Light/Dark Mode: System-aware theme switching
  • Persistent Preferences: Theme saved automatically
  • Smooth Transitions: Framer Motion animations
  • Accessible Design: WCAG 2.1 Level AA compliance target

πŸ›  Tech Stack

Frontend

Technology Version Purpose
Next.js 16.1.6 React framework with App Router
React 19.2.3 UI library with latest features
TypeScript 5.0+ Type-safe development
Tailwind CSS 4.0 Utility-first CSS framework
Radix UI Latest Accessible component primitives
Framer Motion 12.34.1 Animation library

Backend & Database

Technology Version Purpose
Node.js 20+ Server runtime
MongoDB Latest NoSQL database
Prisma 6.16.0 Type-safe database ORM
Clerk 6.37.5 Authentication & user management

Content Processing

Package Purpose
react-markdown Markdown rendering
remark-gfm GitHub Flavored Markdown support
shiki Syntax highlighting
rehype-pretty-code Enhanced code block styling
rehype-sanitize XSS protection

State & UI Management

  • Zustand - Lightweight state management
  • @dnd-kit - Drag and drop functionality
  • Sonner - Toast notifications
  • Lucide React - Icon library
  • next-themes - Theme management
  • Zod - Schema validation

πŸ— Architecture

BlogTorch is built on a modern, scalable architecture leveraging Next.js 16's App Router for optimal performance.

Core Architecture Principles

  1. Server Components First - Default to server components for better initial load
  2. Progressive Enhancement - Works without JavaScript, enhanced with it
  3. Type Safety - TypeScript across the entire stack
  4. Block-Based Content - Extensible system for new content types
  5. Optimistic Updates - Immediate UI feedback for better UX

Database Design

The MongoDB database uses Prisma ORM with the following core models:

User β†’ Posts β†’ Blocks
  ↓      ↓       ↓
Follows Tags  (Ordered content)
  ↓      ↓
Likes  PostTag
  ↓
Comments
  ↓
Bookmarks

Key Technical Decisions

  • βœ… Next.js App Router - Improved performance and developer experience
  • βœ… MongoDB + Prisma - Flexible schema for block-based content
  • βœ… Clerk Authentication - Outsourced auth for security and ease
  • βœ… Server Actions - Type-safe server mutations
  • βœ… Edge Runtime - Fast, globally distributed responses

πŸš€ Getting Started

Prerequisites

  • Node.js 20.x or higher
  • npm / yarn / pnpm
  • MongoDB database (local or cloud)
  • Clerk account for authentication

Installation

  1. Clone the repository
git clone https://github.com/akshitsutharr/BlogTorch.git
cd BlogTorch
  1. Install dependencies
npm install
# or
yarn install
# or
pnpm install
  1. Set up environment variables

Create a .env file in the root directory:

# Database
DATABASE_URL="mongodb+srv://username:password@cluster.mongodb.net/blogtorch"

# Authentication (Clerk)
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY="pk_test_..."
CLERK_SECRET_KEY="sk_test_..."
CLERK_WEBHOOK_SECRET="whsec_..."

# Optional
NEXT_PUBLIC_APP_URL="http://localhost:3000"
  1. Generate Prisma Client
npm run prisma:generate
  1. Push database schema
npm run db:push
  1. Run the development server
npm run dev
  1. Open your browser

Navigate to http://localhost:3000


πŸ“ Project Structure

BlogTorch/
β”œβ”€β”€ prisma/
β”‚   └── schema.prisma          # Database schema definition
β”œβ”€β”€ public/                    # Static assets
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                   # Next.js App Router
β”‚   β”‚   β”œβ”€β”€ (auth)/           # Authentication routes
β”‚   β”‚   β”‚   β”œβ”€β”€ sign-in/
β”‚   β”‚   β”‚   └── sign-up/
β”‚   β”‚   β”œβ”€β”€ api/              # API routes
β”‚   β”‚   β”‚   └── webhooks/     # Clerk webhooks
β”‚   β”‚   β”œβ”€β”€ editor/           # Post editor pages
β”‚   β”‚   β”‚   └── [id]/
β”‚   β”‚   β”œβ”€β”€ explore/          # Discovery page
β”‚   β”‚   β”œβ”€β”€ p/                # Post view pages
β”‚   β”‚   β”‚   └── [slug]/
β”‚   β”‚   β”œβ”€β”€ profile/          # User profiles
β”‚   β”‚   β”‚   └── [username]/
β”‚   β”‚   β”œβ”€β”€ globals.css       # Global styles
β”‚   β”‚   β”œβ”€β”€ layout.tsx        # Root layout
β”‚   β”‚   └── page.tsx          # Home page
β”‚   β”œβ”€β”€ components/           # React components
β”‚   β”‚   β”œβ”€β”€ blocks/          # Content block renderers
β”‚   β”‚   β”‚   β”œβ”€β”€ markdown-block.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ code-block.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ output-block.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ image-block.tsx
β”‚   β”‚   β”‚   └── embed-block.tsx
β”‚   β”‚   β”œβ”€β”€ editor/          # Editor components
β”‚   β”‚   β”‚   β”œβ”€β”€ block-editor.tsx
β”‚   β”‚   β”‚   └── add-block-menu.tsx
β”‚   β”‚   β”œβ”€β”€ layout/          # Layout components
β”‚   β”‚   β”‚   β”œβ”€β”€ navbar.tsx
β”‚   β”‚   β”‚   └── footer.tsx
β”‚   β”‚   β”œβ”€β”€ providers/       # Context providers
β”‚   β”‚   β”‚   β”œβ”€β”€ theme-provider.tsx
β”‚   β”‚   β”‚   └── clerk-provider.tsx
β”‚   β”‚   └── ui/              # UI primitives (shadcn/ui)
β”‚   β”‚       β”œβ”€β”€ button.tsx
β”‚   β”‚       β”œβ”€β”€ card.tsx
β”‚   β”‚       └── ...
β”‚   β”œβ”€β”€ lib/                 # Utility functions
β”‚   β”‚   β”œβ”€β”€ utils.ts         # Helper functions
β”‚   β”‚   └── constants.ts     # App constants
β”‚   β”œβ”€β”€ server/              # Server-side modules
β”‚   β”‚   β”œβ”€β”€ auth.ts          # Authentication helpers
β”‚   β”‚   β”œβ”€β”€ db.ts            # Prisma client
β”‚   β”‚   β”œβ”€β”€ posts.ts         # Post queries
β”‚   β”‚   └── users.ts         # User queries
β”‚   └── middleware.ts        # Next.js middleware
β”œβ”€β”€ .env                     # Environment variables
β”œβ”€β”€ .gitignore
β”œβ”€β”€ eslint.config.mjs        # ESLint configuration
β”œβ”€β”€ next.config.ts           # Next.js configuration
β”œβ”€β”€ package.json
β”œβ”€β”€ postcss.config.mjs       # PostCSS configuration
β”œβ”€β”€ README.md
β”œβ”€β”€ tailwind.config.ts       # Tailwind configuration
└── tsconfig.json            # TypeScript configuration

🧩 Block Types

BlogTorch supports multiple content block types for rich, flexible storytelling:

1. MARKDOWN Block

Rich text formatting with GitHub Flavored Markdown support.

{
  type: "MARKDOWN",
  data: {
    content: "# Hello World\n\nThis is **markdown** content."
  }
}

Features:

  • Inline code, links, lists, tables, blockquotes
  • GitHub Flavored Markdown extensions
  • Typography optimized for technical writing

2. CODE Block

Syntax-highlighted code with multi-language support.

{
  type: "CODE",
  data: {
    language: "typescript",
    code: "const greeting = 'Hello, World!';"
  }
}

Features:

  • 50+ programming languages
  • Line numbers
  • Copy-to-clipboard
  • Theme-aware highlighting
  • Language badges

3. OUTPUT Block

Display code execution results and terminal outputs.

{
  type: "OUTPUT",
  data: {
    mimeType: "text/plain",
    content: "Hello, World!"
  }
}

Supported MIME Types:

  • text/plain - Plain text output
  • image/png, image/jpeg, image/svg+xml - Image outputs
  • Base64 encoded data

4. IMAGE Block

Embed images with captions and alt text.

{
  type: "IMAGE",
  data: {
    url: "https://example.com/image.png",
    alt: "Description",
    caption: "Optional caption"
  }
}

5. EMBED Block

Embed external content like YouTube videos.

{
  type: "EMBED",
  data: {
    url: "https://youtube.com/watch?v=..."
  }
}

6. DIVIDER Block

Visual section separators for better content organization.

7. CALLOUT Block

Highlighted information boxes for important notes.

{
  type: "CALLOUT",
  data: {
    type: "info", // info, warning, tip, danger
    content: "Important information here"
  }
}

πŸ” Environment Variables

Create a .env file with the following variables:

# Database Configuration
DATABASE_URL="mongodb+srv://username:password@cluster.mongodb.net/blogtorch?retryWrites=true&w=majority"

# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY="pk_test_XXXXXXXXXXXXXXXX"
CLERK_SECRET_KEY="sk_test_XXXXXXXXXXXXXXXX"
CLERK_WEBHOOK_SECRET="whsec_XXXXXXXXXXXXXXXX"

# App Configuration (Optional)
NEXT_PUBLIC_APP_URL="http://localhost:3000"
NODE_ENV="development"

Getting Clerk Credentials

  1. Sign up at Clerk.com
  2. Create a new application
  3. Copy the API keys from the dashboard
  4. Set up a webhook endpoint for user synchronization

πŸ—„ Database Schema

Core Models

User

model User {
  id          String   @id @default(auto()) @map("_id") @db.ObjectId
  clerkId     String   @unique
  username    String?  @unique
  displayName String?
  bio         String?
  imageUrl    String?
  role        UserRole @default(USER)
  
  // Social links
  websiteUrl  String?
  githubUrl   String?
  twitterUrl  String?
  
  // Relations
  posts       Post[]
  comments    Comment[]
  likes       Like[]
  bookmarks   Bookmark[]
  followers   Follow[] @relation("followers")
  following   Follow[] @relation("following")
}

Post

model Post {
  id            String     @id @default(auto()) @map("_id") @db.ObjectId
  slug          String     @unique
  title         String
  excerpt       String?
  coverImageUrl String?
  published     Boolean    @default(false)
  source        PostSource @default(EDITOR)
  
  // Relations
  authorId      String     @db.ObjectId
  author        User       @relation(fields: [authorId], references: [id])
  blocks        Block[]
  tags          PostTag[]
  
  // Engagement
  likes         Like[]
  comments      Comment[]
  bookmarks     Bookmark[]
  likeCount     Int        @default(0)
  viewCount     Int        @default(0)
  commentCount  Int        @default(0)
}

Block

model Block {
  id        String    @id @default(auto()) @map("_id") @db.ObjectId
  postId    String    @db.ObjectId
  type      BlockType
  order     Int
  data      Json      // Flexible JSON data for each block type
  
  post      Post      @relation(fields: [postId], references: [id], onDelete: Cascade)
  
  @@index([postId, order])
}

πŸ’» Development

Available Scripts

# Development
npm run dev              # Start development server
npm run build            # Build for production
npm run start            # Start production server
npm run lint             # Run ESLint

# Database
npm run prisma:generate  # Generate Prisma Client
npm run db:push          # Push schema to database
npm run db:studio        # Open Prisma Studio

Code Style

  • ESLint - Code linting with Next.js config
  • TypeScript - Strict mode enabled
  • Prettier - Code formatting (recommended)

Conventions

  • Use Server Components by default
  • Mark client components with 'use client'
  • Co-locate components with their usage
  • Use TypeScript interfaces for props
  • Follow the feature-based folder structure

Environment Setup

Make sure to configure all environment variables in your deployment platform:

  • DATABASE_URL
  • NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
  • CLERK_SECRET_KEY
  • CLERK_WEBHOOK_SECRET
  • NEXT_PUBLIC_APP_URL

πŸ—Ί Roadmap

Phase 1: Core Platform βœ…

  • User authentication with Clerk
  • Block-based editor with drag & drop
  • Post publishing and viewing
  • Social features (likes, comments, follows)
  • Tag system
  • Theme switching

Phase 2: Enhanced Discovery 🚧

  • Advanced search with full-text indexing
  • Multi-tag filtering
  • Trending posts algorithm
  • Personalized recommendations
  • Author pages with full stats

Phase 3: Collaboration πŸ“‹

  • Co-authoring posts
  • Comment mentions (@username)
  • Direct messaging
  • Post sharing to social media

Phase 4: Notebook Import πŸ“‹

  • Jupyter Notebook (.ipynb) import
  • Automatic conversion to blocks
  • Preserve code + output structure

Phase 5: Analytics πŸ“‹

  • Post performance metrics
  • Audience demographics
  • Traffic sources dashboard
  • Export analytics data

Phase 6: Advanced Editor πŸ“‹

  • Real-time collaborative editing
  • Version history with rollback
  • AI-assisted writing
  • Math equation support (LaTeX)
  • Diagram support (Mermaid)

🀝 Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

How to Contribute

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Development Guidelines

  • Follow the existing code style
  • Write meaningful commit messages
  • Add tests for new features
  • Update documentation as needed
  • Keep PRs focused and small

πŸ“„ License

Distributed under the MIT License. See LICENSE for more information.


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

Akshit Suthar


πŸ™ Acknowledgments


πŸ“ž Support

If you have any questions or need help, feel free to:

  • Open an issue on GitHub
  • Star ⭐ this repository if you find it helpful!

Built with ❀️ by developers, for developers

About

A premium developer-focused blogging platform that combines technical writing, code presentation, and storytelling into a unified, notebook-style experience.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors