Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧮 PJ ou CLT Calculator - Brazilian Tax Comparison Tool

A comprehensive Brazilian tax calculator that helps professionals compare Person Jurídica (PJ) vs Consolidação das Leis do Trabalho (CLT) employment regimes with accurate 2025 tax calculations. 100% Production Ready with automated validation, security hardening, and complete testing coverage.

Production Ready Security Next.js 15 TypeScript Testing Docker i18n LGPD

Live at: pjouclt.com.br | Staging: staging.pjouclt.com.br


🎯 What is PJ ou CLT Calculator?

This platform helps Brazilian professionals make informed decisions about their employment regime by comparing the financial outcomes of working as:

  • PJ (Pessoa Jurídica): Independent contractor under Simples Nacional taxation
  • CLT (Consolidação das Leis do Trabalho): Formal employment with labor law protections

Key Features

✅ Accurate 2025 Tax Calculations

  • INSS (R$ 8,157.41 ceiling)
  • IRPF (R$ 3,036 exemption threshold)
  • Simples Nacional with Fator R optimization
  • Complete CLT benefits (13th salary, vacation, FGTS)

✅ Comprehensive Comparison

  • Real-time PJ vs CLT analysis
  • Break-even scenarios
  • Risk assessment
  • Net income calculations

✅ LGPD Compliant

  • Privacy-first architecture
  • No personal data storage
  • Local calculations (client-side)
  • Transparent data handling

✅ Multi-Language Support

  • Portuguese (Brazil) - Primary
  • English - International
  • Spanish - Latin America

🚀 Quick Start

Try the Calculator

Visit pjouclt.com.br and enter:

  1. Your monthly salary (CLT) or revenue (PJ)
  2. Number of dependents
  3. PJ activity type (services, commerce, industry)
  4. Optional: Current benefits and work hours

Get instant comparison results with detailed tax breakdowns!

Local Development

# Clone and install
git clone https://github.com/maxh33/pj-clt-calculator.git
cd pj-clt-calculator
npm install

# Start development server
npm run dev

# Visit http://localhost:3000

Environment Configuration

# Copy environment template
cp .env.template .env.local

# Configure required variables
NEXT_PUBLIC_SITE_URL=http://localhost:3000
POSTGRES_PASSWORD=your_secure_password
JWT_SECRET=your_jwt_secret_key
EMAIL_HOST=smtp.zoho.com
EMAIL_USER=pjouclt@yourdomain.com
RESEND_API_KEY=re_xxxxxxxxxx

📚 Documentation

User Guides

Technical Documentation

Development


🧮 Calculator Features

Tax Calculation Engines

CLT (Employment)

  • INSS Calculation: Progressive rates up to R$ 8,157.41 ceiling
  • IRPF Calculation: Federal income tax with deductions
  • 13th Salary: Extra monthly salary in December
  • Vacation Pay: 30 days + 1/3 additional
  • FGTS: 8% employer deposit
  • Benefits: Health insurance, meal vouchers, transportation

PJ (Independent Contractor)

  • Simples Nacional: Progressive taxation (Anexo III/V)
  • Fator R: Payroll-based tax optimization (≥28% of revenue)
  • Pro-labore: Optimized salary distribution
  • INSS: Separate calculation on pro-labore
  • Flexibility: No CLT guarantees, but higher potential income

Comparison Analysis

  • Net Income Comparison: Real disposable income after all taxes and benefits
  • Break-even Analysis: Salary/revenue needed for regime parity
  • Risk Assessment: Stability vs income potential
  • Scenario Planning: What-if analysis for different income levels

2025 Tax Tables Included

Tax Type Description Rates
INSS (CLT) Social security (employee) 7.5% to 14% progressive
IRPF Federal income tax 0% to 27.5% progressive
Simples Nacional PJ unified tax (Anexo III) 6% to 33% based on revenue
Simples Nacional PJ unified tax (Anexo V + Fator R) 15.5% to 30.5% progressive
FGTS Employment guarantee fund 8% (employer contribution)

🏗️ Technical Architecture

