catalogmx 0.3.0__py3-none-any.whl → 0.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. catalogmx/__init__.py +133 -19
  2. catalogmx/calculators/__init__.py +113 -0
  3. catalogmx/calculators/costo_trabajador.py +213 -0
  4. catalogmx/calculators/impuestos.py +920 -0
  5. catalogmx/calculators/imss.py +370 -0
  6. catalogmx/calculators/isr.py +290 -0
  7. catalogmx/calculators/resico.py +154 -0
  8. catalogmx/catalogs/banxico/__init__.py +29 -3
  9. catalogmx/catalogs/banxico/cetes_sqlite.py +279 -0
  10. catalogmx/catalogs/banxico/inflacion_sqlite.py +302 -0
  11. catalogmx/catalogs/banxico/salarios_minimos_sqlite.py +295 -0
  12. catalogmx/catalogs/banxico/tiie_sqlite.py +279 -0
  13. catalogmx/catalogs/banxico/tipo_cambio_usd_sqlite.py +255 -0
  14. catalogmx/catalogs/banxico/udis_sqlite.py +332 -0
  15. catalogmx/catalogs/cnbv/__init__.py +9 -0
  16. catalogmx/catalogs/cnbv/sectores.py +173 -0
  17. catalogmx/catalogs/conapo/__init__.py +15 -0
  18. catalogmx/catalogs/conapo/sistema_urbano_nacional.py +50 -0
  19. catalogmx/catalogs/conapo/zonas_metropolitanas.py +230 -0
  20. catalogmx/catalogs/ift/__init__.py +1 -1
  21. catalogmx/catalogs/ift/codigos_lada.py +517 -313
  22. catalogmx/catalogs/inegi/__init__.py +17 -0
  23. catalogmx/catalogs/inegi/scian.py +127 -0
  24. catalogmx/catalogs/mexico/__init__.py +2 -0
  25. catalogmx/catalogs/mexico/giros_mercantiles.py +119 -0
  26. catalogmx/catalogs/sat/carta_porte/material_peligroso.py +5 -1
  27. catalogmx/catalogs/sat/cfdi_4/clave_prod_serv.py +78 -0
  28. catalogmx/catalogs/sat/cfdi_4/tasa_o_cuota.py +2 -1
  29. catalogmx/catalogs/sepomex/__init__.py +2 -1
  30. catalogmx/catalogs/sepomex/codigos_postales.py +30 -2
  31. catalogmx/catalogs/sepomex/codigos_postales_completo.py +261 -0
  32. catalogmx/cli.py +12 -9
  33. catalogmx/data/__init__.py +10 -0
  34. catalogmx/data/mexico_dynamic.sqlite3 +0 -0
  35. catalogmx/data/updater.py +362 -0
  36. catalogmx/generators/__init__.py +20 -0
  37. catalogmx/generators/identity.py +582 -0
  38. catalogmx/helpers.py +177 -3
  39. catalogmx/utils/__init__.py +29 -0
  40. catalogmx/utils/clabe_utils.py +417 -0
  41. catalogmx/utils/text.py +7 -1
  42. catalogmx/validators/clabe.py +52 -2
  43. catalogmx/validators/nss.py +32 -27
  44. catalogmx/validators/rfc.py +185 -52
  45. catalogmx-0.4.0.dist-info/METADATA +905 -0
  46. {catalogmx-0.3.0.dist-info → catalogmx-0.4.0.dist-info}/RECORD +51 -25
  47. {catalogmx-0.3.0.dist-info → catalogmx-0.4.0.dist-info}/WHEEL +1 -1
  48. catalogmx/catalogs/banxico/udis.py +0 -279
  49. catalogmx-0.3.0.dist-info/METADATA +0 -644
  50. {catalogmx-0.3.0.dist-info → catalogmx-0.4.0.dist-info}/entry_points.txt +0 -0
  51. {catalogmx-0.3.0.dist-info → catalogmx-0.4.0.dist-info}/licenses/AUTHORS.rst +0 -0
  52. {catalogmx-0.3.0.dist-info → catalogmx-0.4.0.dist-info}/licenses/LICENSE +0 -0
  53. {catalogmx-0.3.0.dist-info → catalogmx-0.4.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,905 @@
1
+ Metadata-Version: 2.4
2
+ Name: catalogmx
3
+ Version: 0.4.0
4
+ Summary: Comprehensive Mexican data validators and official catalogs library - 170K+ records
5
+ Author-email: Luis Fernando Barrera <luisfernando@informind.com>
6
+ Maintainer-email: Luis Fernando Barrera <luisfernando@informind.com>
7
+ License: BSD-2-Clause
8
+ Project-URL: Homepage, https://github.com/openbancor/catalogmx
9
+ Project-URL: Documentation, https://catalogmx.readthedocs.io
10
+ Project-URL: Repository, https://github.com/openbancor/catalogmx.git
11
+ Project-URL: Issues, https://github.com/openbancor/catalogmx/issues
12
+ Project-URL: Changelog, https://github.com/openbancor/catalogmx/blob/main/CHANGELOG.rst
13
+ Keywords: mexico,rfc,curp,clabe,nss,sat,cfdi,inegi,sepomex,banxico,validators,catalogs,postal-codes,geographic-data
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Financial and Insurance Industry
17
+ Classifier: License :: OSI Approved :: BSD License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Programming Language :: Python :: 3.14
26
+ Classifier: Programming Language :: Python :: Implementation :: CPython
27
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
28
+ Classifier: Topic :: Office/Business :: Financial
29
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
30
+ Classifier: Topic :: Utilities
31
+ Classifier: Typing :: Typed
32
+ Requires-Python: >=3.10
33
+ Description-Content-Type: text/markdown
34
+ License-File: LICENSE
35
+ License-File: AUTHORS.rst
36
+ Requires-Dist: unidecode>=1.4.0
37
+ Requires-Dist: click>=8.0.0
38
+ Provides-Extra: generators
39
+ Requires-Dist: faker>=19.0.0; extra == "generators"
40
+ Provides-Extra: dev
41
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
42
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
43
+ Requires-Dist: black>=23.0.0; extra == "dev"
44
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
45
+ Requires-Dist: mypy>=1.7.0; extra == "dev"
46
+ Requires-Dist: faker>=19.0.0; extra == "dev"
47
+ Provides-Extra: docs
48
+ Requires-Dist: sphinx>=7.0.0; extra == "docs"
49
+ Requires-Dist: sphinx-rtd-theme>=2.0.0; extra == "docs"
50
+ Requires-Dist: sphinx-autodoc-typehints>=1.25.0; extra == "docs"
51
+ Provides-Extra: all
52
+ Requires-Dist: catalogmx[dev,docs,generators]; extra == "all"
53
+ Dynamic: license-file
54
+
55
+ # catalogmx
56
+
57
+ ## Enterprise-Grade Mexican Data Validation and Official Catalog Library
58
+
59
+ **catalogmx** is a comprehensive, production-ready library providing validated access to Mexican government data sources and robust validation tools for Mexican identification systems. Built for financial institutions, fintech applications, e-commerce platforms, and enterprise systems requiring compliance with Mexican regulations.
60
+
61
+ [![Python Version](https://img.shields.io/pypi/pyversions/catalogmx)](https://pypi.org/project/catalogmx/)
62
+ [![PyPI Version](https://img.shields.io/pypi/v/catalogmx)](https://pypi.org/project/catalogmx/)
63
+ [![NPM Version](https://img.shields.io/npm/v/catalogmx)](https://www.npmjs.com/package/catalogmx)
64
+ [![pub.dev Version](https://img.shields.io/pub/v/catalogmx)](https://pub.dev/packages/catalogmx)
65
+ [![Test Coverage](https://img.shields.io/badge/coverage-93.78%25-brightgreen)](https://github.com/openbancor/catalogmx)
66
+ [![Tests Passing](https://img.shields.io/badge/tests-1206%20passing-brightgreen)](https://github.com/openbancor/catalogmx)
67
+ [![License](https://img.shields.io/badge/license-BSD--2--Clause-blue.svg)](LICENSE)
68
+
69
+ **Languages**: [English](#) | [Español](README.es.md)
70
+
71
+ ---
72
+
73
+ ## Executive Summary
74
+
75
+ **catalogmx** delivers enterprise-grade validation and data access for Mexican regulatory compliance and business operations:
76
+
77
+ - **4 Production-Ready Validators**: RFC, CURP, CLABE, NSS with complete official algorithms
78
+ - **58 Official Government Catalogs**: SAT, INEGI, SEPOMEX, Banxico, IFT, National Regulations
79
+ - **470,000+ Verified Records**: Complete databases with 157K postal codes, 300K localities, 2.4K municipalities
80
+ - **Multi-Platform Support**: Python 3.10+, TypeScript 5.0+, and Dart/Flutter 3.0+ with identical APIs
81
+ - **Type-Safe Implementation**: Full type hints (PEP 604), TypeScript declarations, and Dart null-safety
82
+ - **Enterprise Quality**: 93.78% test coverage (1,206 tests across all platforms), comprehensive documentation, production-ready
83
+
84
+ ---
85
+
86
+ ## Business Value
87
+
88
+ ### Financial Services
89
+ - **KYC/AML Compliance**: Validate RFC, CURP, and NSS for customer onboarding
90
+ - **SPEI Transfers**: CLABE validation with bank directory integration
91
+ - **Tax Compliance**: Complete SAT catalog access for CFDI generation
92
+ - **Payroll Processing**: Validated IMSS data and nómina catalogs
93
+
94
+ ### E-Commerce & Logistics
95
+ - **Address Validation**: 157K postal codes with municipality and state data
96
+ - **Shipping Integration**: Geographic search with GPS coordinates
97
+ - **Customs Documentation**: Comercio Exterior catalogs for international shipments
98
+ - **Route Planning**: Carta Porte catalogs with airports, seaports, and highways
99
+
100
+ ### Government & Public Sector
101
+ - **Citizen Services**: CURP and RFC validation for government applications
102
+ - **Geographic Analysis**: Complete INEGI municipal and locality data
103
+ - **Regulatory Compliance**: Up-to-date SAT catalogs for tax systems
104
+ - **Data Quality**: Validated against official government sources
105
+
106
+ ### Technology Platforms
107
+ - **Fintech Applications**: Banking, payments, and financial services
108
+ - **SaaS Platforms**: Multi-tenant systems requiring Mexican data
109
+ - **API Services**: RESTful and GraphQL backends
110
+ - **Mobile Applications**: Lightweight validators with offline capability
111
+
112
+ ---
113
+
114
+ ## Installation
115
+
116
+ ### Python
117
+
118
+ **Recommended (using uv - 10-100x faster):**
119
+ ```bash
120
+ # Install uv
121
+ curl -LsSf https://astral.sh/uv/install.sh | sh
122
+
123
+ # Install catalogmx
124
+ uv pip install catalogmx
125
+ ```
126
+
127
+ **Using pip:**
128
+ ```bash
129
+ pip install catalogmx
130
+ ```
131
+
132
+ **Development install:**
133
+ ```bash
134
+ cd packages/python
135
+ uv pip install -e ".[dev]"
136
+ ```
137
+
138
+ ### TypeScript/JavaScript
139
+
140
+ ```bash
141
+ npm install catalogmx
142
+ ```
143
+
144
+ **Yarn:**
145
+ ```bash
146
+ yarn add catalogmx
147
+ ```
148
+
149
+ **Development:**
150
+ ```bash
151
+ cd packages/typescript
152
+ npm install
153
+ npm run build
154
+ ```
155
+
156
+ ### Dart/Flutter
157
+
158
+ **Flutter:**
159
+ ```bash
160
+ flutter pub add catalogmx
161
+ ```
162
+
163
+ **Dart only:**
164
+ ```bash
165
+ dart pub add catalogmx
166
+ ```
167
+
168
+ **Manual (pubspec.yaml):**
169
+ ```yaml
170
+ dependencies:
171
+ catalogmx: ^0.3.0
172
+ ```
173
+
174
+ **Development:**
175
+ ```bash
176
+ cd packages/dart
177
+ dart pub get
178
+ dart test
179
+ ```
180
+
181
+ ---
182
+
183
+ ## Core Validators
184
+
185
+ ### RFC (Registro Federal de Contribuyentes)
186
+
187
+ Validate Mexican tax identification numbers for individuals and corporations.
188
+
189
+ ```python
190
+ from catalogmx.validators import rfc
191
+
192
+ # Validate existing RFC
193
+ is_valid = rfc.validate_rfc("GODE561231GR8") # Returns: True
194
+
195
+ # Generate RFC for individual (Persona Física)
196
+ rfc_code = rfc.generate_rfc_persona_fisica(
197
+ nombre="Juan",
198
+ apellido_paterno="García",
199
+ apellido_materno="López",
200
+ fecha_nacimiento="1990-05-15"
201
+ ) # Returns: "GALJ900515XXX"
202
+
203
+ # Generate RFC for corporation (Persona Moral)
204
+ rfc_code = rfc.generate_rfc_persona_moral(
205
+ razon_social="Tecnología Sistemas Integrales S.A.",
206
+ fecha_constitucion="2009-09-09"
207
+ ) # Returns: "TSI090909XXX"
208
+
209
+ # Detect RFC type
210
+ rfc_type = rfc.detect_rfc_type("GODE561231GR8") # Returns: "fisica"
211
+ ```
212
+
213
+ **Features:**
214
+ - Complete Módulo 11 homoclave algorithm
215
+ - Check digit validation
216
+ - 170+ cacophonic word replacement
217
+ - Support for foreign residents
218
+ - Type detection (física/moral)
219
+
220
+ ### CURP (Clave Única de Registro de Población)
221
+
222
+ Validate and generate Mexican national identification numbers.
223
+
224
+ ```python
225
+ from catalogmx.validators import curp
226
+
227
+ # Validate existing CURP
228
+ is_valid = curp.validate_curp("GORS561231HVZNNL00") # Returns: True
229
+
230
+ # Generate CURP
231
+ curp_code = curp.generate_curp(
232
+ nombre="Juan",
233
+ apellido_paterno="García",
234
+ apellido_materno="López",
235
+ fecha_nacimiento="1990-05-15",
236
+ sexo="H",
237
+ estado="Jalisco"
238
+ ) # Returns: "GALJ900515HJCRPN01"
239
+
240
+ # Extract information from CURP
241
+ info = curp.get_curp_info("GORS561231HVZNNL00")
242
+ # Returns: {
243
+ # 'birth_date': datetime.date(1956, 12, 31),
244
+ # 'gender': 'H',
245
+ # 'state': 'Veracruz',
246
+ # 'is_valid': True
247
+ # }
248
+ ```
249
+
250
+ **Features:**
251
+ - Complete RENAPO algorithm implementation
252
+ - 18-position validation
253
+ - Check digit verification (position 18)
254
+ - 32 Mexican state code validation
255
+ - 70+ inconvenient word handling
256
+ - Birth date, gender, and state extraction
257
+
258
+ ### CLABE (Clave Bancaria Estandarizada)
259
+
260
+ Validate Mexican bank account numbers for electronic transfers.
261
+
262
+ ```python
263
+ from catalogmx.validators import clabe
264
+
265
+ # Validate CLABE
266
+ is_valid = clabe.validate_clabe("002010077777777771") # Returns: True
267
+
268
+ # Generate CLABE with check digit
269
+ clabe_number = clabe.generate_clabe(
270
+ bank_code="002", # Banamex
271
+ branch_code="010",
272
+ account_number="07777777777"
273
+ ) # Returns: "002010077777777771"
274
+
275
+ # Extract CLABE components
276
+ info = clabe.get_clabe_info("002010077777777771")
277
+ # Returns: {
278
+ # 'bank_code': '002',
279
+ # 'branch_code': '010',
280
+ # 'account_number': '07777777777',
281
+ # 'check_digit': '1',
282
+ # 'clabe': '002010077777777771'
283
+ # }
284
+ ```
285
+
286
+ **Features:**
287
+ - Modulo 10 check digit validation
288
+ - Bank code verification
289
+ - Integration with Banxico SPEI directory
290
+ - Component extraction (bank, branch, account)
291
+ - Check digit generation
292
+
293
+ ### NSS (Número de Seguridad Social)
294
+
295
+ Validate Mexican social security numbers.
296
+
297
+ ```python
298
+ from catalogmx.validators import nss
299
+
300
+ # Validate NSS
301
+ is_valid = nss.validate_nss("12345678903") # Returns: True
302
+
303
+ # Generate NSS with check digit
304
+ nss_number = nss.generate_nss(
305
+ subdelegation="12",
306
+ year="34",
307
+ serial="56",
308
+ sequential="7890"
309
+ ) # Returns: "12345678903"
310
+
311
+ # Extract NSS components
312
+ info = nss.get_nss_info("12345678903")
313
+ # Returns: {
314
+ # 'subdelegation': '12',
315
+ # 'year': '34',
316
+ # 'serial': '56',
317
+ # 'sequential': '7890',
318
+ # 'check_digit': '3',
319
+ # 'nss': '12345678903'
320
+ # }
321
+ ```
322
+
323
+ **Features:**
324
+ - Modified Luhn algorithm implementation
325
+ - IMSS subdelegation validation
326
+ - Component extraction
327
+ - Check digit generation and verification
328
+
329
+ ---
330
+
331
+ ## Official Catalogs
332
+
333
+ ### SAT (Servicio de Administración Tributaria) - 31 Catalogs
334
+
335
+ #### CFDI 4.0 (Digital Tax Receipts) - 16 Catalogs
336
+ - **Tax Regimes** (c_RegimenFiscal): 33 fiscal regimes
337
+ - **CFDI Uses** (c_UsoCFDI): 30+ valid uses
338
+ - **Payment Methods** (c_FormaPago / c_MetodoPago): 99 payment forms, 3 payment methods
339
+ - **Tax Types** (c_Impuesto): Federal and local taxes
340
+ - **Product/Service Codes** (c_ClaveProdServ): 52,896 codes with SQLite FTS5 search
341
+ - **Unit Codes** (c_ClaveUnidad): 2,400+ measurement units
342
+ - **Document Types** (c_TipoComprobante): Invoice types
343
+ - **Tax Objects** (c_ObjetoImp): Tax object codes
344
+ - **Export Types** (c_Exportacion): Export classifications
345
+ - **Relationship Types** (c_TipoRelacion): Document relationships
346
+ - **Tax Factors** (c_TipoFactor): Rate/quota/exemption
347
+ - **Rates and Quotas** (c_TasaOCuota): Applicable tax rates
348
+ - **Months** (c_Meses): Month codes
349
+ - **Periodicity** (c_Periodicidad): Payment periods
350
+
351
+ #### Comercio Exterior 2.0 (Foreign Trade) - 8 Catalogs
352
+ - **Incoterms**: 11 international commercial terms (ICC 2020)
353
+ - **Countries** (c_Pais): 250+ countries with ISO 3166-1 codes
354
+ - **Currencies** (c_Moneda): 180+ currencies with ISO 4217 codes
355
+ - **Customs Declarations** (c_ClavePedimento): 40+ customs procedure codes
356
+ - **Customs Units** (c_UnidadAduana): 30+ measurement units for customs
357
+ - **Transfer Motives** (c_MotivoTraslado): Transfer reasons for type T documents
358
+ - **Tax ID Types** (c_RegistroIdentTrib): Foreign tax identification types
359
+ - **USA/Canada States**: US states and Canadian provinces
360
+
361
+ #### Carta Porte 3.0 (Transportation Waybill) - 7 Catalogs
362
+ - **Airports** (c_CodigoTransporteAereo): Mexican and international airports
363
+ - **Seaports** (c_NumAutorizacionNaviero): Maritime ports
364
+ - **Federal Highways** (c_Carreteras): Federal highway network
365
+ - **Dangerous Materials** (c_MaterialPeligroso): UN hazardous materials codes
366
+ - **Packaging Types** (c_TipoEmbalaje): Packaging classifications
367
+ - **Transport Permits** (c_TipoPermiso): Transport authorization types
368
+ - **Vehicle Configurations** (c_ConfigAutotransporte): Truck configurations
369
+
370
+ #### Nómina 1.2 (Payroll) - 7 Catalogs
371
+ - **Banks** (c_Banco): Banking institutions for payroll
372
+ - **Payment Periodicity** (c_PeriodicidadPago): Payment frequencies
373
+ - **Job Risk Levels** (c_RiesgoPuesto): IMSS risk classifications
374
+ - **Contract Types** (c_TipoContrato): Employment contract types
375
+ - **Work Shifts** (c_TipoJornada): Shift types (day, night, mixed)
376
+ - **Payroll Types** (c_TipoNomina): Ordinary and extraordinary
377
+ - **Regime Types** (c_TipoRegimen): Social security regimes
378
+
379
+ ### INEGI (National Statistics Institute) - 4 Catalogs
380
+
381
+ - **Municipalities** (Municipios): 2,478 municipalities with population data (Census 2020)
382
+ - **Localities** (Localidades): 10,635 localities (1,000+ inhabitants) with GPS coordinates
383
+ - **States** (Estados): 32 Mexican states with INEGI codes
384
+ - **Geographic Search**: Coordinate-based locality search with radius filtering
385
+
386
+ ### SEPOMEX (Mexican Postal Service) - 2 Catalogs
387
+
388
+ - **Postal Codes** (Códigos Postales): 157,252 postal codes with complete address data
389
+ - **Postal Code Database**: SQLite version for high-performance queries
390
+
391
+ ### Banxico (Bank of Mexico) - 5 Catalogs
392
+
393
+ - **Banks** (Instituciones Bancarias): 110 financial institutions
394
+ - **SPEI Participants**: Electronic payment system directory
395
+ - **Plaza Codes** (Códigos de Plaza): 463 geographic banking codes
396
+ - **Financial Institutions** (Instituciones Financieras): 20+ institution types with regulators
397
+ - **Currencies** (Monedas y Divisas): International currencies with exchange rate indicators
398
+ - **UDI Values** (Unidades de Inversión): Historical UDI values (1995-2025)
399
+
400
+ ### IFT (Telecommunications Institute) - 2 Catalogs
401
+
402
+ - **Mobile Operators** (Operadores Móviles): Licensed telecommunications operators
403
+
404
+ ### Mexico National - 4 Catalogs
405
+
406
+ - **Minimum Wages** (Salarios Mínimos): Historical minimum wage data (2010-2025)
407
+ - **UMA** (Unidad de Medida y Actualización): Reference values (2017-2025)
408
+ - **Hoy No Circula**: Mexico City traffic restrictions with exemptions
409
+ - **License Plate Formats**: Official vehicle plate formats by state
410
+
411
+ ---
412
+
413
+ ## Technical Specifications
414
+
415
+ ### Architecture
416
+
417
+ - **Hybrid Storage**: JSON for small catalogs, SQLite with FTS5 for large datasets (>10K records)
418
+ - **Lazy Loading**: Catalogs loaded on-demand to minimize memory footprint
419
+ - **Type Safety**: Complete type hints (Python) and TypeScript declarations
420
+ - **Zero External Dependencies**: Validators are standalone (only unidecode for RFC/CURP generation)
421
+ - **Cross-Platform**: Works on Linux, macOS, Windows, and web browsers
422
+
423
+ ### Performance
424
+
425
+ - **Package Size**: 108KB (Python wheel), minimal footprint
426
+ - **Memory Efficient**: Lazy loading prevents unnecessary data loading
427
+ - **Fast Queries**: SQLite with FTS5 for full-text search in large catalogs
428
+ - **Search Performance**: <10ms for indexed queries on SQLite catalogs
429
+
430
+ ### Quality Assurance
431
+
432
+ - **Test Coverage**: 93.78% (926 Python tests + 221 TypeScript tests)
433
+ - **50+ Modules**: 100% test coverage
434
+ - **CI/CD**: Automated testing on Python 3.10-3.13 and Node 18+
435
+ - **Production Validated**: Used in production environments
436
+
437
+ ---
438
+
439
+ ## Use Cases
440
+
441
+ ### Financial Technology (Fintech)
442
+
443
+ **Customer Onboarding (KYC)**
444
+ ```python
445
+ from catalogmx.validators import rfc, curp, nss
446
+
447
+ # Validate customer identification
448
+ rfc_valid = rfc.validate_rfc(customer_rfc)
449
+ curp_valid = curp.validate_curp(customer_curp)
450
+ nss_valid = nss.validate_nss(customer_nss)
451
+
452
+ if all([rfc_valid, curp_valid, nss_valid]):
453
+ # Proceed with onboarding
454
+ pass
455
+ ```
456
+
457
+ **SPEI Transfers**
458
+ ```python
459
+ from catalogmx.validators import clabe
460
+ from catalogmx.catalogs.banxico import BankCatalog
461
+
462
+ # Validate beneficiary account
463
+ if clabe.validate_clabe(beneficiary_clabe):
464
+ clabe_info = clabe.get_clabe_info(beneficiary_clabe)
465
+ bank = BankCatalog.get_bank_by_code(clabe_info['bank_code'])
466
+
467
+ if bank['spei']:
468
+ # Process SPEI transfer
469
+ pass
470
+ ```
471
+
472
+ ### E-Commerce & Marketplaces
473
+
474
+ **Address Validation**
475
+ ```python
476
+ from catalogmx.catalogs.sepomex import CodigosPostales
477
+ from catalogmx.catalogs.inegi import MunicipiosCatalog
478
+
479
+ # Validate shipping address
480
+ postal_data = CodigosPostales.get_by_cp(shipping_postal_code)
481
+
482
+ if postal_data:
483
+ verified_state = postal_data[0]['estado']
484
+ verified_municipality = postal_data[0]['municipio']
485
+
486
+ # Calculate shipping costs by zone
487
+ pass
488
+ ```
489
+
490
+ ### Tax Compliance & Accounting
491
+
492
+ **CFDI Generation**
493
+ ```python
494
+ from catalogmx.catalogs.sat.cfdi_4 import (
495
+ RegimenFiscalCatalog,
496
+ UsoCFDICatalog,
497
+ FormaPagoCatalog
498
+ )
499
+
500
+ # Validate tax regime
501
+ regimen = RegimenFiscalCatalog.get_regimen_fiscal(customer_regimen)
502
+ if regimen and RegimenFiscalCatalog.is_valid_for_persona_fisica(customer_regimen):
503
+ # Generate CFDI
504
+ pass
505
+
506
+ # Validate CFDI use
507
+ uso_valid = UsoCFDICatalog.is_valid(cfdi_use_code)
508
+ ```
509
+
510
+ ### Logistics & International Trade
511
+
512
+ **Customs Documentation**
513
+ ```python
514
+ from catalogmx.catalogs.sat.comercio_exterior import (
515
+ IncotermsValidator,
516
+ PaisCatalog,
517
+ MonedaCatalog
518
+ )
519
+
520
+ # Validate international shipment
521
+ incoterm_valid = IncotermsValidator.is_valid("CIF")
522
+ country_valid = PaisCatalog.is_valid("USA")
523
+ currency_valid = MonedaCatalog.is_valid("USD")
524
+
525
+ # Validate currency conversion
526
+ conversion_result = MonedaCatalog.validate_conversion_usd({
527
+ "moneda": "MXN",
528
+ "total": 20000,
529
+ "tipo_cambio_usd": 20.0,
530
+ "total_usd": 1000
531
+ })
532
+ ```
533
+
534
+ ---
535
+
536
+ ## API Documentation
537
+
538
+ ### Validators Module
539
+
540
+ #### RFC Validator
541
+
542
+ **Methods:**
543
+ - `validate_rfc(rfc: str, check_checksum: bool = True) -> bool`
544
+ - `generate_rfc_persona_fisica(nombre, apellido_paterno, apellido_materno, fecha_nacimiento) -> str`
545
+ - `generate_rfc_persona_moral(razon_social, fecha_constitucion) -> str`
546
+ - `detect_rfc_type(rfc: str) -> str | None`
547
+ - `is_valid_rfc(rfc: str) -> bool` (alias)
548
+
549
+ #### CURP Validator
550
+
551
+ **Methods:**
552
+ - `validate_curp(curp: str, check_digit: bool = True) -> bool`
553
+ - `generate_curp(nombre, apellido_paterno, apellido_materno, fecha_nacimiento, sexo, estado) -> str`
554
+ - `get_curp_info(curp: str) -> dict | None`
555
+ - `is_valid_curp(curp: str) -> bool` (alias)
556
+
557
+ #### CLABE Validator
558
+
559
+ **Methods:**
560
+ - `validate_clabe(clabe: str) -> bool`
561
+ - `generate_clabe(bank_code, branch_code, account_number) -> str`
562
+ - `get_clabe_info(clabe: str) -> dict | None`
563
+
564
+ #### NSS Validator
565
+
566
+ **Methods:**
567
+ - `validate_nss(nss: str) -> bool`
568
+ - `generate_nss(subdelegation, year, serial, sequential) -> str`
569
+ - `get_nss_info(nss: str) -> dict | None`
570
+
571
+ ### Catalogs Module
572
+
573
+ All catalogs follow a consistent API pattern:
574
+
575
+ ```python
576
+ # Standard catalog methods
577
+ catalog.get_all() -> list[dict] # Get all records
578
+ catalog.get_by_code(code: str) -> dict | None # Get by code/ID
579
+ catalog.is_valid(code: str) -> bool # Validate code exists
580
+ catalog.search(query: str) -> list[dict] # Search (if applicable)
581
+ ```
582
+
583
+ **Example:**
584
+ ```python
585
+ from catalogmx.catalogs.sat.cfdi_4 import RegimenFiscalCatalog
586
+
587
+ # Get all regimes
588
+ regimenes = RegimenFiscalCatalog.get_all()
589
+
590
+ # Get specific regime
591
+ regimen = RegimenFiscalCatalog.get_regimen_fiscal("605")
592
+
593
+ # Validate regime exists
594
+ is_valid = RegimenFiscalCatalog.is_valid("605")
595
+
596
+ # Check if valid for person type
597
+ valid_for_fisica = RegimenFiscalCatalog.is_valid_for_persona_fisica("605")
598
+ ```
599
+
600
+ ---
601
+
602
+ ## Production Deployment
603
+
604
+ ### System Requirements
605
+
606
+ **Python:**
607
+ - Python 3.10 or higher
608
+ - 200MB disk space (with all catalogs)
609
+ - Minimal memory footprint (lazy loading)
610
+
611
+ **TypeScript/Node.js:**
612
+ - Node.js 18 or higher
613
+ - npm 7 or higher
614
+
615
+ **Dart/Flutter:**
616
+ - Dart SDK 3.0 or higher
617
+ - Flutter 3.10 or higher (for Flutter apps)
618
+ - Works on iOS, Android, Web, macOS, Windows, Linux
619
+
620
+ ### Dependencies
621
+
622
+ **Python Runtime:**
623
+ - `unidecode>=1.4.0` (RFC/CURP accent handling)
624
+ - `click>=8.0.0` (CLI interface)
625
+
626
+ **Python Development:**
627
+ - `pytest>=7.4.0` (testing)
628
+ - `pytest-cov>=4.1.0` (coverage)
629
+ - `black>=23.0.0` (formatting)
630
+ - `ruff>=0.1.0` (linting)
631
+
632
+ **TypeScript:**
633
+ - `better-sqlite3` (SQLite access)
634
+ - `sql.js` (WebAssembly SQLite)
635
+
636
+ ### Performance Characteristics
637
+
638
+ | Operation | Performance | Notes |
639
+ |-----------|-------------|-------|
640
+ | RFC validation | <1ms | No external dependencies |
641
+ | CURP validation | <1ms | Complete algorithm |
642
+ | CLABE validation | <1ms | Modulo 10 check |
643
+ | Postal code lookup | <5ms | JSON (O(1) with index) |
644
+ | Geographic search | <10ms | SQLite with spatial index |
645
+ | Full-text search | <20ms | SQLite FTS5 |
646
+
647
+ ### Scalability
648
+
649
+ - **Concurrent Requests**: Thread-safe, suitable for multi-threaded applications
650
+ - **Caching**: Catalogs loaded once per process
651
+ - **Memory Usage**: ~50-100MB with all catalogs loaded
652
+ - **Database Connections**: SQLite connection pooling supported
653
+
654
+ ---
655
+
656
+ ## Integration Examples
657
+
658
+ ### FastAPI REST API
659
+
660
+ ```python
661
+ from fastapi import FastAPI, HTTPException
662
+ from catalogmx.validators import rfc
663
+ from catalogmx.catalogs.sepomex import CodigosPostales
664
+
665
+ app = FastAPI(title="catalogmx API")
666
+
667
+ @app.get("/validate/rfc/{rfc_code}")
668
+ async def validate_rfc_endpoint(rfc_code: str):
669
+ is_valid = rfc.validate_rfc(rfc_code)
670
+ return {
671
+ "rfc": rfc_code,
672
+ "valid": is_valid,
673
+ "type": rfc.detect_rfc_type(rfc_code) if is_valid else None
674
+ }
675
+
676
+ @app.get("/postal-codes/{cp}")
677
+ async def get_postal_code(cp: str):
678
+ data = CodigosPostales.get_by_cp(cp)
679
+ if not data:
680
+ raise HTTPException(status_code=404, detail="Postal code not found")
681
+ return data
682
+ ```
683
+
684
+ ### Express.js (Node.js)
685
+
686
+ ```typescript
687
+ import express from 'express';
688
+ import { validateRFC, validateCURP } from 'catalogmx';
689
+
690
+ const app = express();
691
+
692
+ app.get('/validate/rfc/:rfc', (req, res) => {
693
+ const isValid = validateRFC(req.params.rfc);
694
+ res.json({ rfc: req.params.rfc, valid: isValid });
695
+ });
696
+
697
+ app.listen(3000);
698
+ ```
699
+
700
+ ### Flutter/Dart
701
+
702
+ ```dart
703
+ import 'package:catalogmx/catalogmx.dart';
704
+
705
+ // Validate RFC
706
+ final isValidRfc = validateRFC('GODE561231GR8');
707
+
708
+ // Generate RFC for individual
709
+ final rfc = generateRFC(
710
+ nombre: 'Juan',
711
+ apellidoPaterno: 'Garcia',
712
+ apellidoMaterno: 'Lopez',
713
+ fechaNacimiento: DateTime(1990, 5, 15),
714
+ );
715
+
716
+ // Validate CURP
717
+ final isValidCurp = validateCURP('GORS561231HVZNNL00');
718
+
719
+ // Generate CURP
720
+ final curp = generateCURP(
721
+ nombre: 'Juan',
722
+ apellidoPaterno: 'Garcia',
723
+ apellidoMaterno: 'Lopez',
724
+ fechaNacimiento: DateTime(1990, 5, 15),
725
+ sexo: 'H',
726
+ estado: 'Jalisco',
727
+ );
728
+
729
+ // Validate bank account (CLABE)
730
+ final isValidClabe = validateCLABE('002010077777777771');
731
+
732
+ // Access catalogs
733
+ final states = InegStates.getAll();
734
+ final cdmx = InegStates.getByCode('DF');
735
+ final municipalities = InegMunicipios.getByState('09');
736
+ final postalData = SepomexCodigosPostales.getByCP('06600');
737
+ ```
738
+
739
+ ### Django
740
+
741
+ ```python
742
+ from django.http import JsonResponse
743
+ from catalogmx.validators import rfc
744
+
745
+ def validate_rfc_view(request, rfc_code):
746
+ is_valid = rfc.validate_rfc(rfc_code)
747
+ return JsonResponse({
748
+ 'rfc': rfc_code,
749
+ 'valid': is_valid
750
+ })
751
+ ```
752
+
753
+ ---
754
+
755
+ ## Testing & Quality Assurance
756
+
757
+ ### Test Coverage
758
+
759
+ - **Overall Coverage**: 93.78% (Python), ~90% (TypeScript), ~85% (Dart)
760
+ - **Total Tests**: 926 (Python) + 221 (TypeScript) + 59 (Dart) = 1,206
761
+ - **Modules at 100%**: 50+ modules including all core validators
762
+ - **CI/CD**: Automated testing on Python 3.10-3.13, Node.js 18+, and Dart stable/beta
763
+
764
+ ### Running Tests
765
+
766
+ ```bash
767
+ # Python tests
768
+ cd packages/python
769
+ pytest tests/ --cov=catalogmx --cov-report=html
770
+
771
+ # TypeScript tests
772
+ cd packages/typescript
773
+ npm test
774
+
775
+ # Dart tests
776
+ cd packages/dart
777
+ dart test
778
+
779
+ # View coverage report
780
+ open packages/python/htmlcov/index.html
781
+ ```
782
+
783
+ ### Quality Metrics
784
+
785
+ - **Test Success Rate**: 100% (1,206 tests across all platforms)
786
+ - **Code Quality**: Python (Black + Ruff), TypeScript (ESLint + Prettier), Dart (dart analyze + format)
787
+ - **Type Safety**: Full mypy compliance (Python), TypeScript strict mode, Dart null-safety
788
+ - **Documentation**: Comprehensive inline and external docs
789
+
790
+ ---
791
+
792
+ ## Documentation
793
+
794
+ ### Quick Reference
795
+ - **[Installation Guide](docs/installation.rst)** - Detailed setup instructions
796
+ - **[Quick Start Guide](docs/quickstart.rst)** - Get started in 5 minutes
797
+ - **[API Reference](docs/api/)** - Complete API documentation
798
+ - **[Testing Guide](docs/testing-coverage.md)** - Test suite and coverage
799
+ - **[Modern Packaging](docs/modern-packaging.md)** - Using uv and pyproject.toml
800
+ - **[Documentation Index](docs/DOCUMENTATION_INDEX.md)** - Complete documentation hub
801
+
802
+ ### For Developers
803
+ - **[Developer Guide](docs/guides/developers-guide.md)** - Contributing guidelines
804
+ - **[Architecture](docs/guides/architecture.md)** - System design
805
+ - **[AI Agent Rules](CLAUDE.md)** - Guidelines for AI assistants
806
+
807
+ ### External Resources
808
+ - **PyPI**: https://pypi.org/project/catalogmx/
809
+ - **npm**: https://www.npmjs.com/package/catalogmx
810
+ - **pub.dev**: https://pub.dev/packages/catalogmx
811
+ - **GitHub**: https://github.com/openbancor/catalogmx
812
+ - **Issues**: https://github.com/openbancor/catalogmx/issues
813
+
814
+ ---
815
+
816
+ ## Roadmap
817
+
818
+ ### Current Version: 0.3.0 (Production Ready)
819
+
820
+ **Delivered:**
821
+ - 58 official catalogs with 470K+ records
822
+ - 4 production validators (RFC, CURP, CLABE, NSS)
823
+ - Multi-platform: Python 3.10+, TypeScript 5.0+, Dart/Flutter 3.0+
824
+ - 93.78% test coverage (1,206 tests)
825
+ - SQLite hybrid architecture with lazy loading
826
+ - Comprehensive publishing infrastructure (PyPI, NPM, pub.dev)
827
+ - CI/CD automation with GitHub Actions
828
+
829
+ ### Version 0.5.0 (Q1 2025) - Enhancement
830
+
831
+ **Planned:**
832
+ - Complete SEPOMEX SQLite migration
833
+ - Postal code geocoding (lat/lon for all 157K codes)
834
+ - CP ↔ Locality linkage table
835
+ - Additional SAT catalogs
836
+ - Enhanced Flutter widgets for validation
837
+ - WebAssembly support for browser performance
838
+
839
+ ### Version 0.6.0 (Q2-Q3 2025) - Expansion
840
+
841
+ **Planned:**
842
+ - New validators (vehicle plates, passport MRZ)
843
+ - IMSS catalogs (clinics, sub delegations)
844
+ - TIGIE complete tariff schedule (~10K codes)
845
+ - ML-powered address normalization
846
+ - Historical catalog versions
847
+ - Offline-first mobile support
848
+
849
+ ### See [Product Roadmap](docs/roadmap.md) for detailed planning
850
+
851
+ ---
852
+
853
+ ## Support & Maintenance
854
+
855
+ ### Release Schedule
856
+
857
+ - **Minor Versions** (0.x.0): Quarterly (every 3-4 months)
858
+ - **Patch Versions** (0.3.x): As needed (bug fixes, catalog updates)
859
+ - **Major Versions** (1.0.0): When API is declared stable
860
+
861
+ ### Catalog Updates
862
+
863
+ Government catalogs are updated according to official publication schedules:
864
+
865
+ | Catalog | Update Frequency | Source |
866
+ |---------|-----------------|--------|
867
+ | SEPOMEX | Monthly | Correos de México |
868
+ | INEGI | Annually | INEGI Census |
869
+ | SAT CFDI | Quarterly | SAT Official |
870
+ | Banxico | Quarterly | Banco de México |
871
+
872
+ ### Community Support
873
+
874
+ - **GitHub Issues**: Bug reports and feature requests
875
+ - **Documentation**: Comprehensive guides and API references
876
+ - **Email Support**: luisfernando@informind.com
877
+
878
+ ---
879
+
880
+ ## License
881
+
882
+ BSD 2-Clause License. See [LICENSE](LICENSE) for details.
883
+
884
+ ---
885
+
886
+ ## Credits
887
+
888
+ ### Official Data Sources
889
+
890
+ - **SAT** (Servicio de Administración Tributaria)
891
+ - **INEGI** (Instituto Nacional de Estadística y Geografía)
892
+ - **SEPOMEX** (Servicio Postal Mexicano)
893
+ - **Banxico** (Banco de México)
894
+ - **RENAPO** (Registro Nacional de Población)
895
+ - **IFT** (Instituto Federal de Telecomunicaciones)
896
+
897
+ ### Maintainer
898
+
899
+ **Luis Fernando Barrera**
900
+ - Email: luisfernando@informind.com
901
+ - GitHub: [@openbancor](https://github.com/openbancor)
902
+
903
+ ---
904
+
905
+ **catalogmx v0.3.0** | **Python + TypeScript + Dart** | **1,206 Tests** | **93.78% Coverage** | **Production Ready** | **BSD-2-Clause**