Alpha System - Content Hub (v2.0)
A simple NodeJS application for creating and managing documentation, changelogs, roadmaps, and knowledge base articles within distinct projects, using Markdown and powered by PocketBase.
Features
- π’ Project Organization: Group your content (entries, templates, assets) into separate projects.
- π Markdown Editing: Create and manage content using a familiar Markdown editor (EasyMDE) with toolbar assistance, image uploads, diagram support (Mermaid), grammar checking (LanguageTool), and Ctrl+S saving.
- π₯οΈ Admin Dashboard: Central dashboards for global overview and per-project management. View, create, edit, archive, and manage entries within their projects. Includes activity charts.
- π¨ Custom Headers & Footers (Per-Project, Per-Type): Create reusable HTML headers/footers specific to each project and entry type (Documentation, Changelog) for customized public view pages.
- π Templates (Per-Project): Define reusable Markdown templates within each project for consistent entry structure.
- πΊοΈ Roadmap Management: Create and manage roadmap items with distinct stages (Planned, Next Up, In Progress, Done) per project.
- π Public Roadmap Board: Automatically generated public Kanban-style board view for each project's roadmap.
- π§ Knowledge Base Management: Create and manage question/answer pairs within projects.
- π‘ Public Knowledge Base View: Automatically generated, searchable public view for each project's knowledge base.
- π Secure Access: Dashboard access is protected by PocketBase user authentication. Project access is controlled per user.
- π Project Access Control: Projects can be made public or private, with optional password protection for public projects.
- βοΈ Project Settings: Configure project name, description, visibility, password, and feature enablement (Roadmap, View Tracking, Time Tracking).
- βοΈ Sidebar Ordering (Per-Project): Drag-and-drop interface to control the order of entries shown in the public project sidebar.
- π Light & Dark Themes: Choose your preferred viewing mode for the admin interface.
- ποΈ View Tracking: Basic view counts are recorded for each public entry page using SQLite and privacy-preserving IP hashing.
- β±οΈ View Time Tracking: Optionally track approximate time spent on public documentation and changelog pages.
- π Pocketbase Backend: Leveraging the speed and simplicity of Pocketbase for data storage.
- π Public View Pages: Automatically generated, styled pages for customers to view published entries (
/view/:id
), roadmaps (/roadmap/:projectId
), and knowledge bases (/kb/:projectId
), respecting project visibility and password settings. - βοΈ Configurable: Uses environment variables and dynamic app settings stored in PocketBase.
- π Global Search: Search across all entries (title, collection, tags) accessible to the logged-in user.
- π Audit Log: Tracks key actions performed within the application globally. Exportable to CSV.
- π Staging: Make changes to published entries without affecting the live version until you explicitly publish the staged changes.
- π Preview Links: Generate shareable, optionally password-protected preview links for draft entries.
- πΌοΈ Image Uploads: Directly upload images within the Markdown editor for entries.
- π Diagram Support: Embed and render various diagrams (flowcharts, sequence, Gantt, etc.) directly within your Markdown content using Mermaid syntax.
Preview
You can see a public page example here.
Changelog
You can see the changelog here.
Tech Stack
- Backend: NodeJS, Express
- Templating: EJS
- Database: PocketBase
- Session Store: SQLite
- View Tracking Store: SQLite
- Markdown Editor: EasyMDE
- Styling: Vanilla CSS
Prerequisites
Before you begin, ensure you have the following installed:
- Node.js: Version 18 or higher recommended. (Download Node.js)
- npm: Usually included with Node.js.
- Git: For cloning the repository. (Download Git)
- A running PocketBase instance:
- Download and run PocketBase from pocketbase.io.
- Note the URL where it's running (e.g.,
http://127.0.0.1:8090
).
Installation
Clone the repository:
git clone https://github.com/devAlphaSystem/Alpha-System-ContentHub.git cd Alpha-System-ContentHub
Install dependencies:
npm install
Configuration
Configuration is managed through a .env
file in the project root.
Create
.env
and fill in the values:# PocketBase instance URL POCKETBASE_URL=http://127.0.0.1:8090 # Credentials for an ADMIN/SUPERUSER account in PocketBase (used for setup script & admin tasks) POCKETBASE_ADMIN_EMAIL=your_admin_email@example.com POCKETBASE_ADMIN_PASSWORD=your_admin_password # Set to "production" for production environments, otherwise "development" NODE_ENV=development # Port for the NodeJS application to run on PORT=3000 # Generate strong, random strings for these secrets! SESSION_SECRET=your-very-strong-random-secret-key-here IP_HASH_SALT=another-very-strong-random-secret-for-hashing-ips # Record ID of the single record in the 'app_settings' collection in PocketBase APP_SETTINGS_RECORD_ID=YOUR_APP_SETTINGS_RECORD_ID_HERE # --- Optional Overrides / Defaults --- # Can be: NONE < ERROR < WARN < INFO < DEBUG < TRACE LOG_LEVEL=INFO # Default items per page in tables ITEMS_PER_PAGE=10 # Session duration in days SESSION_MAX_AGE_DAYS=7 # Default expiry for preview links (hours) - Can be overridden in App Settings UI PREVIEW_TOKEN_EXPIRY_HOURS=6 # Default for Global Search feature - Can be overridden in App Settings UI ENABLE_GLOBAL_SEARCH=true # Default for Audit Log feature - Can be overridden in App Settings UI ENABLE_AUDIT_LOG=true # Default for View Tracking on new projects - Can be overridden in App Settings UI ENABLE_PROJECT_VIEW_TRACKING_DEFAULT=true # Default for View Time Tracking on new projects - Can be overridden in App Settings UI ENABLE_PROJECT_TIME_TRACKING_DEFAULT=true # How long (hours) before a view from the same IP is counted again VIEW_TIMEFRAME_HOURS=24 # Average words per minute used for reading time calculation AVERAGE_WPM=225
Configure PocketBase Collections (Automated Setup):
This project includes a script to automatically set up the required PocketBase collections using an exported schema definition (
pb_schema.json
). This is the recommended way to set up the database structure.Prerequisites for Automated Setup:
- Your PocketBase instance must be running at the
POCKETBASE_URL
specified in your.env
file. - The
POCKETBASE_ADMIN_EMAIL
andPOCKETBASE_ADMIN_PASSWORD
in your.env
file must correspond to a valid Admin/Superuser account in your PocketBase instance. - The
pb_schema.json
file (containing the collection definitions) must be present in the project root directory. - Node.js dependencies must be installed (
npm install
).
Running the Setup Script:
- Open your terminal in the project root directory (
Alpha-System-ContentHub
). - Run the command:
node build_pb.js
- The script will connect to your PocketBase instance, authenticate as the admin user, and attempt to import the collections defined in
pb_schema.json
. It will skip collections that already exist by name. - Crucially, after the script runs successfully, note the Record ID printed for the
app_settings
collection. You must copy this ID and paste it into your.env
file as the value forAPP_SETTINGS_RECORD_ID
. - Review the script's output for any errors. If errors occur, ensure PocketBase is running and accessible, and admin credentials are correct. If collections were partially created, you might need to manually delete them from the PocketBase Admin UI (
http://YOUR_POCKETBASE_URL/_/
) before re-running the script.
- Your PocketBase instance must be running at the
Configure
users
Collection (Manual Step):You still need to configure the default
users
collection for application login:- Navigate to your PocketBase Admin UI (e.g.,
http://127.0.0.1:8090/_/
). - Go to
users
collection > Options > Identity/Password. - Ensure "Identity/Password" is ENABLED.
- You might want to disable "Send email alert for new logins" to avoid error logs if email is not configured in PocketBase.
- Create at least one non-admin user account via the UI. This user account will be used to log into the Content Hub application itself.
- Navigate to your PocketBase Admin UI (e.g.,
Running the Application
Ensure PocketBase is running and the collections have been configured (using
node build_pb.js
) and theAPP_SETTINGS_RECORD_ID
is set in.env
.Start the Node.js application:
Development Mode (with automatic restarts using
nodemon
):npm run dev
Production Mode:
npm start
Access: Open your browser and navigate to
http://localhost:3000
(or the port specified in your.env
file). Log in using the non-admin user credentials you created in PocketBase.
Usage
- Navigate to the application URL and log in using your PocketBase user credentials.
- Global Dashboard (
/
): View an overview across all your projects. - Projects (
/projects
): View, search, and manage your projects. Create new projects. - Project Dashboard (
/projects/:projectId
): View project-specific metrics and recently updated entries. Access project settings. - Project Entries (
/projects/:projectId/documentation
,/changelogs
,/roadmaps
,/knowledge_base
): View, filter, sort, and manage entries (Docs, Changelogs, Roadmap items, KB articles) for the specific project. Perform actions like Archive, Delete, or Publish Staged Changes. Initiate bulk actions. - Create New Entry (
/projects/:projectId/new
): Create a new entry within a project. Select type (Doc, Changelog, Roadmap, KB), use the Markdown editor, apply optional project templates, and select optional custom headers/footers (type-specific). Assign Roadmap stage if applicable. - Edit Entry (
/projects/:projectId/edit/:entryId
): Modify an existing entry. If the entry is published, changes are staged by default. Select optional custom headers/footers. Generate preview links for drafts. Use the grammar check tool. - Archived Entries (Per-Project, Per-Type): View archived entries for the project/type. Unarchive or permanently delete them.
- Templates (Per-Project) (
/projects/:projectId/templates
): Create, view, edit, and delete reusable Markdown templates specific to the project. - Headers/Footers (Per-Project, Per-Type): Create, view, edit, and delete reusable HTML headers/footers for Documentation and Changelog entries within the project.
- Sidebar Order (Per-Project) (
/projects/:projectId/sidebar-order
): Drag and drop to reorder entries shown in the public project sidebar. - Global Audit Log (
/audit-log
): View a log of system and user actions across all projects. Export or clear logs (if enabled in settings). - System Settings (
/settings
): Configure global application settings like Audit Log enablement, Global Search, and default project settings. - Global Search (
/search?q=...
or via top bar): Search across all entries you have access to. - Public View (
/view/:id
): Access the public page for a published entry (respects project visibility/password). - Public Roadmap (
/roadmap/:projectId
): Access the public roadmap board for a project (respects project visibility/password and roadmap feature enablement). - Public Knowledge Base (
/kb/:projectId
): Access the public knowledge base for a project (respects project visibility/password). - Preview (
/preview/:token
): Access a draft entry using a generated preview link (may require a password). - Theme Toggle: Use the toggle in the sidebar footer to switch between light and dark modes for the admin interface.
- Save Shortcut: Use
Ctrl+S
(orCmd+S
) on Create/Edit pages (Entries, Templates, Headers, Footers) to save the form.
Notes
- Session Storage: Uses
connect-sqlite3
storing sessions indb/sessions.db
. Consider alternatives (Redis, PostgreSQL) for high-traffic production. - View Tracking: Uses
sqlite3
storing view logs and duration data indb/view_tracking.db
. Hashing IPs enhances privacy but review GDPR/LGPD compliance if applicable. - Error Handling: Basic error pages (403, 404, 500) are included. Check server logs for detailed errors.
- Admin Client: The application uses a PocketBase admin client internally for certain operations (like setup, cleanup, some lookups). Ensure the admin credentials in
.env
are kept secure.