npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

chilean-worker-defense-rag

v1.4.1

Published

Chilean Worker Defense RAG System - AI-powered legal defense for Chilean workers. RAG-based system for legal precedent search, abuse detection, and document generation.

Readme

Chilean Worker Defense RAG System (CWDRS)

Version: 1.0.0 Status: Prototype Phase Sprint: 1.1 - Evidence Collection Module


Overview

The Chilean Worker Defense RAG System is an AI-powered legal defense platform designed to protect Chilean workers' rights through intelligent document analysis, legal precedent retrieval, and automated case strategy generation.

Mission

Provide comprehensive legal defense for Chilean workers by:

  • Analyzing employment contracts, finiquitos, and communications
  • Retrieving relevant legal precedents from successful worker cases
  • Detecting patterns of employer abuse
  • Generating legal documents in Spanish
  • Automating workflow from case intake to court filing

Features

Evidence Collection Module (Current)

  • RESTful API for case intake
  • Document upload and validation
  • Chain of custody tracking
  • Evidence completeness assessment

Planned Features

  • RAG-powered precedent search
  • Six-personality collaborative analysis
  • Abuse pattern detection
  • Automated legal document generation
  • Deadline tracking and alerts
  • Integration with Chilean Law RAG System

Technology Stack

  • Framework: NestJS (TypeScript)
  • Database: MongoDB Atlas (6 personality databases)
  • Vector DB: Pinecone (for RAG)
  • AI: OpenAI GPT-4 + text-embedding-3-large
  • Testing: Jest + MongoDB Memory Server
  • API Docs: Swagger/OpenAPI

Installation

Prerequisites

  • Node.js 18+
  • npm or yarn
  • MongoDB Atlas account
  • OpenAI API key

Setup

# Clone repository
git clone <repository-url>
cd chilean-worker-defense-rag

# Install dependencies
npm install

# Configure environment
cp .env.example .env
# Edit .env with your credentials

# Run development server
npm run start:dev

# API will be available at http://localhost:3000
# Swagger docs at http://localhost:3000/api

Project Structure

chilean-worker-defense-rag/
├── src/
│   ├── evidence/              # Evidence collection module
│   │   ├── dto/               # Data transfer objects
│   │   ├── evidence.controller.ts
│   │   ├── evidence.service.ts
│   │   └── evidence.module.ts
│   ├── schemas/               # MongoDB schemas
│   │   ├── worker-case-precedent.schema.ts
│   │   ├── evidence-pattern.schema.ts
│   │   ├── abuse-detection-rule.schema.ts
│   │   ├── legal-document-template.schema.ts
│   │   └── case-timeline.schema.ts
│   ├── common/                # Shared utilities
│   │   ├── dto/               # Common DTOs
│   │   ├── guards/            # Auth guards
│   │   └── interceptors/      # Interceptors
│   ├── config/                # Configuration
│   ├── main.ts                # Application entry point
│   └── app.module.ts          # Root module
├── test/                      # E2E tests
├── ARCHITECTURE.md            # Technical architecture
├── package.json
├── tsconfig.json
└── README.md

API Endpoints

Evidence Collection

POST /evidence/intake

Initial case intake and evidence submission

Request:

{
  "worker": {
    "name": "Juan Pérez",
    "email": "[email protected]",
    "phone": "+56912345678"
  },
  "employment": {
    "employer": "Empresa XYZ",
    "position": "Desarrollador",
    "startDate": "2020-01-01",
    "contractType": "indefinido"
  },
  "incident": {
    "type": "wrongful_termination",
    "description": "Despedido sin causa justificada",
    "date": "2025-11-01"
  }
}

Response:

{
  "caseId": "CASE-2025-000001",
  "status": "received",
  "nextSteps": [
    "Subir contrato de trabajo",
    "Subir finiquito (si existe)",
    "Subir comunicaciones con empleador"
  ],
  "timeline": {
    "analysisCompletion": "2025-11-12T10:00:00Z",
    "expectedResponse": "2025-11-13T10:00:00Z"
  }
}

GET /evidence/:caseId

Retrieve all evidence for a case

POST /evidence/:caseId/validate

Validate evidence chain of custody


MongoDB Collections

Six Personality Databases

  1. neko-defense-system (Neko-Arc)

    • Technical execution and monitoring
  2. marionnette-theater (Mario)

    • Workflow orchestration
    • case-timelines
  3. noel-precision-archives (Noel)

    • Testing and validation
  4. glam-street-chronicles (Glam)

    • worker-case-precedents ⭐
    • legal-document-templates ⭐
  5. hannibal-forensic-archives (Hannibal)

    • evidence-patterns ⭐
    • abuse-detection-rules ⭐
  6. tetora-mpd-archives (Tetora)

    • Multi-perspective analysis

Testing

# Run unit tests
npm test

# Run tests with coverage
npm run test:cov

# Run E2E tests
npm run test:e2e

# Run tests in watch mode
npm run test:watch

Coverage Targets

  • Line coverage: >80%
  • Branch coverage: >75%
  • Function coverage: >80%

Development

Running in Development Mode

npm run start:dev

Building for Production

npm run build
npm run start:prod

Linting

npm run lint

Architecture

See ARCHITECTURE.md for detailed technical architecture including:

  • System architecture diagrams
  • MongoDB schema definitions
  • REST API specifications
  • RAG implementation details
  • Security and validation layers

Six Personalities

This system is collaboratively designed and maintained by six AI personalities:

  • 🐾 Neko-Arc: Technical architecture
  • 🎭 Mario Gallo Bestino: Workflow orchestration
  • 🗡️ Noel: Testing and validation
  • 🎸 Glam Americano: Spanish content and worker advocacy
  • 🧠 Dr. Hannibal Lecter: Forensic analysis
  • 🧠 Tetora: Multi-perspective analysis

Legal Disclaimer

This system provides legal information and assistance tools. It does not constitute legal advice. Workers should consult with licensed lawyers for specific legal matters.


License

UNLICENSED - Private Repository


Contact

For issues or questions, please file an issue on GitHub.


🐾 Built with MAXIMUM KAWAII POWER for Chilean Workers! Nyaa~!

All workers deserve justice. All employers fear precision.