Cervo HRM - Human Resource Management System
🎯 Overview
Cervo HRM is a complete HR management solution featuring:
-
Employee Management - Full CRUD with import/export capabilities
-
Attendance Tracking - GPS & IP-based check-in/out with approval workflow
-
Leave Management - Request, approve, and balance tracking
-
Payroll Processing - Automated calculations with payslip generation
-
Role-Based Access Control - Granular permissions per role
-
Audit Logging - Complete activity tracking
-
Multi-Company Support - Manage multiple organizations
✨ Features
Core Modules
|
Module |
Features |
|
Dashboard |
Real-time statistics, quick actions, recent activity |
|
Employees |
Directory, profiles, contracts, bank accounts, CSV import |
|
Departments |
Organization structure, head/manager assignment |
|
Attendance |
Check-in/out, GPS tracking, IP validation, admin view |
|
Leave |
Request workflow, approval system, balance tracking |
|
Payroll |
Run management, auto-calculation, payslip generation |
|
Reports |
Headcount, leave summary, payroll reports, CSV export |
|
Notifications |
In-app alerts, broadcast announcements |
|
Audit Log |
Complete activity trail |
|
Support Tickets |
Issue tracking and resolution |
Role-Based Access Control
|
Role |
Capabilities |
|
ADMIN |
Full system access |
|
EXECUTIVE |
Company-level management |
|
HR |
HR operations, payroll, employees |
|
MANAGER |
Department management, leave approval |
|
USER |
Personal data, leave requests |
🔑 Demo Credentials
After running the seed script, use these accounts:
🚀 Quick Start
Prerequisites
-
Node.js 18+
-
PostgreSQL 15+ or SQLite
-
npm/yarn/pnpm
Installation
# 1. Download the repository
# extract cervo.zip
# go to cervo-main folder
cd cervo
# 2. Install dependencies
npm install
# 3. Set up environment
cp .env.example .env
# Edit .env with your database URL
# 4. Initialize database
npx prisma generate
npx prisma db push
# 5. Seed demo data
npm run seed
# 6. Start development server
npm run dev
Open http://localhost:3000 in your browser.
📁 Project Structure
cervo/
├── prisma/
│ ├── schema.prisma # Database schema
│ ├── migrations/ # Database migrations
│ └── seed.ts # Demo data seeder
├── src/
│ ├── actions/ # Server Actions (API)
│ │ ├── auth.ts # Authentication
│ │ ├── employees.ts # Employee management
│ │ ├── departments.ts
│ │ ├── leave.ts # Leave management
│ │ ├── attendance.ts # Attendance tracking
│ │ ├── payroll.ts # Payroll processing
│ │ ├── notifications.ts
│ │ └── reports.ts
│ ├── app/ # Next.js App Router
│ │ ├── (auth)/ # Login, Register
│ │ ├── employees/ # Employee pages
│ │ ├── departments/ # Department pages
│ │ ├── leave/ # Leave pages
│ │ ├── attendance/ # Attendance pages
│ │ ├── payroll/ # Payroll pages
│ │ └── ...
│ ├── components/ # React components
│ │ └── ui/ # UI primitives
│ └── lib/ # Utilities
│ ├── authz.ts # RBAC permissions
│ ├── session.ts # JWT session
│ └── prisma.ts # Database client
└── public/ # Static assets
🛠️ Technology Stack
|
Category |
Technology |
|
Framework |
Next.js 16 (App Router) |
|
Language |
TypeScript 5 |
|
Database |
PostgreSQL / SQLite |
|
ORM |
Prisma 7 |
|
Auth |
JWT (jose) + bcrypt |
|
Styling |
Tailwind CSS |
|
Icons |
Material Symbols |
📖 Documentation
READ HERE
🔐 Security Features
-
JWT-based session management
-
Password hashing with bcrypt
-
Role-based access control (RBAC)
-
Audit logging for all actions
-
Protected routes via middleware
-
Input validation on all forms
-
Prisma ORM (SQL injection prevention)
📊 Database Models
18 complete models with proper relations and indexes:
Company ←→ Department ←→ Employee ←→ User
↓
LeaveType ←→ LeaveBalance
↓
LeaveRequest ←→ LeaveApproval
↓
AttendanceRecord ←→ AttendanceApproval
↓
PayrollRun ←→ PayrollItem ←→ Payslip
↓
Notification, AuditLog, Ticket
🌐 Deployment
Vercel (Recommended)
-
Push to GitHub
-
Connect to Vercel
-
Set environment variables
-
Deploy
Railway / Render
-
Create PostgreSQL database
-
Set
DATABASE_URL environment variable
-
Deploy with
npm run build && npm start
Docker
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npx prisma generate
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]
XEM THÊM ==> Hướng dẫn cài đặt chi tiết
HƯỚNG DẪN CÀI ĐẶT
Cervo HRM - Installation Guide
This guide covers complete installation of Cervo HRM on your local machine or server.
Prerequisites
Required Software
Alternative: You can use SQLite for development (no installation required).
Step 1: Clone Repository
git clone <cervo git>
cd cervo
Step 2: Install Dependencies
npm install
Or with yarn/pnpm:
yarn install
# or
pnpm install
Step 3: Configure Environment
Option A: PostgreSQL (Production)
-
Create a PostgreSQL database:
CREATE DATABASE cervo_hrm;
CREATE USER cervo_user WITH ENCRYPTED PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE cervo_hrm TO cervo_user;
-
Create
.env file:
cp .env.example .env
-
Edit
.env:
DATABASE_URL="postgresql://cervo_user:your_password@localhost:5432/cervo_hrm"
SESSION_SECRET="your-super-secret-session-key-min-32-chars"
Option B: SQLite (Development Only)
-
Edit
.env:
DATABASE_URL="file:./dev.db"
SESSION_SECRET="dev-secret-key-for-local-development-only"
-
Update
prisma/schema.prisma:
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
Step 4: Generate Prisma Client
npx prisma generate
This generates the Prisma client based on your schema.
Step 5: Create Database Tables
npx prisma db push
This creates all tables in your database.
Step 6: Seed Demo Data (Optional)
npm run seed
This creates:
-
1 Company (Cervo Global)
-
3 Departments (Engineering, HR, Marketing)
-
4 Users (Admin, HR, Manager, Employee)
-
7 Employees
-
Leave Types & Balances
-
Sample Payroll Run
Step 7: Start Development Server
npm run dev
The app will be available at http://localhost:3000.
Verification Checklist
After installation, verify:
Common Issues
Issue: "Cannot find module '@prisma/client'"
Solution:
npx prisma generate
npm install
Issue: "Connection refused to database"
Solution:
-
Verify PostgreSQL is running
-
Check DATABASE_URL in
.env
-
Ensure database exists
Issue: "Migration failed"
Solution:
npx prisma db push --force-reset
⚠️ This will delete all data!
Issue: "Port 3000 already in use"
Solution:
PORT=3001 npm run dev
Development Commands
|
Command |
Description |
npm run dev |
Start development server |
npm run build |
Build for production |
npm run start |
Start production server |
npm run lint |
Run ESLint |
npx prisma studio |
Open Prisma database GUI |
npx prisma db push |
Sync schema to database |
npx prisma migrate dev |
Run migrations (creates tables) |
npm run seed |
Seed demo data |
Production Build
# Build the application
npm run build
# Start production server
npm run start
Docker Setup (Optional)
Dockerfile
FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npx prisma generate
RUN npm run build
FROM node:18-alpine AS runner
WORKDIR /app
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./
COPY --from=builder /app/prisma ./prisma
ENV NODE_ENV=production
EXPOSE 3000
CMD ["node", "server.js"]
Docker Compose
version: '3.8'
services:
app:
build: .
ports:
- "3000:3000"
environment:
- DATABASE_URL=postgresql://user:pass@db:5432/cervo
depends_on:
- db
db:
image: postgres:15-alpine
environment:
- POSTGRES_USER=user
- POSTGRES_PASSWORD=pass
- POSTGRES_DB=cervo
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:
Nguồn: Topcode.vn