Skip to content

mr-coder90/Multi-blog

Repository files navigation

Blog Platform

A modern, full-stack blogging platform built with Next.js 15, tRPC, PostgreSQL, and Drizzle ORM. This application demonstrates modern web development practices with type-safe APIs, responsive design, and a clean architecture.

πŸš€ Features

Core Features (Priority 1 - βœ… Implemented)

  • βœ… Blog post CRUD operations (create, read, update, delete)
  • βœ… Category CRUD operations
  • βœ… Assign one or more categories to posts
  • βœ… Blog listing page showing all posts
  • βœ… Individual post view page
  • βœ… Category filtering on listing page
  • βœ… Basic responsive navigation
  • βœ… Clean, professional UI

Expected Features (Priority 2 - βœ… Implemented)

  • βœ… Landing page with Header/Hero, Features, and Footer sections
  • βœ… Dashboard page for managing posts
  • βœ… Draft vs Published post status
  • βœ… Loading and error states
  • βœ… Mobile-responsive design
  • βœ… Content editor with markdown support

Bonus Features (Priority 3 - πŸ”„ Optional)

  • πŸ”„ Search functionality for posts
  • πŸ”„ Post statistics (word count, reading time)
  • πŸ”„ Dark mode support
  • πŸ”„ Image upload for posts
  • πŸ”„ Post preview functionality
  • πŸ”„ SEO meta tags
  • πŸ”„ Pagination

πŸ›  Tech Stack

  • Frontend: Next.js 15 with App Router, React 19, TypeScript
  • Styling: Tailwind CSS, shadcn/ui components
  • Backend: tRPC for type-safe APIs
  • Database: PostgreSQL with Drizzle ORM
  • State Management: Zustand (where needed)
  • Data Fetching: React Query (via tRPC integration)
  • Form Handling: React Hook Form with Zod validation
  • Icons: Lucide React

πŸ“ Project Structure

src/
β”œβ”€β”€ app/                    # Next.js App Router pages
β”‚   β”œβ”€β”€ api/trpc/          # tRPC API routes
β”‚   β”œβ”€β”€ blog/              # Blog pages
β”‚   β”œβ”€β”€ dashboard/         # Admin dashboard
β”‚   β”œβ”€β”€ globals.css        # Global styles
β”‚   β”œβ”€β”€ layout.tsx         # Root layout
β”‚   β”œβ”€β”€ page.tsx           # Landing page
β”‚   └── providers.tsx      # tRPC and React Query providers
β”œβ”€β”€ components/            # Reusable components
β”‚   β”œβ”€β”€ ui/               # shadcn/ui components
β”‚   └── navigation.tsx    # Navigation component
└── lib/                  # Utilities and configurations
    β”œβ”€β”€ db.ts             # Database connection
    β”œβ”€β”€ schema.ts         # Database schema
    β”œβ”€β”€ trpc.ts           # tRPC configuration
    β”œβ”€β”€ trpc-client.ts    # tRPC client setup
    └── routers/          # tRPC routers
        β”œβ”€β”€ index.ts      # Main app router
        β”œβ”€β”€ posts.ts      # Posts router
        └── categories.ts # Categories router

πŸš€ Getting Started

Prerequisites

  • Node.js 18.17 or later
  • PostgreSQL database (local or hosted)

Installation

  1. Clone the repository

    git clone <repository-url>
    cd blog-platform
  2. Install dependencies

    npm install
  3. Set up environment variables

    cp .env.local.example .env.local

    Update .env.local with your database connection string:

    DATABASE_URL="postgresql://username:password@localhost:5432/blog_platform"
  4. Set up the database

    # Generate migration files
    npm run db:generate
    
    # Push schema to database
    npm run db:push
  5. Start the development server

    npm run dev
  6. Open your browser Navigate to http://localhost:3000

πŸ—„ Database Schema

The application uses three main tables:

Posts Table

  • id (UUID, Primary Key)
  • title (VARCHAR, 200 chars)
  • content (TEXT)
  • slug (VARCHAR, 200 chars, Unique)
  • published (BOOLEAN, default: false)
  • createdAt (TIMESTAMP)
  • updatedAt (TIMESTAMP)

Categories Table

  • id (UUID, Primary Key)
  • name (VARCHAR, 100 chars, Unique)
  • description (TEXT)
  • slug (VARCHAR, 100 chars, Unique)
  • createdAt (TIMESTAMP)
  • updatedAt (TIMESTAMP)

Post Categories Table (Many-to-Many)

  • id (UUID, Primary Key)
  • postId (UUID, Foreign Key)
  • categoryId (UUID, Foreign Key)
  • createdAt (TIMESTAMP)

πŸ”§ Available Scripts

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm run start - Start production server
  • npm run lint - Run ESLint
  • npm run db:generate - Generate database migrations
  • npm run db:migrate - Run database migrations
  • npm run db:push - Push schema changes to database
  • npm run db:studio - Open Drizzle Studio

🌐 API Endpoints

The application uses tRPC for type-safe API endpoints:

Posts Router (/api/trpc/posts)

  • getAll - Get all published posts with optional category filtering
  • getBySlug - Get a single post by slug
  • create - Create a new post
  • update - Update an existing post
  • delete - Delete a post
  • getAllForAdmin - Get all posts (including drafts) for admin

Categories Router (/api/trpc/categories)

  • getAll - Get all categories
  • getBySlug - Get a single category by slug
  • create - Create a new category
  • update - Update an existing category
  • delete - Delete a category

πŸ“± Pages and Routes

  • / - Landing page with hero, features, and footer
  • /blog - Blog listing page with category filtering
  • /blog/[slug] - Individual post view page
  • /dashboard - Admin dashboard for managing posts and categories
  • /dashboard/new - Create new post page
  • /dashboard/edit/[id] - Edit existing post page

🎨 UI Components

The application uses shadcn/ui components for a consistent and professional design:

  • Button - Various button styles and sizes
  • Card - Content containers with header and content sections
  • Input - Form input fields
  • Textarea - Multi-line text input
  • Label - Form labels
  • Select - Dropdown selection component
  • Badge - Small status and category indicators
  • Separator - Visual content separators

πŸ”’ Type Safety

The application leverages TypeScript and tRPC for end-to-end type safety:

  • Database Schema: Defined with Drizzle ORM with full TypeScript support
  • API Layer: tRPC provides automatic type inference from server to client
  • Frontend: All API calls are fully typed with autocomplete and error checking
  • Validation: Zod schemas ensure data integrity at runtime

πŸ“± Responsive Design

The application is fully responsive and works seamlessly across:

  • Desktop (1024px+)
  • Tablet (768px - 1023px)
  • Mobile (320px - 767px)

Key responsive features:

  • Mobile-first navigation with hamburger menu
  • Responsive grid layouts for blog posts
  • Flexible form layouts
  • Touch-friendly button sizes

πŸš€ Deployment

Vercel (Recommended)

  1. Push to GitHub

    git add .
    git commit -m "Initial commit"
    git push origin main
  2. Deploy to Vercel

    • Connect your GitHub repository to Vercel
    • Add environment variables in Vercel dashboard
    • Deploy automatically on push

Environment Variables for Production

DATABASE_URL="your-production-database-url"

🀝 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 MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support

If you have any questions or need help with the project, please:

  1. Check the Issues page
  2. Create a new issue with detailed information
  3. Contact the maintainers

Built with ❀️ using modern web technologies

About

blog-platform

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •