This project is a full-stack blog application built with modern web technologies.
You can view a live demo of the project
- Node.js (v14 or later)
- pnpm
- PostgreSQL database
-
Clone the repository:
git clone https://github.com/Fulwing/BlogDemo.git cd BlogDemo
-
Install dependencies:
pnpm install
-
Set up your environment variables: Create a
.env.local
file in the root directory and add your database URL and any other necessary environment variables. -
Run database migrations:
pnpm drizzle-kit push:pg
-
Start the development server:
pnpm dev
The application should now be running on http://localhost:3000
.
This project utilizes a modern and robust tech stack:
- React: A JavaScript library for building user interfaces.
- Next.js: A React framework that enables server-side rendering and generates static websites for React based web applications.
- Next.js API Routes: Serverless functions that can be deployed as API endpoints.
- PostgreSQL: A powerful, open-source object-relational database system.
- Drizzle ORM: A lightweight and performant TypeScript ORM for SQL databases.
- NextAuth.js: A complete authentication solution for Next.js applications.
- React Hook Form: Performant, flexible and extensible forms with easy-to-use validation.
- Zod: TypeScript-first schema declaration and validation library.
- Tailwind CSS: A utility-first CSS framework for rapidly building custom user interfaces.
- React-Toastify: A React notification library for adding toast notifications to your app.
- Remark: A Markdown processor powered by plugins.
- date-fns: Modern JavaScript date utility library.
- User authentication (sign up, sign in, sign out)
- Create, read, update, and delete blog posts
- Markdown support for writing blog posts
- Cover image upload for blog posts
- Comments system for blog posts
- Responsive design with dark mode support
- Server-side rendering and static site generation capabilities
- Toast notifications for user feedback
The project follows a typical Next.js structure with some additional directories for better organization:
src/
: Contains the main source codeapp/
: Next.js 13+ app directory_components/
: Reusable React componentsauth/
: Authentication-related pages and componentsposts/
: Blog post pagesprotected/
: Protected routes (e.g., add post, edit post)
db/
: Database-related codequeries/
: Database query functionsutils/
: Utility functions for database operations
interfaces/
: TypeScript interfaceslib/
: Utility functions and constants
public/
: Static assetsmigrations/
: Database migration files_posts/
: Markdown files for static blog posts (if applicable)
Key files:
src/app/layout.tsx
: Root layout componentsrc/app/page.tsx
: Home page componentsrc/db/schema.ts
: Database schema definitionssrc/auth.ts
: NextAuth.js configurationtailwind.config.ts
: Tailwind CSS configurationnext.config.js
: Next.js configuration