A modern, feature-rich blogging platform built with Next.js, NestJS, PostgreSQL, and Prisma. Designed for developers to share knowledge, insights, and engage with the community.
- Modern UI/UX: Clean, responsive design with dark/light mode support
- Article Editor: Rich markdown editor with live preview and formatting tools
- User Authentication: Secure login/register with JWT tokens
- User Dashboard: Personal analytics, article management, and profile settings
- Article Reading: Optimized reading experience with comments and engagement
- Explore & Discovery: Advanced search, filtering, and topic-based browsing
- Analytics Dashboard: Comprehensive insights into content performance
- Responsive Design: Mobile-first approach with seamless cross-device experience
- RESTful API: Well-structured API endpoints following REST principles
- Authentication & Authorization: JWT-based auth with role-based access control
- Database Integration: TypeORM with PostgreSQL for robust data management
- Input Validation: Comprehensive validation using class-validator
- Error Handling: Centralized error handling with proper HTTP status codes
- Security: CORS, rate limiting, and input sanitization
- Relational Data Model: Optimized schema for users, articles, comments, and analytics
- Data Integrity: Foreign key constraints and proper indexing
- Performance: Query optimization and connection pooling
- Migrations: Version-controlled database schema changes
- Framework: Next.js 14 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS + shadcn/ui
- State Management: React Hooks + Context API
- Authentication: JWT tokens with secure storage
- Icons: Lucide React
- Forms: React Hook Form + Zod validation
- Framework: NestJS
- Language: TypeScript
- Database ORM: TypeORM
- Authentication: JWT + Passport
- Validation: class-validator + class-transformer
- Security: bcryptjs for password hashing
- Primary Database: PostgreSQL
- ORM: TypeORM
- Schema Management: TypeORM migrations
- Frontend Hosting: Vercel
- Backend Hosting: Railway/Heroku
- Database Hosting: Supabase/Railway
- Version Control: Git + GitHub
Before running this project, make sure you have:
- Node.js (v18 or higher)
- npm or yarn
- PostgreSQL (v12 or higher)
- Git
```bash git clone https://github.com/yourusername/devblog.git cd devblog ```
```bash
cd frontend
npm install
cp .env.example .env.local
NEXT_PUBLIC_API_URL=http://localhost:3001
NEXT_PUBLIC_APP_URL=http://localhost:3000
```
```bash
cd backend
npm install
npm install -g @nestjs/cli
cp .env.example .env
```
```bash
createdb devblog_db
npm run migration:run
npm run seed ```
```bash
cd backend npm run start:dev
cd frontend npm run dev ```
Visit http://localhost:3000 to see the application running!
```env
NEXT_PUBLIC_API_URL=http://localhost:3001 NEXT_PUBLIC_APP_URL=http://localhost:3000
NEXTAUTH_SECRET=your-nextauth-secret NEXTAUTH_URL=http://localhost:3000 ```
```env
DB_HOST=localhost DB_PORT=5432 DB_USERNAME=postgres DB_PASSWORD=your_postgres_password DB_DATABASE=devblog_db
JWT_SECRET=your-super-secret-jwt-key-here JWT_EXPIRES_IN=7d
PORT=3001 NODE_ENV=development
CORS_ORIGIN=http://localhost:3000 ```
```sql
- id (UUID, Primary Key)
- username (String, Unique)
- email (String, Unique)
- password (String, Hashed)
- name (String)
- bio (Text, Optional)
- avatar (String, Optional)
- website (String, Optional)
- location (String, Optional)
- followersCount (Integer, Default: 0)
- followingCount (Integer, Default: 0)
- createdAt (Timestamp)
- updatedAt (Timestamp) ```
```sql
- id (UUID, Primary Key)
- title (String)
- slug (String, Unique)
- content (Text)
- excerpt (Text, Optional)
- coverImage (String, Optional)
- status (Enum: draft, published, archived)
- tags (Array of Strings)
- views (Integer, Default: 0)
- likes (Integer, Default: 0)
- commentsCount (Integer, Default: 0)
- readTime (Integer, Optional)
- publishedAt (Timestamp, Optional)
- authorId (UUID, Foreign Key)
- createdAt (Timestamp)
- updatedAt (Timestamp) ```
```sql
- id (UUID, Primary Key)
- content (Text)
- likes (Integer, Default: 0)
- authorId (UUID, Foreign Key)
- articleId (UUID, Foreign Key)
- createdAt (Timestamp)
- updatedAt (Timestamp) ```
``` POST /auth/register - User registration POST /auth/login - User login POST /auth/logout - User logout GET /auth/profile - Get current user profile PUT /auth/profile - Update user profile ```
``` GET /articles - Get all articles (with pagination) GET /articles/:slug - Get article by slug POST /articles - Create new article (auth required) PUT /articles/:id - Update article (auth required) DELETE /articles/:id - Delete article (auth required) GET /articles/user/:id - Get articles by user ```
``` GET /comments/article/:id - Get comments for article POST /comments - Create comment (auth required) PUT /comments/:id - Update comment (auth required) DELETE /comments/:id - Delete comment (auth required) ```
``` GET /analytics/overview - Get user analytics overview GET /analytics/articles - Get article performance data GET /analytics/audience - Get audience demographics ```
- Navbar: Responsive navigation with user menu
- Hero Section: Landing page hero with call-to-action
- Article Card: Reusable article preview component
- Comment Section: Nested comments with replies
- Editor: Rich markdown editor with toolbar
- Analytics Dashboard: Charts and metrics visualization
- Button, Input, Textarea, Select
- Card, Badge, Avatar, Separator
- Dialog, Dropdown Menu, Tabs
- Toast notifications, Loading states
- Form components with validation
/- Home page with featured articles/explore- Discover articles with search and filters/topics- Browse articles by topics/article/[slug]- Individual article reading page/login- User authentication/register- User registration
/dashboard- User dashboard with analytics/editor- Article creation and editing/settings- User profile and account settings/analytics- Detailed analytics dashboard
- XSS Protection: Input sanitization and CSP headers
- CSRF Protection: Token-based request validation
- Secure Storage: JWT tokens in httpOnly cookies
- Route Protection: Authentication guards for protected routes
- Password Hashing: bcryptjs with salt rounds
- JWT Authentication: Secure token-based auth
- Input Validation: Comprehensive request validation
- Rate Limiting: API endpoint protection
- CORS Configuration: Controlled cross-origin requests
- Code Splitting: Dynamic imports for route-based splitting
- Image Optimization: Next.js Image component with lazy loading
- Caching: Static generation and incremental static regeneration
- Bundle Analysis: Webpack bundle analyzer integration
- Database Indexing: Optimized queries with proper indexes
- Connection Pooling: Efficient database connection management
- Caching: Redis integration for frequently accessed data
- Compression: Gzip compression for API responses
```bash
npm run test
npm run test:integration
npm run test:e2e ```
```bash
npm run test
npm run test:e2e
npm run test:cov ```
- Connect your GitHub repository to Vercel
- Configure environment variables in Vercel dashboard
- Deploy automatically on push to main branch
- Create new app on Railway/Heroku
- Connect GitHub repository
- Configure environment variables
- Set up PostgreSQL addon
- Deploy with automatic builds
- Create PostgreSQL instance
- Run migrations in production
- Configure connection pooling
- Set up backups and monitoring
```bash
git checkout -b feature/article-editor
git add . git commit -m "feat: add article editor with markdown support"
git push origin feature/article-editor ```
```bash
npm run migration:generate -- -n AddUserProfile
npm run migration:run
npm run migration:revert ```
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Use TypeScript for type safety
- Follow ESLint and Prettier configurations
- Write meaningful commit messages
- Add tests for new features
- Update documentation as needed
This project is licensed under the MIT License - see the LICENSE file for details.
- Next.js - React framework
- NestJS - Node.js framework
- shadcn/ui - UI component library
- Tailwind CSS - CSS framework
- PostgreSQL - Database
- TypeORM - ORM
- Vercel - Deployment platform
If you have any questions or need help, please:
- Check the Issues page
- Create a new issue with detailed description
- Join our Discord community
- Email us at support@devblog.com
Built with β€οΈ by the DevBlog Team