darpan 0.1.0

Linux developer service monitoring utility with auto-detection, real-time health checks, and interactive TUI for databases, APIs, Docker containers, and more
Documentation
use crate::models::{HealthCheckConfig, ServiceType};
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProjectConfig {
    pub version: u32,
    pub services: Vec<ServiceConfig>,
    pub dependencies: Option<Vec<DependencyConfig>>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ServiceConfig {
    pub name: String,
    
    #[serde(rename = "type")]
    pub service_type: ServiceType,
    
    pub port: u16,
    
    #[serde(skip_serializing_if = "Option::is_none")]
    pub host: Option<String>,
    
    #[serde(skip_serializing_if = "Option::is_none")]
    pub process: Option<String>,
    
    #[serde(skip_serializing_if = "Option::is_none")]
    pub health_check: Option<HealthCheckConfig>,
    
    #[serde(default)]
    pub tags: Vec<String>,
    
    #[serde(skip_serializing_if = "Option::is_none")]
    pub additional_ports: Option<Vec<u16>>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DependencyConfig {
    pub service: String,
    pub depends_on: Vec<String>,
}

impl ProjectConfig {
    pub fn default_template() -> String {
        r#"version: 1

services:
  - name: Backend API
    type: http_server
    port: 3001
    health_check:
      type: http
      path: /api/health
    tags: [critical, backend]
    
  - name: PostgreSQL
    type:
      database: postgres
    port: 5432
    health_check:
      type: postgres
      database: myapp_dev
    
  - name: Redis
    type:
      cache: redis
    port: 6379
    health_check:
      type: redis

dependencies:
  - service: Backend API
    depends_on: [PostgreSQL, Redis]
"#
        .to_string()
    }
}