This directory contains example applications that demonstrate the Charmonator modular app system.
Note: These examples require the main Charmonator server to run. Please install and configure Charmonator first before using these applications.
The Charmonator modular app system allows you to create self-contained applications with:
- Static Assets: HTML, CSS, JS files served from the app's
publicdirectory - API Routes: Express.js routes defined in the app's
routesdirectory - Configuration: App-specific settings in
app-config.json - Independence: Each app is completely modular and can be enabled/disabled
Each app follows this directory structure:
my-app/
├── app-config.json # App configuration
├── README.md # App documentation
├── public/ # Static files (HTML, CSS, JS, images)
│ ├── index.html
│ └── styles.css
└── routes/ # Express route handlers
├── api.mjs
└── admin.mjs
The app-config.json file defines how your app integrates:
{
"name": "My Application",
"description": "A sample Charmonator app",
"version": "1.0.0",
"baseRoute": "/apps/my-app",
"staticRoute": "/apps/my-app",
"publicDir": "public",
"routesDir": "routes",
"enabled": true,
"customProperty": "custom-value"
}- name: Display name for your app
- description: Brief description of app functionality
- version: Semantic version of your app
- baseRoute: Base URL path for API routes (e.g.,
/apps/my-app) - staticRoute: URL path for static files (e.g.,
/apps/my-app) - publicDir: Directory containing static assets (default:
public) - routesDir: Directory containing route handlers (default:
routes) - enabled: Whether the app should be loaded (default:
true)
You can add custom properties for app-specific configuration.
Route files should export an Express router:
// routes/api.mjs
import express from 'express';
import { getAppConfig } from '../../../lib/app-loader.mjs';
const router = express.Router();
router.get('/hello', (req, res) => {
const config = getAppConfig('my-app');
res.json({
message: 'Hello from my app!',
version: config?.version
});
});
export default router;Files in the public directory are served at the app's staticRoute:
public/index.html→/apps/my-app/index.htmlpublic/styles.css→/apps/my-app/styles.csspublic/js/app.js→/apps/my-app/js/app.js
Register your app in the main conf/config.json:
{
"apps": {
"my-app": {
"directory": "./examples/my-app",
"enabled": true,
"description": "My custom application"
}
}
}- clinical-trial-matcher-app: AI-powered clinical trial eligibility assessment with comprehensive API and mobile interface
- chat-with-records-app: AI-powered conversational interface for medical record interaction with HIPAA-compliant models
- outlive-checklist-app: Health assessment tool based on Dr. Peter Attia's longevity framework with risk evaluation
- undiagnosed-diseases-app: Application assistance for the Undiagnosed Diseases Network program with rare disease pattern recognition
- cbt-alcohol-coach-app: Real-time CBT-based alcohol recovery coach with crisis intervention and therapeutic memory
- Create app directory:
mkdir examples/my-app - Add configuration: Create
app-config.json - Add static files: Create
public/directory with HTML/CSS/JS - Add routes: Create
routes/directory with Express handlers - Register app: Add entry to main
config.json - Restart server: Charmonator will load your app automatically
- Hot Reload: Restart the server to reload app changes
- Configuration Access: Use
getAppConfig(appId)in routes to access config - Error Handling: Check server logs for app loading errors
- Static Assets: Reference static files relative to your
staticRoute - Route Conflicts: Ensure
baseRoutedoesn't conflict with existing endpoints
- Keep apps self-contained and modular
- Use clear, descriptive route paths
- Include proper error handling in routes
- Document your app's API endpoints
- Version your apps semantically
- Test apps in isolation before deployment