Skip to content

A modern, feature-rich social feed application built as an experiment with [GitHub's spec-kit](https://github.com/google/spec-kit) methodology.

Notifications You must be signed in to change notification settings

suchithm1999/PostShare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PostShare

A modern, feature-rich social feed application built as an experiment with GitHub's spec-kit methodology.

πŸ“ About This Project

PostShare was created to explore and demonstrate the spec-kit development approach - a specification-driven workflow that emphasizes:

  • Specification-first development: Features are fully specified before implementation
  • Structured planning: Each feature has detailed research, data models, and task breakdowns
  • Incremental delivery: Features are implemented as independent, testable units
  • Documentation-driven: All features are documented in /specs with specifications, plans, and contracts

This project serves as a real-world example of how spec-kit can streamline the development process from idea to implementation.

✨ Features

PostShare is a complete social feed platform with the following capabilities:

Core Functionality

  • πŸ“ Create Posts: Write and share posts with text content
  • πŸ–ΌοΈ Image Support: Attach images to posts with automatic compression (<300KB)
  • ✏️ Edit Posts: Modify post content and images after publishing
  • πŸ—‘οΈ Delete Posts: Remove individual posts or clear entire feed
  • πŸ‘οΈ View Images: Click images to view in full-screen modal
  • πŸŒ“ Dark Mode: Toggle between light and dark themes with system preference sync

Authentication & Security

  • πŸ” JWT Authentication: Secure token-based authentication with access and refresh tokens
  • πŸ“§ Email/Password Signup & Login: Traditional authentication with strong password requirements
  • πŸ”‘ Google OAuth: Sign in with Google for seamless authentication
  • πŸ™ GitHub OAuth: Sign in with GitHub for developer-friendly login
  • πŸ”— Account Linking: Automatically links OAuth and password authentication methods
  • πŸ›‘οΈ Protected Routes: Route-level authentication guards for secure access
  • πŸ”„ Automatic Token Refresh: Seamless session management with refresh token rotation
  • 🚫 Rate Limiting: Login attempt throttling with account lockout protection

Technical Features

  • πŸ’Ύ Database Storage: MongoDB with Vercel integration for persistent data
  • 🌐 Full-Stack Architecture: Express backend API + React frontend
  • πŸ“± Responsive Design: Beautiful UI that works on all screen sizes
  • 🎨 Image Optimization: Automatic compression using browser-image-compression
  • ✨ Modern UI: Glassmorphism effects, smooth animations, gradient accents
  • ⚑ Real-time Updates: Optimistic UI updates without page reloads
  • πŸŒ™ Complete Dark Mode: Full dark theme support across all pages and components

πŸ› οΈ Tech Stack

Frontend

  • Framework: React 18+ with Vite
  • Styling: Tailwind CSS with custom design system
  • Routing: React Router DOM v6
  • Icons: Lucide React
  • Image Processing: browser-image-compression
  • State Management: React Context API

Backend

  • Runtime: Node.js 18+ with Express
  • Database: MongoDB with connection pooling
  • Authentication: JWT (jsonwebtoken) + OAuth 2.0
  • Password Hashing: bcrypt
  • Image Storage: Cloudinary integration
  • Environment: dotenv for configuration

Deployment

  • Platform: Vercel (serverless functions)
  • Database: MongoDB Atlas
  • CDN: Cloudinary for image hosting

πŸ“ Project Structure

PostShare/
β”œβ”€β”€ api/                    # Backend API routes (Vercel serverless)
β”‚   β”œβ”€β”€ auth/
β”‚   β”‚   β”œβ”€β”€ login.js
β”‚   β”‚   β”œβ”€β”€ signup.js
β”‚   β”‚   β”œβ”€β”€ refresh.js
β”‚   β”‚   β”œβ”€β”€ logout.js
β”‚   β”‚   └── oauth/
β”‚   β”‚       β”œβ”€β”€ google.js
β”‚   β”‚       β”œβ”€β”€ github.js
β”‚   β”‚       └── [provider]/callback.js
β”‚   β”œβ”€β”€ posts/
β”‚   └── images/
β”œβ”€β”€ lib/                    # Shared utilities
β”‚   β”œβ”€β”€ auth.js            # JWT & password hashing
β”‚   β”œβ”€β”€ mongodb.js         # Database connection
β”‚   β”œβ”€β”€ cloudinary.js      # Image upload
β”‚   β”œβ”€β”€ errors.js          # Error handling
β”‚   └── middleware.js      # Request validation
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/        # React components
β”‚   β”‚   β”œβ”€β”€ Navbar.jsx
β”‚   β”‚   β”œβ”€β”€ PostCard.jsx
β”‚   β”‚   β”œβ”€β”€ PostForm.jsx
β”‚   β”‚   β”œβ”€β”€ EditPostModal.jsx
β”‚   β”‚   β”œβ”€β”€ ImageModal.jsx
β”‚   β”‚   └── ProtectedRoute.jsx
β”‚   β”œβ”€β”€ pages/             # Route pages
β”‚   β”‚   β”œβ”€β”€ Feed.jsx
β”‚   β”‚   β”œβ”€β”€ CreatePost.jsx
β”‚   β”‚   β”œβ”€β”€ Login.jsx
β”‚   β”‚   β”œβ”€β”€ Signup.jsx
β”‚   β”‚   └── OAuthCallback.jsx
β”‚   β”œβ”€β”€ services/          # API client
β”‚   β”‚   └── apiClient.js
β”‚   β”œβ”€β”€ contexts/          # React Context
β”‚   β”‚   └── AuthContext.jsx
β”‚   └── hooks/             # Custom hooks
β”‚       └── useAuth.js
β”œβ”€β”€ specs/                 # Feature specifications
β”‚   β”œβ”€β”€ 001-static-blog-page/
β”‚   β”œβ”€β”€ 002-clear-feed/
β”‚   β”œβ”€β”€ 003-ui-revamp-theme/
β”‚   β”œβ”€β”€ 004-delete-post-image-opt/
β”‚   β”œβ”€β”€ 005-view-edit-feed/
β”‚   └── 006-vercel-db-storage/  # ← Authentication & Database
└── .specify/              # spec-kit configuration

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ and npm
  • MongoDB Atlas account (free tier works)
  • Google OAuth credentials (optional, for Google login)
  • GitHub OAuth app (optional, for GitHub login)
  • Cloudinary account (for image uploads)

Installation

  1. Clone the repository

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

    npm install
  3. Set up environment variables

    Create a .env.local file in the root directory:

    # Database
    MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/postshare
    
    # JWT Secret (generate a random string)
    JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
    
    # OAuth - Google (optional)
    GOOGLE_CLIENT_ID=your-google-client-id
    GOOGLE_CLIENT_SECRET=your-google-client-secret
    
    # OAuth - GitHub (optional)
    GITHUB_CLIENT_ID=your-github-client-id
    GITHUB_CLIENT_SECRET=your-github-client-secret
    
    # Cloudinary (for image uploads)
    CLOUDINARY_CLOUD_NAME=your-cloud-name
    CLOUDINARY_API_KEY=your-api-key
    CLOUDINARY_API_SECRET=your-api-secret
  4. Initialize the database

    node lib/initDb.js
  5. Start development servers

    For local development with OAuth:

    # Terminal 1: Start backend API
    node start-server.js
    
    # Terminal 2: Start frontend dev server
    npm run dev

    Or use Vercel's dev environment:

    vercel dev
  6. Open your browser Navigate to http://localhost:5174 (or port shown in terminal)

Available Scripts

  • npm run dev - Start Vite development server (frontend only)
  • node start-server.js - Start Express backend server (port 3000)
  • vercel dev - Start full-stack dev environment (recommended)
  • npm run build - Build for production
  • npm run preview - Preview production build locally
  • npm run lint - Run ESLint

OAuth Setup (Optional)

Google OAuth:

  1. Go to Google Cloud Console
  2. Create a new project
  3. Enable Google+ API
  4. Create OAuth credentials
  5. Add to authorized redirect URIs:
    • http://localhost:3000/api/auth/oauth/google/callback (local)
    • Your production URL

GitHub OAuth:

  1. Go to GitHub Settings β†’ Developer settings β†’ OAuth Apps
  2. Create a new OAuth app
  3. Set authorization callback URL:
    • http://localhost:3000/api/auth/oauth/github/callback (local)
    • Your production URL

🎯 Feature Development with spec-kit

Each feature in PostShare follows the spec-kit workflow:

1. Specification (/speckit.specify)

Define what the feature should do from a user perspective:

  • User stories and acceptance criteria
  • Success metrics
  • Functional requirements

2. Planning (/speckit.plan)

Technical design and architecture:

  • Research decisions
  • Data models
  • API contracts
  • Implementation structure

3. Task Generation (/speckit.tasks)

Break down into actionable tasks:

  • Phase-based organization
  • Dependency tracking
  • Parallel execution opportunities

4. Implementation (/speckit.implement)

Execute tasks systematically:

  • Sequential and parallel task execution
  • Validation at each phase
  • Progress tracking

Example Feature: View & Edit Posts (005)

specs/005-view-edit-feed/
β”œβ”€β”€ spec.md              # User-facing specification
β”œβ”€β”€ plan.md              # Technical implementation plan
β”œβ”€β”€ research.md          # Technology decisions
β”œβ”€β”€ data-model.md        # Data structure design
β”œβ”€β”€ contracts/           # API interfaces
β”‚   └── BlogService.ts
β”œβ”€β”€ quickstart.md        # Testing guide
└── tasks.md             # Implementation checklist

πŸ“š Feature History

  1. 001-static-blog-page: Initial post feed and creation (LocalStorage)
  2. 002-clear-feed: Bulk delete functionality
  3. 003-ui-revamp-theme: Dark mode and modern design system
  4. 004-delete-post-image-opt: Single post deletion + image compression
  5. 005-view-edit-feed: Image viewing modal + post editing
  6. 006-vercel-db-storage: Full authentication system βœ…
    • MongoDB database integration
    • JWT authentication with refresh tokens
    • Email/password signup & login
    • Google OAuth 2.0 integration
    • GitHub OAuth 2.0 integration
    • Account linking (OAuth ↔ password)
    • Protected routes & session management
    • Rate limiting & security features

πŸ” Key Learnings from spec-kit

Benefits Experienced:

  • βœ… Clear scope: Each feature has well-defined boundaries
  • βœ… Better planning: Design decisions documented before coding
  • βœ… Easier debugging: Specifications provide reference for expected behavior
  • βœ… Incremental progress: Features can be developed independently
  • βœ… Self-documenting: Specs serve as living documentation

Challenges:

  • πŸ“ Initial overhead in creating detailed specifications
  • πŸ”„ Learning curve for the workflow commands
  • πŸ“Š Maintaining consistency across specification documents

🀝 Contributing

This is an experimental project, but contributions are welcome! Please:

  1. Follow the spec-kit workflow for new features
  2. Create a specification before implementing
  3. Update relevant documentation
  4. Ensure all tasks are completed

πŸ“„ License

This project is open source and available for learning purposes.

πŸ™ Acknowledgments

  • spec-kit by Google for the specification-driven development methodology
  • Tailwind CSS for the utility-first CSS framework
  • Vite for blazing-fast development experience
  • Lucide for beautiful icons

Note: This project was built entirely using the spec-kit methodology as an experiment in specification-driven development. Each feature was carefully planned, documented, and implemented following the workflows provided by spec-kit.

About

A modern, feature-rich social feed application built as an experiment with [GitHub's spec-kit](https://github.com/google/spec-kit) methodology.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors