A modern, flexible headless CMS built with React, GraphQL, and MongoDB. This project provides a robust content management system with a clean and intuitive user interface.
- 🚀 Modern Stack: Built with React, GraphQL, and MongoDB
- 🔐 Authentication & Authorization: Role-based access control with admin, editor, and author roles
- 📝 Content Types: Create and manage custom content types with flexible fields
- 🗃️ Content Management: Create, edit, publish, and archive content entries
- 🖼️ Media Library: Upload and manage media assets
- 👥 User Management: Manage users and their permissions
- 🎨 Beautiful UI: Clean and intuitive interface built with Tailwind CSS
- 📱 Responsive Design: Works seamlessly on desktop and mobile devices
-
Frontend:
- React
- Apollo Client
- React Router
- React Hook Form
- Tailwind CSS
- Lucide Icons
-
Backend:
- Node.js
- Express
- Apollo Server
- GraphQL
- MongoDB
- JSON Web Tokens
- Node.js (v18 or higher)
- npm or yarn
- Clone the repository:
git clone https://github.com/yourusername/headless-cms.git
cd headless-cms
- Install dependencies:
npm install
- Create a
.env
file in the root directory:
PORT=4000
MONGODB_URI=mongodb://localhost:27017/headless-cms
JWT_SECRET=your_jwt_secret_key_change_in_production
- Start the development server:
npm run dev
The application will start in development mode:
- Frontend: http://localhost:3000
- GraphQL Server: http://localhost:4000/graphql
The system creates two default users on first run:
-
Admin User:
- Email: [email protected]
- Password: password123
-
Guest User:
- Available through "Continue as Guest" option
headless-cms/
├── server/ # Backend server code
│ ├── models/ # MongoDB models
│ ├── utils/ # Utility functions
│ ├── schema.js # GraphQL schema
│ └── resolvers.js # GraphQL resolvers
├── src/ # Frontend source code
│ ├── components/ # React components
│ ├── context/ # React context providers
│ ├── pages/ # Page components
│ └── main.tsx # Application entry point
└── package.json # Project dependencies
The CMS supports various field types for content:
- Text
- Rich Text
- Number
- Boolean
- Date
- Media
- Reference
Each content type can have multiple fields with different configurations:
- Required/Optional
- Multiple Values
- Custom Validations
-
Admin:
- Full system access
- Manage users and roles
- Create/edit content types
- Manage all content
-
Editor:
- Publish/unpublish content
- Create/edit all content
- Access media library
-
Author:
- Create and edit own content
- Access media library
The GraphQL API provides endpoints for:
- Content Type Management
- Content Operations
- User Authentication
- Media Management
Example GraphQL query:
query GetContents {
contents {
id
title
slug
status
contentType {
name
}
fields {
fieldName
value
}
}
}
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.