Full-Stack Authentication & Content Management System
This project is a full-stack authentication and content management system built with NestJS (backend) and Next.js (frontend). It supports role-based access control (RBAC) for two types of content:
- Posts: Can be managed by both Users and Admins.
- Blogs: Only Admins can create, update, and delete, while Users can only view.
- Admin: Full CRUD access to Posts & Blogs.
- Regular User: Can create, update, and delete their own Posts but only view Blogs.
- Users sign up and log in using email and password.
- Passwords are securely hashed using bcrypt.
- Authentication is managed using JWT (JSON Web Tokens).
- Frontend validation is implemented with Zod.
- Users are redirected to the dashboard based on their role after login.
- Role-Based Access Control (RBAC) is implemented using NestJS Guards.
- Different permissions for Admin and Regular Users.
- Fields:
image
,content
,date
,author
- Admin & Users can:
- Create new posts
- Update their own posts
- Delete their own posts
- View all posts
- Search & Filter:
- Users can search posts by content or date.
- Pagination is implemented for better performance.
- Fields:
image
,title
,content
,created_at
- Admin can:
- Create, update, delete, and view all blogs.
- Users can:
- Only view blogs.
- Uses Tailwind CSS for a clean and responsive UI.
- Ensures mobile-friendly design.
- NestJS (with TypeScript)
- PostgreSQL (database)
- TypeORM (ORM for database management)
- JWT Authentication (for user sessions)
- Guards (for role-based access control)
- Multer (for image uploads)
- Next.js (React framework for SSR & CSR rendering)
- React Hook Form (with Zod for validation)
- React Query (for efficient API requests)
- Tailwind CSS (for styling)
- Node.js (v16+)
- PostgreSQL
git clone https://github.com/fighteros/flux.git
cd flux
create .env file and file values for env variables from file apps/backend/config/configurations.ts
cd backend
npm install
- Create a
.env
file and configure database credentials:
DB_HOST=host-to-db
DB_PORT=por
DB_USERNAME=you-db-user
DB_PASSWORD=you-db-password
DB_NAME=your-db-name
PORT=port-to-the-backend-server # only in local development
NODE_ENV=development #set to production if deployed
JWT_SECRET=-your-jwt-secert
JWT_EXPIRES_IN='1d' #3600s
CLOUD_NAME=-get-from-cloudinary
CLOUDINARY_API_KEY=-get-from-cloudinary
CLOUDINARY_API_SECRET=-get-from-cloudinary
ADMIN_EMAIL=set-email-for-the-admin-user-that-you-would-seed
ADMIN_PASSWORD=set-admin-password
- Run migrations and start the backend server:
# seed admin user
npm run seed:admin
# seed posts (optional)
npm run seed:posts
# seed blogs (optional)
npm run seed:posts
cd frontend
npm install
npm run dev
- Frontend:
http://localhost:3000
- Backend API:
http://localhost:8000
Feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.