Skip to content

ahmednasser111/threads

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

49 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧡 Threads β€” Full-Stack Social Media App

A feature-rich, full-stack social media application inspired by Meta's Threads, built with Next.js 15, MongoDB, Clerk Authentication, and UploadThing. Users can create threads, reply, like, repost, search for other users, join communities, and more β€” all wrapped in a sleek dark-themed UI.

Next.js React MongoDB Clerk TailwindCSS TypeScript


✨ Features

  • πŸ” Authentication β€” Secure sign-up, sign-in, and onboarding flow powered by Clerk with a dark theme.
  • πŸ“ Create Threads β€” Share your thoughts by creating new threads with rich text input.
  • πŸ’¬ Nested Replies β€” Comment on threads and engage in nested, threaded conversations.
  • ❀️ Like Threads β€” Like and unlike threads with real-time feedback.
  • πŸ” Repost Threads β€” Repost threads to amplify content you enjoy.
  • πŸ”— Share Threads β€” Share threads via a convenient share button.
  • πŸ—‘οΈ Delete Threads β€” Remove your own threads with a confirmation modal.
  • πŸ” Search Users β€” Discover other users on the platform with the search bar.
  • πŸ‘€ User Profiles β€” View user profiles with profile headers, bio, and tabbed content (Threads, Replies, Tagged).
  • 🏘️ Communities β€” Browse and join communities with dedicated community pages and member listings.
  • πŸ“Έ Image Uploads β€” Upload profile images via UploadThing.
  • πŸ“„ Pagination β€” Paginated feeds for smooth browsing through threads.
  • πŸ“± Responsive Design β€” Fully responsive layout with a top bar, left sidebar, right sidebar, and mobile bottom bar.
  • πŸ”” Activity Feed β€” Stay updated with an activity page for notifications.
  • 🌐 Webhooks β€” Real-time data sync with Clerk via webhook integration (Svix).
  • 🎨 Dark Theme β€” Beautiful dark-mode interface throughout the entire application.

πŸ› οΈ Tech Stack

Category Technology
Framework Next.js 15 (App Router)
Language TypeScript 5
UI Library React 19
Styling Tailwind CSS 4 + tailwindcss-animate
Authentication Clerk (@clerk/nextjs, @clerk/themes)
Database MongoDB with Mongoose
File Uploads UploadThing
Forms React Hook Form + Zod
UI Components Radix UI (Tabs, Label, Slot)
Icons Lucide React
Notifications Sonner (Toast notifications)
Webhooks Svix
Font Inter (Google Fonts)

πŸ“ Project Structure

