AI Development GuideFoundations
Repository Structure
File and folder layout for the HRMS codebase
Repository Structure
This is the standard directory layout for the HRMS monorepo.
Directory Layout
hrms/
├── apps/
│ ├── web/ # Next.js frontend
│ │ ├── app/ # App Router pages
│ │ │ ├── (auth)/ # Auth routes
│ │ │ ├── (dashboard)/ # Dashboard routes
│ │ │ ├── api/ # API routes
│ │ │ └── layout.tsx
│ │ ├── components/ # UI components
│ │ │ ├── ui/ # Shadcn components
│ │ │ ├── forms/ # Form components
│ │ │ └── layouts/ # Layout components
│ │ ├── lib/ # Utilities
│ │ │ ├── api.ts # API client
│ │ │ ├── auth.ts # Auth utilities
│ │ │ └── utils.ts # General utilities
│ │ └── hooks/ # Custom hooks
│ │ ├── useEmployees.ts
│ │ ├── useOrg.ts
│ │ └── useTimeOff.ts
│ │
│ └── api/ # NestJS backend
│ ├── src/
│ │ ├── modules/ # Feature modules
│ │ │ ├── employees/ # Employee management
│ │ │ │ ├── employees.controller.ts
│ │ │ │ ├── employees.service.ts
│ │ │ │ ├── employees.module.ts
│ │ │ │ └── dto/
│ │ │ ├── org/ # Org structure module
│ │ │ │ ├── org.controller.ts
│ │ │ │ ├── org.service.ts
│ │ │ │ └── org.module.ts
│ │ │ ├── timeoff/ # Time-off tracking
│ │ │ ├── documents/ # Document management
│ │ │ ├── goals/ # OKR/Goals
│ │ │ └── feed/ # Team communication
│ │ ├── common/ # Shared utilities
│ │ │ ├── decorators/ # Custom decorators
│ │ │ ├── guards/ # Auth guards
│ │ │ ├── filters/ # Exception filters
│ │ │ └── pipes/ # Validation pipes
│ │ ├── auth/ # Authentication
│ │ │ ├── auth.controller.ts
│ │ │ ├── auth.service.ts
│ │ │ └── strategies/
│ │ └── prisma/ # Database
│ │ ├── prisma.service.ts
│ │ └── prisma.module.ts
│ └── test/ # Test files
│ ├── unit/
│ └── integration/
│
├── packages/
│ ├── types/ # Shared TypeScript types
│ │ ├── employee.ts
│ │ ├── org.ts
│ │ └── index.ts
│ └── config/ # Shared configurations
│ ├── eslint/
│ └── tsconfig/
│
├── prisma/ # Database schema
│ ├── schema.prisma
│ ├── migrations/
│ └── seed.ts
│
├── docker/ # Docker configurations
│ ├── Dockerfile.api
│ ├── Dockerfile.web
│ └── docker-compose.yml
│
└── docs/ # Documentation
└── adr/ # Architecture decisionsModule Structure
Each feature module follows this structure:
modules/employees/
├── employees.controller.ts # HTTP handlers
├── employees.service.ts # Business logic
├── employees.repository.ts # Data access (optional)
├── employees.module.ts # NestJS module
├── dto/
│ ├── create-employee.dto.ts
│ ├── update-employee.dto.ts
│ └── employee-response.dto.ts
└── entities/
└── employee.entity.ts # Type definitionsNaming Conventions
| Type | Convention | Example |
|---|---|---|
| Files | kebab-case | employee-service.ts |
| Classes | PascalCase | EmployeeService |
| Functions | camelCase | getEmployeeById |
| Constants | UPPER_CASE | MAX_PAGE_SIZE |
| Interfaces | PascalCase | EmployeeResponse |
| DTOs | PascalCase + Dto | CreateEmployeeDto |
Import Order
Follow this import order:
// 1. External packages
import { Injectable } from '@nestjs/common'
import { PrismaClient } from '@prisma/client'
// 2. Internal packages
import { Employee } from '@packages/types'
// 3. Local imports
import { PrismaService } from '../prisma/prisma.service'
import { CreateEmployeeDto } from './dto/create-employee.dto'File Size Limits
To maintain code quality:
| File Type | Max Lines |
|---|---|
| Service | 150 |
| Controller | 100 |
| Repository | 100 |
| DTO | 50 |
| Test | 200 |