Technology Stack

  • Framework: Next.js 15 (App Router)
  • Language: TypeScript 5.8 (Strict mode)
  • Styling: Tailwind CSS 3.4
  • Database: PostgreSQL 16
  • Deployment: Docker + Traefik + VPS
  • Testing: Playwright (E2E + Component)
  • i18n: Custom dictionary system (PT/EN/ES)

Key Components

src/
├── app/
│   ├── [lang]/                 # Internationalized routes
│   │   ├── calculadora/        # Main calculator page
│   │   ├── guia-pj-clt/       # Educational guides
│   │   └── consultor/          # Professional referral
│   └── api/
│       ├── calculator/         # Tax calculation endpoints
│       ├── contact/            # Contact form with email
│       └── admin/              # LGPD compliance endpoints
├── lib/
│   ├── calculations/           # Tax engines (CLT, PJ, comparison)
│   ├── config/                 # Calculator configuration
│   ├── i18n/                   # Multi-language dictionaries
│   └── validations/            # Input validation (Brazilian context)
└── components/
    ├── calculator/             # Calculator UI components
    ├── sections/               # Page sections
    └── forms/                  # Contact and consultation forms

Tax Calculation Flow

graph LR
    A[User Input] --> B[Validation]
    B --> C[CLT Engine]
    B --> D[PJ Engine]
    C --> E[Comparison Logic]
    D --> E
    E --> F[Results Display]
    F --> G[Break-even Analysis]
    F --> H[Risk Assessment]
Loading

🧪 Testing & Quality

Intelligent Testing Strategy

Three-tier approach for efficient deployment:

# Critical Tests (100% required for deployment)
npm run test:critical         # Security, accessibility, production readiness

# Core Tests (85% threshold)
npm run test:core            # Contact forms, navigation, i18n, email

# Enhancement Tests (70% threshold)
npm run test:enhancement     # UI/UX, keyboard navigation, performance

Production Validation

# Validate production readiness
npm run production:check

# Build and validate for deployment
npm run production:validate

# Deployment readiness check
npm run test:validate-deployment

Expected Results

  • 🔒 Critical Tests: 100% pass rate (blocks deployment)
  • 🎯 Core Tests: ≥85% threshold (flexible)
  • ✨ Enhancement Tests: ≥70% threshold (non-blocking)
  • 📊 Overall: ≥80% for deployment approval

📖 Complete testing guide: docs/testing/README.md


🐳 Deployment

Docker Deployment (VPS)

# Production deployment
docker-compose -f docker-compose.prod.yml up -d

# Staging deployment
docker-compose -f docker-compose.staging.yml up -d

# View logs
docker logs pj-clt-calculator-prod -f

Database Management 🗄️

No port conflicts - containers communicate via internal Docker network:

# Connect to database
npm run db:connect            # Staging
npm run db:connect:prod       # Production

# Create backup
npm run db:backup             # Staging
npm run db:backup:prod        # Production

# View statistics
npm run db:stats              # Staging

# Test connection
npm run db:test               # Staging

Or use helper scripts directly:

# Linux/Mac
./scripts/db-connect.sh staging psql

# Windows
scripts\db-connect.bat staging psql

Infrastructure

  • SSL: Automatic via Traefik + Let's Encrypt
  • Monitoring: Prometheus metrics at /api/metrics
  • Health Checks: /api/health endpoint
  • Networking: monitoring_shared_monitoring_network (external)
  • Domains:
    • Production: pjouclt.com.br
    • Staging: staging.pjouclt.com.br

📖 Deployment guide: docs/deployment/overview.md


🔒 Security & Compliance

LGPD (Brazilian Data Protection Law)

✅ Privacy-First Architecture

  • No personal data stored on servers
  • Client-side calculations
  • Explicit user consent for contact forms
  • Data export and deletion endpoints

✅ Security Features

  • CSRF protection on all forms
  • Input sanitization and validation
  • Rate limiting (100 requests/15 minutes)
  • Secure JWT-based admin authentication
  • CSP headers and XSS prevention

Professional Disclaimers

⚠️ Educational Purpose Only This calculator provides informational estimates based on 2025 Brazilian tax tables. Results are not professional advice. Always consult a qualified accountant (contador) for definitive tax decisions.


