StackIt is a minimal question-and-answer platform that supports collaborative learning and structured knowledge sharing. It's designed to be simple, user-friendly, and focused on the core experience of asking and answering questions within a community.
- Ask Questions: Users can submit questions with titles, rich text descriptions, and tags
- Rich Text Editor: Support for formatting, lists, links, images, and text alignment
- Answer Questions: Users can post formatted answers to questions
- Voting System: Upvote/downvote questions and answers
- Accept Answers: Question owners can mark answers as accepted
- Tagging System: Questions must include relevant tags for categorization
- Notification System: Real-time notifications for answers, comments, and mentions
- Guest: View all questions and answers
- User: Register, log in, post questions/answers, vote
- Admin: Moderate content, ban users, view platform statistics
- Bold, Italic, Strikethrough
- Numbered lists, Bullet points
- Emoji insertion
- Hyperlink insertion (URL)
- Image upload
- Text alignment – Left, Center, Right
- Node.js with Express.js
- MongoDB Atlas for database
- Mongoose for ODM
- JWT for authentication
- bcryptjs for password hashing
- Cloudinary for image uploads
- Express Validator for input validation
- React with functional components and hooks
- React Router for navigation
- React Quill for rich text editing
- Tailwind CSS for styling
- Axios for API communication
- React Hot Toast for notifications
stackit/
├── backend/
│ ├── index.js # Main server file
│ ├── middleware/
│ │ └── auth.js # Authentication middleware
│ ├── routes/
│ │ ├── auth.js # Authentication routes
│ │ ├── questions.js # Question management
│ │ ├── answers.js # Answer management
│ │ ├── users.js # User management
│ │ └── notifications.js # Notification system
│ └── data/
│ └── db.js # In-memory database
├── frontend/
│ ├── src/
│ │ ├── components/
│ │ │ └── Navbar.js # Navigation component
│ │ ├── contexts/
│ │ │ └── AuthContext.js # Authentication context
│ │ ├── pages/
│ │ │ ├── Home.js # Home page
│ │ │ ├── Login.js # Login page
│ │ │ ├── Register.js # Registration page
│ │ │ ├── AskQuestion.js # Ask question page
│ │ │ ├── QuestionDetail.js # Question detail page
│ │ │ ├── Profile.js # User profile page
│ │ │ └── Admin.js # Admin dashboard
│ │ ├── App.js # Main app component
│ │ └── index.js # React entry point
│ ├── package.json # Frontend dependencies
│ └── tailwind.config.js # Tailwind configuration
├── package.json # Backend dependencies
└── README.md # This file
- Node.js (v14 or higher)
- npm or yarn
- MongoDB Atlas account
- Cloudinary account (optional, for image uploads)
-
Clone the repository
git clone <repository-url> cd stackit
-
Install dependencies
npm run install-all
-
Configure environment variables
- Copy
.env.exampleto.env - Update the following variables:
MONGODB_URI: Your MongoDB Atlas connection stringJWT_SECRET: A secure random string for JWT signingCLOUDINARY_CLOUD_NAME: Your Cloudinary cloud nameCLOUDINARY_API_KEY: Your Cloudinary API keyCLOUDINARY_API_SECRET: Your Cloudinary API secret
- Copy
-
Seed the database
npm run seed
-
Start the development servers
# Start both backend and frontend npm run dev # Or start them separately: npm run server # Backend on port 5000 npm run client # Frontend on port 3000
-
Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:5000
After seeding the database, you can login with:
- Admin: admin@stackit.com / admin123
- User: john@example.com / user123
POST /api/auth/register- User registrationPOST /api/auth/login- User loginGET /api/auth/me- Get current userPUT /api/auth/profile- Update profile
GET /api/questions- Get all questions (with pagination, search, tags)GET /api/questions/:id- Get single questionPOST /api/questions- Create new questionPUT /api/questions/:id- Update questionDELETE /api/questions/:id- Delete questionPOST /api/questions/:id/vote- Vote on questionPOST /api/questions/:id/accept-answer/:answerId- Accept answerGET /api/questions/tags/popular- Get popular tags
GET /api/answers/question/:questionId- Get answers for questionPOST /api/answers- Create new answerPUT /api/answers/:id- Update answerDELETE /api/answers/:id- Delete answerPOST /api/answers/:id/vote- Vote on answerGET /api/answers/:id- Get single answer
GET /api/users/:id- Get user profileGET /api/users- Get all users (admin only)PUT /api/users/:id/ban- Ban user (admin only)PUT /api/users/:id/unban- Unban user (admin only)GET /api/users/:id/stats- Get user statistics
GET /api/notifications- Get user notificationsGET /api/notifications/unread-count- Get unread countPUT /api/notifications/:id/read- Mark notification as readPUT /api/notifications/mark-all-read- Mark all as readDELETE /api/notifications/:id- Delete notificationPOST /api/notifications/broadcast- Send platform-wide message (admin only)
GET /api/users/tags/popular- Get popular tagsGET /api/questions/tags/popular- Get popular tags from questions
The application comes with sample data including:
- Admin user (username: admin, email: admin@stackit.com)
- Sample user (username: john_doe, email: john@example.com)
- Sample questions and answers
- Popular tags
The platform uses React Quill for rich text editing, supporting:
- Text formatting (bold, italic, underline, strikethrough)
- Lists (ordered and unordered)
- Text alignment
- Links and images
- Code blocks
- Real-time notifications for new answers
- Unread notification count in navbar
- Notification dropdown with recent notifications
- Mark as read functionality
- User management (view all users, ban/unban)
- Platform statistics dashboard
- Content moderation capabilities
- Mobile-first approach
- Responsive navigation
- Optimized for all screen sizes
- Create new routes in
backend/routes/ - Add corresponding frontend components in
frontend/src/ - Update the main server file to include new routes
- Test thoroughly before deployment
The current implementation uses in-memory storage. To add a real database:
- Install database driver (e.g.,
mongoosefor MongoDB) - Replace data access in
server/data/db.js - Update environment variables for database connection
The project uses Tailwind CSS. To add custom styles:
- Modify
client/tailwind.config.js - Add custom classes in
client/src/index.css - Use Tailwind utility classes in components
- Set environment variables (JWT_SECRET, PORT, etc.)
- Install production dependencies
- Build the application
- Use a process manager like PM2
- Build the React app:
npm run build - Serve the
buildfolder - Configure reverse proxy for API calls
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License.
For support or questions, please open an issue in the repository.