Skip to content

omkcan/stackit

ย 
ย 

Repository files navigation

StackIt ๐Ÿš€

Ask, Answer, Elevate Your Code - A modern Q&A platform for developers

Next.js TypeScript PostgreSQL Drizzle ORM Tailwind CSS

โœจ Features

  • ๐Ÿ” Q&A Hub - Ask programming questions and get expert answers
  • ๐Ÿ’ฌ Threaded Comments - Multi-level comment system with GIF support
  • โญ Voting System - Upvote/downvote posts and comments
  • ๐Ÿ† Reputation & Badges - Earn points for valuable contributions
  • ๐Ÿ”” Real-time Notifications - Get notified when someone responds
  • ๐Ÿ” Secure Authentication - OTP-based login with email verification
  • ๐Ÿ‘ฎโ€โ™‚๏ธ Content Moderation - Advanced reporting and moderation system
  • ๐ŸŽจ Beautiful UI - Modern design with smooth animations
  • ๐Ÿ“ฑ PWA Support - Installable as a mobile app
  • ๐ŸŒ™ Dark/Light Mode - Customizable theme preferences

๐Ÿ› ๏ธ Tech Stack

Frontend

  • Framework: Next.js 14 with App Router
  • Language: TypeScript
  • Styling: Tailwind CSS with custom animations
  • UI Components: Radix UI primitives
  • Animations: Framer Motion
  • Icons: Lucide React, Tabler Icons

Backend

  • Database: PostgreSQL
  • ORM: Drizzle ORM
  • Authentication: Custom token-based auth with OTP
  • Email: Resend API
  • Rate Limiting: Built-in rate limiting
  • Security: Cloudflare Turnstile CAPTCHA

Additional Features

  • Rich Text Editor: MDX Editor with markdown support
  • GIF Support: Giphy API integration
  • PWA: Next.js PWA with offline support
  • Analytics: Performance monitoring

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+
  • PostgreSQL database
  • pnpm (recommended) or npm

Installation

  1. Clone the repository

    git clone https://github.com/shravanasati/stackit.git
    cd stackit
  2. Install dependencies

    pnpm install
  3. Set up environment variables Create a .env.local file in the root directory:

    # Database Configuration
    DB_HOST=localhost
    DB_PORT=5432
    DB_USER=your_username
    DB_PASSWORD=your_password
    DB_NAME=stackit
    DB_SSL=false
    DATABASE_URL=postgresql://your_username:your_password@localhost:5432/stackit
    
    # Authentication
    SECRET_KEY=your_secret_key_here
    SALT=your_salt_here
    
    # Email (Resend)
    RESEND_API_KEY=your_resend_api_key
    
    # Captcha (Cloudflare Turnstile)
    TURNSTILE_SECRET_KEY=your_turnstile_secret
    
    # Moderation
    MODERATOR_EMAILS=[email protected],[email protected]
    
    # Discord Webhook (Optional)
    DISCORD_WEBHOOK_URL=your_discord_webhook_url
    
    # Environment
    NODE_ENV=development
  4. Set up the database

    # Generate database schema
    pnpm run db:generate
    
    # Apply migrations
    pnpm run db:push
  5. Start the development server

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

๐Ÿ“ Project Structure

stackit/
โ”œโ”€โ”€ app/                    # Next.js App Router pages
โ”‚   โ”œโ”€โ”€ api/               # API routes
โ”‚   โ”œโ”€โ”€ admin/             # Admin dashboard
โ”‚   โ”œโ”€โ”€ create/            # Post creation
โ”‚   โ”œโ”€โ”€ feed/              # Main feed
โ”‚   โ”œโ”€โ”€ login/             # Authentication
โ”‚   โ””โ”€โ”€ post/              # Individual post pages
โ”œโ”€โ”€ components/            # React components
โ”‚   โ”œโ”€โ”€ LandingPage/       # Landing page sections
โ”‚   โ”œโ”€โ”€ Posts/             # Post-related components
โ”‚   โ”œโ”€โ”€ ui/                # Reusable UI components
โ”‚   โ””โ”€โ”€ Gradients/         # Background components
โ”œโ”€โ”€ lib/                   # Core business logic
โ”‚   โ”œโ”€โ”€ actions/           # Server actions
โ”‚   โ”œโ”€โ”€ database/          # Database operations
โ”‚   โ””โ”€โ”€ utils/             # Utility functions
โ”œโ”€โ”€ hooks/                 # Custom React hooks
โ”œโ”€โ”€ migrations/            # Database migrations
โ””โ”€โ”€ public/                # Static assets

๐Ÿ—„๏ธ Database Schema

StackIt uses PostgreSQL with the following main tables:

  • posts - Questions/posts with voting and moderation
  • comments - Threaded comments with GIF support
  • tokens - User authentication tokens
  • notifications - User notifications system
  • reports - Content moderation reports
  • otp - One-time passwords for authentication
  • security_logs - Admin activity logging

๐Ÿ”ง Available Scripts

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

# Database
pnpm db:generate      # Generate database migrations
pnpm db:migrate       # Apply migrations
pnpm db:push          # Push schema changes
pnpm db:studio        # Open Drizzle Studio

๐Ÿณ Docker Support

Build and run with Docker:

# Build the Docker image
docker build -t stackit .

# Run the container
docker run -p 3000:3000 --env-file .env.local stackit

๐Ÿ“Š Key Features Deep Dive

Authentication System

  • OTP-based login with email verification
  • Role-based access (user, admin)
  • Secure token management with automatic expiration
  • Rate limiting to prevent abuse

Content Management

  • Rich text editor with markdown support
  • Tag system for categorizing posts
  • Multi-level comments with threaded replies
  • GIF integration via Giphy API
  • Vote system for quality control

Moderation Tools

  • Content reporting system
  • Admin dashboard for moderation
  • Automated content filtering
  • Security logging for audit trails

Performance & UX

  • Progressive Web App (PWA) support
  • Infinite scrolling for posts
  • Real-time notifications
  • Responsive design for all devices
  • Smooth animations with Framer Motion

๐Ÿ” Security Features

  • CAPTCHA protection with Cloudflare Turnstile
  • Rate limiting on all sensitive endpoints
  • Content sanitization to prevent XSS
  • SQL injection protection via Drizzle ORM
  • Secure authentication with encrypted tokens

๐Ÿš€ Deployment

Vercel (Recommended)

  1. Connect your repository to Vercel
  2. Set environment variables in Vercel dashboard
  3. Deploy - Vercel will automatically build and deploy

Manual Deployment

  1. Build the project

    pnpm build
  2. Start the production server

    pnpm start

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add 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

  • Next.js team for the amazing framework
  • Drizzle Team for the excellent ORM
  • Radix UI for accessible component primitives
  • Vercel for hosting and deployment platform

๐Ÿ“ž Support


Built with โค๏ธ by the StackIt team

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 97.7%
  • CSS 2.2%
  • JavaScript 0.1%