Skip to content

Latest commit

 

History

History
95 lines (77 loc) · 3.7 KB

File metadata and controls

95 lines (77 loc) · 3.7 KB

NexusHR - Human Resource Management System

Overview

NexusHR is a production-ready HRMS (Human Resource Management System) MVP designed for companies with 50-500 employees. The application provides role-based access control, employee self-service capabilities, leave management, attendance tracking, payroll processing, and recruitment features.

The system follows a full-stack TypeScript architecture with a React frontend and Express backend, using MongoDB Atlas as the primary database.

User Preferences

Preferred communication style: Simple, everyday language.

System Architecture

Frontend Architecture

  • Framework: React with TypeScript, built using Vite
  • Styling: Tailwind CSS with shadcn/ui component library (New York style variant)
  • State Management: TanStack React Query for server state, React Context for auth state
  • Routing: Wouter for client-side navigation
  • Form Handling: React Hook Form with Zod validation
  • Charts: Recharts for dashboard analytics
  • Animations: Framer Motion for page transitions

Backend Architecture

  • Framework: Express.js with TypeScript
  • Database: MongoDB Atlas with Mongoose ODM
  • Authentication: JWT-based (access tokens stored in localStorage)
  • Password Security: bcryptjs for hashing
  • Validation: Zod schemas shared between frontend and backend

Project Structure

/client          - React frontend application
  /src
    /components  - UI components (shadcn/ui based)
    /hooks       - Custom React hooks for data fetching
    /pages       - Page components
    /lib         - Utilities and query client
/server          - Express backend
  /middleware    - Auth and RBAC middleware
  routes.ts      - API route definitions
  models.ts      - Mongoose schemas
  db.ts          - MongoDB connection
/shared          - Shared TypeScript types and Zod schemas
  schema.ts      - Data models and validation
  routes.ts      - API contract definitions

Authentication & Authorization

  • JWT tokens issued on login, stored in localStorage
  • Token passed via Authorization: Bearer <token> header
  • Role-based access control with 4 roles: SUPER_ADMIN, HR_ADMIN, MANAGER, EMPLOYEE
  • Middleware verifies tokens and checks role permissions

Data Models

  • User: Authentication credentials and role assignment
  • Employee: Personal and employment information
  • LeaveRequest: Leave applications with approval workflow
  • Attendance: Daily check-in/check-out records
  • Candidate: Recruitment pipeline tracking
  • SalaryStructure/PayrollRun: Payroll management

API Design

  • RESTful endpoints under /api/* prefix
  • Standardized response format: { success: boolean, data?: T, error?: string }
  • Zod schemas define request/response contracts in /shared/routes.ts

External Dependencies

Database

  • MongoDB Atlas: Cloud-hosted MongoDB database
  • Connection via MONGO_URI environment variable
  • Mongoose ODM for schema definition and queries

Authentication

  • jsonwebtoken: JWT creation and verification
  • bcryptjs: Password hashing
  • JWT_SECRET environment variable required

Build & Development

  • Vite: Frontend dev server and bundler
  • esbuild: Production server bundling
  • tsx: TypeScript execution for development
  • drizzle-kit: Database migration tooling (PostgreSQL support available)

Environment Variables Required

  • MONGO_URI: MongoDB Atlas connection string
  • JWT_SECRET: Secret key for JWT signing
  • DATABASE_URL: PostgreSQL connection (if using Drizzle/Postgres features)

Seed Data

Run server/seed.ts to populate initial data:

  • Admin user: admin@company.com / admin123
  • HR Admin: sarah.hr@company.com / password123
  • Sample managers and employees