📊 Performance & SEO

Performance Optimization

  • ⚡ 90+ Lighthouse Scores out of the box
  • 🖼️ Image Optimization: WebP format, lazy loading
  • 📦 Code Splitting: Route-based optimization
  • 📱 Mobile-First: Responsive design, touch-optimized

SEO Features

  • 🔍 Dynamic Robots.txt: Environment-aware crawling
  • 📝 Multi-Language Sitemaps: PT/EN/ES with proper hreflang
  • 🌐 Structured Data: Organization, Calculator, FAQ schemas
  • 🔗 Social Sharing: Open Graph and Twitter Cards
  • 📍 Local SEO: Brazilian business context

Google Analytics 4

# Enable analytics in .env
NEXT_PUBLIC_ANALYTICS_ENABLED=true
NEXT_PUBLIC_GA_MEASUREMENT_ID=G-XXXXXXXXXX

Pre-configured Events:

  • Calculator usage tracking
  • Contact form submissions
  • Newsletter signups
  • Professional referral clicks

🛠️ Development Commands

Development

npm run dev                   # Development server (port 3000)
npm run dev:alt               # Alternative port (3001)
npm run build                 # Production build
npm start                     # Start production server

Testing

npm test                      # All test categories
npm run test:critical         # Critical tests only
npm run test:headed           # Visual test execution
npm run test:debug            # Step-by-step debugging
npm run test:docker           # Docker environment test

Database

npm run db:connect            # Connect to staging DB
npm run db:backup             # Create backup
npm run db:stats              # View statistics
npm run db:migrate            # Run migrations
npm run db:seed               # Seed data

Calculator

npm run calculator:validate   # Validate tax calculations
npm run calculator:update-rates # Update tax tables

Production

npm run production:check      # Validate readiness
npm run production:validate   # Build + validate

📈 Roadmap

Phase 1: Foundation ✅ (Completed)

  • Tax calculation engines (CLT, PJ, Fator R)
  • Multi-language support (PT, EN, ES)
  • LGPD compliance
  • Production deployment
  • VPS port conflict resolution

Phase 2: Enhancements 🚧 (In Progress)

  • Tax automation system (n8n + Crawl4AI)
  • Advanced scenario planning
  • PDF report generation
  • Professional referral system

Phase 3: Scale 📋 (Planned)

  • User accounts (save calculations)
  • Historical tax table comparisons
  • Industry-specific presets
  • API for integration

📖 Full roadmap: docs/project/roadmap.md


🤝 Contributing

Bug Reports & Feature Requests

Found a calculation error or have a feature idea?

  1. Check existing GitHub Issues
  2. Create new issue with:
    • Clear description
    • Steps to reproduce (for bugs)
    • Expected vs actual behavior
    • Screenshots if applicable

Tax Table Updates

Brazilian tax laws change regularly. To update:

  1. Modify: src/lib/data/tax-rates.ts
  2. Run: npm run calculator:validate
  3. Submit PR with official source reference

📞 Support

For Users

For Developers


📄 License

This project is proprietary software. All rights reserved.

For licensing inquiries, contact: pjouclt@kodalabs.dev


🏆 Credits

Developed by: KodaLabs Development

Tax Expertise: Based on official Brazilian government tax tables (2025)

Technology Partners:

  • Next.js by Vercel
  • PostgreSQL by PostgreSQL Global Development Group
  • Traefik by Traefik Labs

🎉 Recent Updates

October 2025 - Production Ready Release ✅

🔧 Major Fixes:

  • ✅ TypeScript build errors resolved (dictionary type inconsistencies)
  • ✅ VPS port conflict resolution (internal Docker networking)
  • ✅ Database helper scripts for port-free access
  • ✅ Documentation aligned with calculator project

🚀 Deployment Status:

  • ✅ TypeScript compilation passing
  • ✅ Docker builds successful
  • ✅ Container auto-startup working
  • ✅ Database connectivity verified
  • ✅ Security and accessibility compliant

📚 Documentation:


Ready to compare PJ vs CLT? Visit pjouclt.com.br 🚀

For developers: Check CLAUDE.md for AI-assisted development workflow.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages