An open API service indexing awesome lists of open source software.

https://github.com/bernoussama/server-manager


https://github.com/bernoussama/server-manager

Last synced: 5 months ago
JSON representation

Awesome Lists containing this project

README

          

# Server Manager

A full-stack monorepo application for managing and monitoring network services built with TypeScript, Express, and React.

![License](https://img.shields.io/badge/license-GPLv3-blue.svg)
![TypeScript](https://img.shields.io/badge/TypeScript-5.1.6-blue)
![Node.js](https://img.shields.io/badge/Node.js-18+-green)
![Express](https://img.shields.io/badge/Express-4.18.2-lightblue)
![React](https://img.shields.io/badge/React-18.3.1-61DAFB)
[![CI](https://github.com/bernoussama/server-manager/actions/workflows/ci.yml/badge.svg)](https://github.com/bernoussama/server-manager/actions/workflows/ci.yml)

## ๐Ÿ“‹ Overview

Server Manager is a powerful web application for monitoring and controlling essential network services like DNS (bind), DHCP, and HTTP servers. It features a robust TypeScript/Express backend API and a modern React UI with a clean, responsive dashboard.

The application allows you to:

- Monitor system metrics (CPU, memory, disk usage, uptime)
image


- Start, stop, and restart network services (named, dhcpd, httpd)
image


- Configure DNS zones and records with bind integration
image
image

- Configure HTTP virtual hosts and Apache settings
image

- Configure DHCP server settings
image

- View service status and logs
- Manage user accounts with authentication

## ๐Ÿ”ง Tech Stack

### Backend (`apps/backend`)
- **Language**: TypeScript
- **Runtime**: Node.js
- **Framework**: Express
- **Database**: SQLite with Drizzle ORM
- **Validation**: Zod (via shared package)
- **Authentication**: JWT tokens with bcrypt password hashing
- **Development Tools**: ESLint, Prettier, Nodemon, Jest

### Frontend (`apps/ui`)
- **Language**: TypeScript
- **Framework**: React 18
- **UI Components**: Custom component library with shadcn/ui
- **Styling**: Tailwind CSS
- **Icons**: Lucide React
- **Build Tool**: Vite
- **Testing**: Vitest
- **State Management**: React Hook Form
- **HTTP Client**: Fetch API with custom wrapper

### Shared (`packages/shared`)
- **Types**: Shared TypeScript interfaces and types
- **Validators**: Zod schemas for data validation
- **Transformers**: Data transformation utilities

### Infrastructure
- **Monorepo**: Turborepo with pnpm workspaces
- **Package Manager**: pnpm
- **Containerization**: Docker support

## ๐Ÿ“ Project Structure

```
ts-node-express/
โ”œโ”€โ”€ apps/
โ”‚ โ”œโ”€โ”€ backend/ # Express API server
โ”‚ โ”‚ โ”œโ”€โ”€ src/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ controllers/ # API route controllers
โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ authController.ts
โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ dnsController.ts
โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ httpController.ts
โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ servicesController.ts
โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ systemMetricsController.ts
โ”‚ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ usersController.ts
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ db/ # Database configuration
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ lib/ # Utility libraries
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ middlewares/ # Express middlewares
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ models/ # Data models
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ routes/ # API route definitions
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ types/ # Type definitions
โ”‚ โ”‚ โ”œโ”€โ”€ drizzle/ # Database migrations
โ”‚ โ”‚ โ””โ”€โ”€ test/ # API tests and config files
โ”‚ โ””โ”€โ”€ ui/ # React frontend application
โ”‚ โ””โ”€โ”€ src/
โ”‚ โ”œโ”€โ”€ components/ # Reusable UI components
โ”‚ โ”œโ”€โ”€ features/ # Feature-specific components
โ”‚ โ”‚ โ”œโ”€โ”€ configuration/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ dns/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ dhcp/
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ http/
โ”‚ โ”‚ โ”œโ”€โ”€ dashboard/
โ”‚ โ”‚ โ””โ”€โ”€ services/
โ”‚ โ”œโ”€โ”€ hooks/ # Custom React hooks
โ”‚ โ”œโ”€โ”€ lib/ # Frontend utilities and API clients
โ”‚ โ””โ”€โ”€ pages/ # Page components
โ”œโ”€โ”€ packages/
โ”‚ โ””โ”€โ”€ shared/ # Shared code between apps
โ”‚ โ””โ”€โ”€ src/
โ”‚ โ”œโ”€โ”€ types/ # TypeScript type definitions
โ”‚ โ””โ”€โ”€ validators/ # Zod validation schemas
โ”œโ”€โ”€ docs/ # Documentation
โ””โ”€โ”€ Configuration files (package.json, turbo.json, etc.)
```

## ๐Ÿš€ Getting Started

### Prerequisites

- Node.js 18+
- pnpm package manager

### Installation

1. Clone the repository:
```bash
git clone https://github.com/bernoussama/server-manager.git
cd server-manager
```

2. Install dependencies using pnpm workspaces:
```bash
pnpm install
```

3. Set up environment variables:
```bash
# Copy example environment file
cp apps/backend/.env.example apps/backend/.env

# Edit the .env file with your configuration
```

4. Set up the database:
```bash
# Generate and run database migrations
cd apps/backend
pnpm dlx drizzle-kit generate
pnpm dlx drizzle-kit push
```

### Running the Application

#### Development Mode

Start all applications in development mode:
```bash
# From root directory
pnpm dev
```

Or start individual applications:

```bash
# Start backend only
cd apps/backend && pnpm dev

# Start frontend only (in a new terminal)
cd apps/ui && pnpm dev
```

Your backend API will run at http://localhost:3000 and the UI will be available at http://localhost:5173.

#### Production Build

Build all applications:
```bash
pnpm build
```

Run in production mode:
```bash
# Start backend
cd apps/backend && pnpm start

# Serve frontend (after building)
cd apps/ui && pnpm preview
```

## ๐Ÿ”Œ API Endpoints

### Authentication API
- `POST /api/auth/signup` - Register a new user
- `POST /api/auth/login` - Login user

### Services API
- `GET /api/services` - Get all services status
- `GET /api/services/:service` - Get specific service status
- `POST /api/services/:service/start` - Start a service
- `POST /api/services/:service/stop` - Stop a service
- `POST /api/services/:service/restart` - Restart a service

### DNS API
- `GET /api/dns/config` - Get DNS configuration
- `PUT /api/dns/config` - Update DNS configuration

### HTTP API
- `GET /api/http/config` - Get HTTP configuration
- `PUT /api/http/config` - Update HTTP configuration
- `POST /api/http/validate` - Validate HTTP configuration
- `GET /api/http/status` - Get HTTP service status
- `POST /api/http/service/:action` - Control HTTP service

### System Metrics API
- `GET /api/system-metrics` - Get system performance metrics

### Users API
- `GET /api/users` - Get all users
- `GET /api/users/:id` - Get specific user
- `POST /api/users` - Create a user
- `PUT /api/users/:id` - Update a user
- `DELETE /api/users/:id` - Delete a user

## ๐Ÿงช Testing

Run tests for the entire monorepo:
```bash
pnpm test
```

Run tests for individual applications:
```bash
# Backend tests
cd apps/backend && pnpm test

# Frontend tests
cd apps/ui && pnpm test

# Shared package tests
cd packages/shared && pnpm test
```

## ๐Ÿ“‹ Development Commands

### Root level (affects all workspaces):
- `pnpm dev` - Start all applications in development mode
- `pnpm build` - Build all applications
- `pnpm test` - Run tests for all packages
- `pnpm lint` - Lint all packages
- `pnpm format` - Format code in all packages

### Backend (`apps/backend`):
- `pnpm start` - Run production build
- `pnpm dev` - Run development server with hot reload
- `pnpm build` - Build for production
- `pnpm lint` - Run ESLint
- `pnpm format` - Format code with Prettier
- `pnpm test` - Run Jest tests

### Frontend (`apps/ui`):
- `pnpm dev` - Run development server
- `pnpm build` - Build for production
- `pnpm preview` - Preview production build
- `pnpm lint` - Run ESLint
- `pnpm test` - Run Vitest tests

### Shared (`packages/shared`):
- `pnpm build` - Build shared package
- `pnpm test` - Run tests
- `pnpm lint` - Run ESLint

## ๐Ÿ—๏ธ Architecture

The application follows a modern monorepo architecture:

- **Turborepo**: Manages the monorepo with optimized build caching and task orchestration
- **Shared Package**: Contains common types, validators, and utilities used by both frontend and backend
- **Type Safety**: End-to-end type safety with shared TypeScript interfaces
- **API-First Design**: RESTful API with comprehensive validation using Zod schemas
- **Component-Based UI**: Modular React components with feature-based organization

## ๐Ÿณ Docker Support

The backend includes Docker support:

```bash
# Build Docker image
cd apps/backend
docker build -t server-manager-backend .

# Run with Docker
docker run -p 3000:3000 server-manager-backend
```

## ๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the project
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## ๐Ÿ“„ License

This project is licensed under the GPLv3 License.

## ๐Ÿ“ž Contact

Project Link: [https://github.com/bernoussama/server-manager](https://github.com/bernoussama/server-manager)