Express.js backend API serving documentation content with real-time file watching and markdown rendering.
- Real-time File Watching - Auto-reloads documentation changes
- Markdown Rendering - Converts markdown to HTML with syntax highlighting
- File System API - Serves code and documentation from local directories
- CORS Support - Cross-origin requests for frontend integration
- Compression - Response compression for better performance
- Rate Limiting - Built-in protection against API abuse
- Health Monitoring - Service health check endpoint
- Node.js 16+
- npm or yarn
- Optional: MongoDB (if using database features)
cd backend
npm installCopy .env.example to .env and configure:
# Server Configuration
PORT=5000
NODE_ENV=development
# Data Folder Path (where documentation lives)
# Default: Looks for data folder relative to backend directory
# PYTHON_PATH=C:\Users\YourName\Documents\Python\data
# Optional Settings
MAX_SCAN_DEPTH=3
INCLUDE_FILE_TYPES=.py,.md,.txt,.js,.html,.css
EXCLUDE_DIRS=node_modules,venv,__pycache__,.git
VERBOSE_LOGGING=false# Development (with auto-restart on file changes)
npm run dev
# Production
npm startGET /api/documents- List all documents and foldersGET /api/documents/categories- Get document categoriesGET /api/documents/*path- Get specific document content
GET /api/health- Server health check
- Auto-discovery - Scans data folder for documentation
- Real-time updates - File changes trigger automatic reload
- Markdown parsing - Converts
.mdfiles to HTML - Code highlighting - Syntax highlighting for code files
backend/
βββ server.js # Main Express server
βββ routes/
β βββ documents.js # Document API routes
βββ models/ # Database models (if needed)
βββ utils/ # Helper functions
βββ data/ # Documentation content (external)
βββ .env.example # Environment template
βββ package.json # Dependencies
βββ README.md # This file
- express (v5.2.1) - Web framework
- cors (v2.8.6) - Cross-origin resource sharing
- dotenv (v17.3.1) - Environment variable management
- chokidar (v5.0.0) - File system watcher
- fs-extra (v11.3.4) - Enhanced file system operations
- marked (v17.0.4) - Markdown parser
- highlight.js (v11.11.1) - Syntax highlighting
- compression (v1.7.4) - Gzip compression
- express-rate-limit (v7.4.1) - Rate limiting
- mongoose (v9.3.0) - MongoDB ODM
- nodemon (v3.1.14) - Auto-restart on changes
The backend automatically watches the data folder for changes:
- New files are detected and added to the API
- Modified files trigger real-time updates
- Deleted files are removed from the API
- Graceful handling of missing files
- Comprehensive error logging
- Fallback to default configurations
# Set production environment
export NODE_ENV=production
# Start the server
npm startNODE_ENV=production- Enables production optimizationsPORT- Server port (default: 5000)PYTHON_PATH- Absolute path to documentation folder
File not found errors
- Check
PYTHON_PATHin.env - Verify data folder exists and contains files
CORS errors
- Ensure frontend is running on allowed origins
- Check CORS configuration in
server.js
Performance issues
- Enable compression middleware
- Consider caching strategies
- Monitor file system changes
Enable verbose logging:
VERBOSE_LOGGING=trueISC License
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
For issues and questions:
- Check the troubleshooting section
- Review server logs for detailed error messages
- Verify environment configuration