ProcLens.ai is a web-based system process monitoring application that provides users with real-time visualization of system processes and resources. It features an interactive dashboard with process tables, performance charts, and an AI assistant powered by Google's Gemini API that can answer questions about the system's processes. The application is designed with a modern, responsive interface and supports both light and dark themes.
- Frontend Framework: React with TypeScript
- Routing: React Router
- Styling: Tailwind CSS with custom glass-morphism effects
- UI Components: shadcn/ui component library
- Charts/Visualization: Recharts
- Icons: Lucide React
- State Management: React Context API and hooks
- AI Integration: Google's Gemini API for intelligent process analysis
- Build System: Vite
- Backend Server: Node.js with Express and TypeScript
- System Information: systeminformation package for real-time system data
-
Create a
.env
file in the root directory with the following variables:# Gemini API Configuration # Get your API key from https://makersuite.google.com/app/apikey VITE_GEMINI_API_KEY=your_gemini_api_key_here # Backend API Configuration VITE_API_BASE_URL=http://localhost:3002
-
Get your Gemini API key:
- Visit https://makersuite.google.com/app/apikey
- Create a new API key
- Copy the key and paste it as the value for
VITE_GEMINI_API_KEY
-
Start the backend server:
cd server npm install npm start
-
Start the frontend development server:
npm install npm run dev
- index.html: The entry point HTML file that loads the React application.
- src/main.tsx: The main entry point that renders the React app into the DOM.
- src/App.tsx: Sets up the application with React Router, Query Client, and global UI providers.
- vite.config.ts: Vite configuration for the build process.
- tailwind.config.ts: Tailwind CSS configuration with custom theme settings.
- src/index.css: Global CSS styles including custom utility classes for glass-morphism effects.
- src/pages/Index.tsx: The main dashboard page showing process monitoring.
- src/pages/Contact.tsx: Contact page with a form for user inquiries.
- src/pages/NotFound.tsx: 404 error page for handling non-existent routes.
The project includes a Node.js backend server that provides real-time system data:
- server/src/index.ts: Main server file with Express setup and API endpoints
- server/package.json: Server dependencies and scripts
- server/tsconfig.json: TypeScript configuration for the server
-
GET /processes
- Returns real-time system process data
- Includes PID, name, status, CPU/memory usage, user, start time, and priority
- Data is formatted to match the frontend's expected structure
-
GET /system-resources
- Returns real-time system resource usage
- Includes CPU usage percentage
- Memory usage in GB (total and used)
- Disk usage in GB (total and used)
- Network speed in MB/s
- Real-time system monitoring using systeminformation package
- Automatic data refresh every 10 seconds
- Error handling with appropriate HTTP status codes
- CORS enabled for frontend communication
- TypeScript for type safety
- Nodemon for development auto-reload
- src/components/ProcessProvider.tsx: Context provider that fetches, manages, and distributes process data throughout the application. It also manages the chat history for the AI assistant.
- src/components/ProcessTable.tsx: Displays system processes in a sortable, paginated table with search functionality.
- src/components/QueryInput.tsx: Provides an interface for users to query the AI about system processes, with optional Ollama integration or mock responses.
- src/components/ResponseBox.tsx: Displays AI assistant responses in a formatted chat-like interface.
- src/components/PerformanceChart.tsx: Line chart showing CPU and memory usage over time.
- src/components/ResourceUsageChart.tsx: Area chart showing disk I/O and network usage over time.
- src/components/ThemeToggle.tsx: Button for switching between light and dark mode.
- src/components/ui/: Directory containing reusable UI components from shadcn/ui:
- navigation-menu.tsx: Navigation menu component for the top navbar.
- button.tsx: Button component with various styles.
- input.tsx: Input field component.
- separator.tsx: Horizontal or vertical separator line.
- scroll-area.tsx: Scrollable container with custom scrollbars.
- table.tsx: Data table with headers and cells.
- tooltip.tsx: Tooltip component for showing additional information on hover.
- progress.tsx: Progress bar component.
- hover-card.tsx: Card that appears on hover.
- And many more shadcn/ui components for a consistent UI design.
- src/hooks/useTheme.tsx: Custom hook for managing the application's theme (light/dark mode).
- src/hooks/use-toast.ts: Hook for displaying toast notifications.
- src/lib/utils.ts: Utility functions including the
cn
function for combining Tailwind classes. - src/fetch-timeout-polyfill.ts: Polyfill for adding timeout functionality to fetch requests.
The application provides real-time monitoring of system processes with:
- A sortable and searchable table of processes
- Details including PID, name, status, CPU/memory usage, user, start time, threads, and priority
- Visual status indicators for running, sleeping, stopped, and zombie processes
- Pagination for navigating large process lists
Real-time charts display system performance metrics:
- CPU and memory usage over time with line charts
- Disk I/O and network activity with area charts
- Responsive design that adapts to different screen sizes
An intelligent assistant that can analyze process data:
- Natural language query interface
- Integration with local Ollama AI model (if available)
- Fallback to mock responses when Ollama is not running
- Persistent chat history during the session
The application is fully responsive with:
- Adaptive layout for mobile, tablet, and desktop screens
- Glass-morphism UI elements that work in both light and dark mode
- Smooth animations and transitions
Complete light and dark theme support:
- User preference detection
- Theme persistence using local storage
- Theme toggle accessible throughout the application
The application now uses a real backend server to provide system process data:
- Node.js server with Express framework
- systeminformation package for accurate system data
- Real-time process monitoring and resource usage tracking
- Automatic data refresh mechanism
- Fallback to mock data if server is unavailable
The server implements proper data formatting:
- Memory values converted to GB with 2 decimal places
- Disk usage calculated in GB
- Network speed calculated in MB/s
- CPU usage shown as percentage
- All values properly rounded and formatted
The server runs on port 3002 by default and can be configured through environment variables:
PORT
: Server port (default: 3002)- CORS enabled for frontend communication
- TypeScript compilation settings for optimal performance
The server implements comprehensive error handling:
- Try-catch blocks for all async operations
- Appropriate HTTP status codes for different scenarios
- Detailed error messages for debugging
- Graceful fallback mechanisms
The application uses Google's Gemini API for intelligent process analysis:
- Natural language query interface
- Real-time process data analysis
- Context-aware responses based on current system state
- Automatic retry mechanism with exponential backoff
- Rate limit handling
- Error handling with user-friendly messages
The project uses a custom styling approach with:
- Tailwind CSS for utility-first styling
- Custom glass-morphism effect classes
- CSS variables for theme colors
- Responsive design breakpoints
The application uses React's Context API for global state management:
ProcessProvider
for process data and chat historyThemeProvider
for theme state- Local component state for UI interactions
Components follow a consistent pattern:
- Functional components with TypeScript typing
- Hook-based state management
- Separation of concerns between data, display, and interaction
- Consistent prop interfaces
The application implements several performance optimizations:
- Memoization of filtered and sorted processes
- Controlled refresh intervals to avoid unnecessary re-renders
- Pagination to handle large datasets efficiently
- Efficient chart rendering with limited data points
When deploying ProcLens.ai:
- The backend server needs to be running to provide real system process data.
- Configure the frontend's API_BASE_URL to point to the correct server address.
- Ensure proper CORS settings for production deployment.
- Set up environment variables for server configuration.
- Consider using a process manager like PM2 for production deployment.
- The application is configured for deployment with Vite's build system.
Potential areas for future development:
- Process Management: Add capability to end, pause, or restart processes.
- Historical Data: Implement persistent storage for historical performance analysis.
- Advanced Filtering: Add more sophisticated filtering and grouping options.
- User Accounts: Add authentication to save preferences and queries.
- Backend Integration: Replace mock data with real system process data.
- Enhanced AI Capabilities: Extend AI capabilities with process optimization recommendations.
- System Alerts: Add threshold-based alerts for resource usage.
- Remote Monitoring: Add support for monitoring remote systems.
ProcLens.ai demonstrates how modern web technologies can be used to create a sophisticated system monitoring interface with AI-powered assistance. The combination of real-time data visualization, responsive design, and natural language interaction provides users with an intuitive way to understand and manage system processes.