threads/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ (auth)/                  # Authentication pages
β”‚   β”‚   β”œβ”€β”€ layout.tsx           # Auth layout with dark Clerk theme
β”‚   β”‚   β”œβ”€β”€ sign-in/             # Sign-in page
β”‚   β”‚   β”œβ”€β”€ sign-up/             # Sign-up page
β”‚   β”‚   └── onboarding/          # User onboarding flow
β”‚   β”œβ”€β”€ (root)/                  # Main application pages
β”‚   β”‚   β”œβ”€β”€ layout.tsx           # Root layout (Topbar, Sidebars, Bottombar)
β”‚   β”‚   β”œβ”€β”€ page.tsx             # Home feed
β”‚   β”‚   β”œβ”€β”€ activity/            # Activity / notifications page
β”‚   β”‚   β”œβ”€β”€ communities/         # Communities listing & detail pages
β”‚   β”‚   β”œβ”€β”€ create-thread/       # Create new thread page
β”‚   β”‚   β”œβ”€β”€ profile/[id]/        # User profile page
β”‚   β”‚   β”œβ”€β”€ search/              # User search page
β”‚   β”‚   └── thread/              # Individual thread page
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ uploadthing/         # UploadThing API routes
β”‚   β”‚   └── webhooks/clerk/      # Clerk webhook handler
β”‚   β”œβ”€β”€ globals.css              # Global styles
β”‚   └── favicon.ico
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ cards/                   # Card components
β”‚   β”‚   β”œβ”€β”€ ThreadCard.tsx       # Thread display card
β”‚   β”‚   β”œβ”€β”€ CommunityCard.tsx    # Community display card
β”‚   β”‚   β”œβ”€β”€ UserCard.tsx         # User display card
β”‚   β”‚   β”œβ”€β”€ ThreadLikeButton.tsx # Like interaction button
β”‚   β”‚   β”œβ”€β”€ ThreadRepostButton.tsx # Repost interaction button
β”‚   β”‚   └── ThreadShareButton.tsx  # Share interaction button
β”‚   β”œβ”€β”€ forms/                   # Form components
β”‚   β”‚   β”œβ”€β”€ AccountProfile.tsx   # Profile edit form
β”‚   β”‚   β”œβ”€β”€ PostThread.tsx       # Create thread form
β”‚   β”‚   β”œβ”€β”€ Comment.tsx          # Comment/reply form
β”‚   β”‚   β”œβ”€β”€ DeleteThread.tsx     # Thread deletion handler
β”‚   β”‚   └── ConfirmDeleteModal.tsx # Deletion confirmation modal
β”‚   β”œβ”€β”€ shared/                  # Shared layout components
β”‚   β”‚   β”œβ”€β”€ Topbar.tsx           # Top navigation bar
β”‚   β”‚   β”œβ”€β”€ LeftSidebar.tsx      # Left sidebar navigation
β”‚   β”‚   β”œβ”€β”€ RightSidebar.tsx     # Right sidebar (suggestions)
β”‚   β”‚   β”œβ”€β”€ Bottombar.tsx        # Mobile bottom navigation
β”‚   β”‚   β”œβ”€β”€ ProfileHeader.tsx    # User profile header
β”‚   β”‚   β”œβ”€β”€ ThreadsTab.tsx       # Threads tab content
β”‚   β”‚   β”œβ”€β”€ RepostsTab.tsx       # Reposts tab content
β”‚   β”‚   β”œβ”€β”€ Searchbar.tsx        # Search input component
β”‚   β”‚   β”œβ”€β”€ Pagination.tsx       # Pagination controls
β”‚   β”‚   └── PaginationWrapper.tsx
β”‚   └── ui/                      # Radix-based UI primitives
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ actions/                 # Server actions
β”‚   β”‚   β”œβ”€β”€ thread.actions.ts    # Thread CRUD operations
β”‚   β”‚   β”œβ”€β”€ user.actions.ts      # User CRUD operations
β”‚   β”‚   └── community.actions.ts # Community CRUD operations
β”‚   β”œβ”€β”€ models/                  # Mongoose models
β”‚   β”‚   β”œβ”€β”€ thread.model.ts      # Thread schema
β”‚   β”‚   β”œβ”€β”€ user.model.ts        # User schema
β”‚   β”‚   └── community.model.ts   # Community schema
β”‚   β”œβ”€β”€ validations/             # Zod validation schemas
β”‚   β”‚   β”œβ”€β”€ thread.ts            # Thread form validation
β”‚   β”‚   └── user.ts              # User form validation
β”‚   β”œβ”€β”€ mongoose.ts              # MongoDB connection utility
β”‚   β”œβ”€β”€ uploadthing.ts           # UploadThing configuration
β”‚   └── utils.ts                 # Utility functions
β”œβ”€β”€ constants/
β”‚   └── index.js                 # Sidebar links, profile & community tabs
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ assets/                  # SVG icons and assets
β”‚   └── logo.svg                 # App logo
β”œβ”€β”€ middleware.ts                # Clerk auth middleware
β”œβ”€β”€ next.config.ts               # Next.js configuration
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
└── tailwind / postcss configs

πŸš€ Getting Started

Prerequisites

1. Clone the Repository

git clone https://github.com/ahmednasser111/threads.git
cd threads

2. Install Dependencies

yarn install
# or
npm install

3. Set Up Environment Variables

Create a .env.local file in the project root with the following variables:

# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_xxxxx
CLERK_SECRET_KEY=sk_test_xxxxx
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/onboarding
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/onboarding

# MongoDB
MONGODB_URI=mongodb+srv://<username>:<password>@cluster.mongodb.net/threads

# UploadThing
UPLOADTHING_SECRET=sk_live_xxxxx
UPLOADTHING_APP_ID=xxxxx

# Clerk Webhook (Svix)
CLERK_WEBHOOK_SECRET=whsec_xxxxx

4. Run the Development Server

yarn dev
# or
npm run dev

Open http://localhost:3000 in your browser to see the app.


πŸ“¦ Scripts

Command Description
yarn dev Start the development server
yarn build Build the production application
yarn start Start the production server
yarn lint Run ESLint for code quality checks

πŸ—„οΈ Database Models

User

Field Type Description
id String Clerk user ID (unique)
username String Unique username
name String Display name
image String Profile image URL
bio String User bio (max 500 chars)
threads ObjectId[] References to authored threads
onboarded Boolean Whether onboarding is completed
communities ObjectId[] Communities the user belongs to

Thread

Field Type Description
text String Thread content
author ObjectId Reference to the author (User)
community ObjectId Reference to a community
createdAt Date Timestamp of creation
parentId String Parent thread ID (for replies)
likes String[] Array of user IDs who liked
reposts String[] Array of user IDs who reposted
children ObjectId[] References to child threads

Community

Field Type Description
id String Clerk organization ID
username String Unique community handle
name String Community display name
image String Community image URL
bio String Community description
createdBy ObjectId Reference to creator (User)
threads ObjectId[] References to community threads
members ObjectId[] References to community members

πŸ”— API Routes

Route Method Description
/api/uploadthing POST Handle file uploads via UploadThing
/api/webhooks/clerk POST Handle Clerk webhook events (Svix)

🀝 Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

  1. Fork the repository
  2. Create your 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 open source and available under the MIT License.


πŸ™ Acknowledgments

  • Next.js β€” The React framework for production
  • Clerk β€” Authentication and user management
  • MongoDB β€” NoSQL database
  • UploadThing β€” File upload service
  • Radix UI β€” Accessible UI primitives
  • Tailwind CSS β€” Utility-first CSS framework

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors