LokiCMS is a powerful headless content management system that leverages a modernized version of LokiJS, providing a seamless REST API experience. With embedded database functionality and AI-driven management through the Model Context Protocol, it offers flexibility for developers seeking to create dynamic applications without the overhead of traditional CMS interfaces.
lokiCMS is a modernized Headless Content Management System (CMS) powered by LokiJS, featuring a REST API and an AI-driven Model Context Protocol (MCP) server for seamless agent management. Built using TypeScript, it provides a robust and lightweight solution focused exclusively on backend functionality, allowing for easy integration and consumption without a graphical user interface.
Key Features
- Embedded Database: Utilizes an updated version of LokiJS with no obsolete dependencies, ensuring high performance and reliability.
- REST API: Comprehensive endpoints featuring JWT authentication and API Keys secure operations and data management.
- MCP Server: Facilitates integration with AI agents via the Model Context Protocol, enabling intelligent operations and workflows.
- Headless Design: Tailored for direct consumption by servers and applications, making it an ideal choice for developers looking to integrate content management capabilities into their applications.
Environment Setup
To get started, the following environment configurations are necessary:
| Variable | Description | Default |
|---|---|---|
PORT | Specify the API server port | 3000 |
HOST | Define the server host | localhost |
DB_PATH | Path to the database file | ./data/cms.db |
JWT_SECRET | Secret key for JWT tokens | (required in production) |
JWT_EXPIRES_IN | Token expiration duration | 7d |
API_KEY_PREFIX | Prefix for API keys | lkcms_ |
Installation and Initialization
To initialize the database, run the following command:
npm run seed
This setup will create an administrator user, default content types (e.g., Post, Page), default taxonomies (e.g., Category, Tag), and example terms.
API Usage
Authentication
- Register a new user:
POST /api/auth/register
Content-Type: application/json
{
"email": "user@example.com",
"password": "password123",
"name": "John Doe"
}
Content Management
- Create New Content Type:
POST /api/content-types
Authorization: Bearer <token>
Content-Type: application/json
{
"name": "Product",
"slug": "product",
"description": "E-commerce products",
"fields": [
{
"name": "title",
"label": "Title",
"type": "text",
"required": true
},
{
"name": "price",
"label": "Price",
"type": "number",
"required": true
}
]
}
- List Entries:
GET /api/entries?contentType=post&status=published&search=hello&page=1&limit=10
Plugin System
Additional functionality can be added through the flexible plugin system that supports both npm packages and local plugins. Plugins can register their hooks, routes, and even modify the CMS's operational behavior through the provided API.
Modernized LokiJS
lokiCMS incorporates an enhanced LokiJS library, offering:
- Full TypeScript support with typed objects.
- Modern ES6 classes for improved readability and maintainability.
- Async/await API for handling operations, eliminating callback hell.
Conclusion
lokiCMS provides a powerful, headless solution for managing digital content while integrating seamlessly with external applications and AI services. It is designed for developers seeking efficient content management capabilities, free from the limitations of traditional CMS interfaces.
No comments yet.
Sign in to be the first to comment.