|
| 1 | +# Q&A Platform with RBAC |
1 | 2 |
|
| 3 | +> A modern Q&A platform built with Next.js and Clerk, featuring role-based access control. Ask questions, share knowledge, and learn from others in a secure, well-structured environment. |
2 | 4 |
|
3 |
| -## Getting Started |
| 5 | + |
4 | 6 |
|
5 |
| -1. Clone the repository: |
| 7 | +## 🌟 Features |
| 8 | + |
| 9 | +- **Authentication & Authorization** |
| 10 | + - Secure authentication with Clerk |
| 11 | + - Role-based access control (RBAC) |
| 12 | + - Protected routes and API endpoints |
| 13 | + |
| 14 | +- **Core Functionality** |
| 15 | + - Ask and answer questions |
| 16 | + - Search users and questions |
| 17 | + - Admin dashboard for content moderation |
| 18 | + - Real-time updates |
| 19 | + |
| 20 | +## 🚀 Getting Started |
| 21 | + |
| 22 | +### Prerequisites |
6 | 23 |
|
| 24 | +- Node.js 18+ |
| 25 | +- npm/yarn |
| 26 | +- A Clerk account |
| 27 | +- A Neon Database account |
| 28 | + |
| 29 | +### Installation |
| 30 | + |
| 31 | +1. Clone the repository: |
7 | 32 | ```bash
|
8 | 33 | git clone https://github.com/tyaga001/clerk-qa-platform
|
| 34 | +cd clerk-qa-platform |
9 | 35 | ```
|
10 | 36 |
|
11 |
| -2. Install the dependencies |
12 |
| - |
| 37 | +2. Install dependencies: |
13 | 38 | ```bash
|
14 | 39 | npm install
|
15 | 40 | ```
|
16 | 41 |
|
17 |
| -3. Set up a Clerk application and Neon database. Then create a Create a .env.local file in the root directory of the project and add the following keys |
18 |
| - |
| 42 | +3. Set up environment variables: |
19 | 43 | ```bash
|
20 |
| -NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY= |
21 |
| -CLERK_SECRET_KEY= |
22 |
| -NEON_DATABASE_URL= |
| 44 | +# Create a .env file in the root directory and add: |
| 45 | +NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_publishable_key |
| 46 | +CLERK_SECRET_KEY=your_secret_key |
| 47 | +NEON_DATABASE_URL=your_database_url |
23 | 48 | ```
|
24 | 49 |
|
25 |
| -4. Initialize the database |
| 50 | +4. Initialize the database: |
| 51 | +```bash |
| 52 | +npx drizzle-kit push |
| 53 | +``` |
26 | 54 |
|
| 55 | +5. Start the development server: |
27 | 56 | ```bash
|
28 |
| -npx drizzle-kit push |
| 57 | +npm run dev |
| 58 | +``` |
| 59 | + |
| 60 | +Visit `http://localhost:3000` to see the application. |
| 61 | + |
| 62 | +## 🏗️ Project Structure |
| 63 | + |
29 | 64 | ```
|
| 65 | +clerk-qa-platform/ |
| 66 | +├── .idea/ # IDE configuration |
| 67 | +├── .next/ # Next.js build output |
| 68 | +├── drizzle/ # Drizzle ORM files |
| 69 | +├── node_modules/ # Dependencies |
| 70 | +├── public/ # Static files |
| 71 | +├── src/ # Source code |
| 72 | +│ ├── app/ # Next.js app directory |
| 73 | +│ │ ├── admin/ # Admin dashboard |
| 74 | +│ │ ├── api/ # API routes |
| 75 | +│ │ ├── qa/ # Q&A features |
| 76 | +│ │ └── searchUsers/# User search functionality |
| 77 | +│ ├── components/ # React components |
| 78 | +│ ├── db/ # Database configurations |
| 79 | +│ ├── lib/ # Utility libraries |
| 80 | +│ ├── types/ # TypeScript types |
| 81 | +│ └── utils/ # Utility functions |
| 82 | +├── .env # Environment variables |
| 83 | +├── .gitignore # Git ignore rules |
| 84 | +├── favicon.ico # Site favicon |
| 85 | +├── globals.css # Global styles |
| 86 | +├── layout.tsx # Root layout |
| 87 | +├── middleware.ts # Auth middleware |
| 88 | +└── page.tsx # Root page |
| 89 | +``` |
| 90 | + |
| 91 | +## 🔐 Role-Based Access Control |
30 | 92 |
|
31 |
| -5. Start the Next.js development server |
| 93 | +The platform implements three main roles: |
| 94 | +- **Admin**: Full access to all features |
| 95 | +- **Moderator**: Can moderate content |
| 96 | +- **User**: Can ask and answer questions |
32 | 97 |
|
| 98 | +## 📝 Environment Variables |
| 99 | + |
| 100 | +Required environment variables: |
33 | 101 | ```bash
|
34 |
| -npm run dev |
| 102 | +NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY= |
| 103 | +CLERK_SECRET_KEY= |
| 104 | +NEON_DATABASE_URL= |
35 | 105 | ```
|
| 106 | + |
| 107 | +## 🤝 Contributing |
| 108 | + |
| 109 | +Contributions are welcome. Please feel free to submit a Pull Request. |
| 110 | + |
| 111 | +1. Fork the repository |
| 112 | +2. Create your feature branch (`git checkout -b feature/AmazingFeature`) |
| 113 | +3. Commit your changes (`git commit -m 'Add some AmazingFeature'`) |
| 114 | +4. Push to the branch (`git push origin feature/AmazingFeature`) |
| 115 | +5. Open a Pull Request |
| 116 | + |
| 117 | +## 📄 License |
| 118 | + |
| 119 | +This project is licensed under the Creative Commons License - see the [LICENSE](LICENSE) file for details. |
| 120 | + |
| 121 | +## 👏 Acknowledgments |
| 122 | + |
| 123 | +- [Clerk](https://clerk.dev/) for authentication |
| 124 | +- [Neon](https://neon.tech/) for the database |
0 commit comments