heoliday commited on
Commit
6f73359
Β·
verified Β·
1 Parent(s): 248ddae

Upload 2 files

Browse files
Files changed (2) hide show
  1. README.md +219 -12
  2. requirements.txt +5 -0
README.md CHANGED
@@ -1,12 +1,219 @@
1
- ---
2
- title: Tin Checker
3
- emoji: πŸ†
4
- colorFrom: pink
5
- colorTo: gray
6
- sdk: gradio
7
- sdk_version: 5.41.1
8
- app_file: app.py
9
- pinned: false
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # πŸ†” TIN Validator - Hugging Face Spaces
2
+
3
+ A Gradio-based web application for validating Philippine Tax Identification Numbers (TIN) with multiple name combination testing.
4
+
5
+ ## 🌟 Features
6
+
7
+ - **Multiple Name Combinations**: Automatically tests various name formatting combinations
8
+ - **Parallel Processing**: Simultaneous validations for faster results
9
+ - **User-Friendly Interface**: Clean Gradio UI with real-time results
10
+ - **Detailed Results**: See which combinations worked and failure reasons
11
+ - **CSV Export**: Download validation results for record keeping
12
+ - **Mobile Responsive**: Works on desktop and mobile devices
13
+
14
+ ## πŸš€ Quick Start
15
+
16
+ ### Deploy to Hugging Face Spaces
17
+
18
+ 1. **Create New Space**:
19
+ - Go to [Hugging Face Spaces](https://huggingface.co/spaces)
20
+ - Click "Create new Space"
21
+ - Choose "Gradio" as the SDK
22
+ - Set visibility (Public/Private)
23
+
24
+ 2. **Upload Files**:
25
+ ```
26
+ your-space/
27
+ β”œβ”€β”€ app.py
28
+ β”œβ”€β”€ requirements.txt
29
+ └── README.md
30
+ ```
31
+
32
+ 3. **Files Content**: Use the provided files in this repository
33
+
34
+ 4. **Space will auto-deploy** once files are uploaded
35
+
36
+ ### Local Development
37
+
38
+ ```bash
39
+ # Clone repository
40
+ git clone <your-repo-url>
41
+ cd tin-validator
42
+
43
+ # Install dependencies
44
+ pip install -r requirements.txt
45
+
46
+ # Run application
47
+ python app.py
48
+ ```
49
+
50
+ ## πŸ“ File Structure
51
+
52
+ ```
53
+ tin-validator/
54
+ β”œβ”€β”€ app.py # Main Gradio application
55
+ β”œβ”€β”€ requirements.txt # Python dependencies
56
+ β”œβ”€β”€ README.md # This documentation
57
+ └── .gitignore # Git ignore file (optional)
58
+ ```
59
+
60
+ ## πŸ”§ Configuration Required
61
+
62
+ ⚠️ **Important**: This is a demonstration version. To make it fully functional, you need to:
63
+
64
+ ### 1. Find the Real API Endpoint
65
+
66
+ The current code uses a placeholder endpoint. You need to:
67
+
68
+ 1. **Inspect Network Traffic**:
69
+ - Open [BIR TIN Validation](https://revie.bir.gov.ph/tin-validation) in browser
70
+ - Open Developer Tools (F12) β†’ Network tab
71
+ - Submit a test form
72
+ - Find the actual API endpoint being called
73
+
74
+ 2. **Update the Endpoint**:
75
+ ```python
76
+ # In app.py, update this line:
77
+ url = "https://revie.bir.gov.ph/api/validate-tin" # Replace with real endpoint
78
+ ```
79
+
80
+ ### 2. Analyze Response Format
81
+
82
+ Update the response parsing logic based on actual API response:
83
+
84
+ ```python
85
+ def validate_tin(self, ...):
86
+ # Update this section based on real API response
87
+ if response.status_code == 200:
88
+ result = response.json() # or response.text if not JSON
89
+ # Parse based on actual response format
90
+ ```
91
+
92
+ ### 3. Handle CSRF/Security Tokens
93
+
94
+ If the site uses CSRF protection:
95
+
96
+ ```python
97
+ def __init__(self):
98
+ # Add session initialization to get CSRF tokens
99
+ self.session = requests.Session()
100
+ # Get initial page to extract tokens
101
+ self.session.get("https://revie.bir.gov.ph/tin-validation")
102
+ ```
103
+
104
+ ## 🎯 Usage
105
+
106
+ 1. **Enter Personal Information**:
107
+ - First Name (required)
108
+ - Middle Name (optional)
109
+ - Last Name (required)
110
+ - TIN ID (9 digits)
111
+ - Birth Date
112
+ - Sex
113
+
114
+ 2. **Configure Settings**:
115
+ - Adjust parallel workers (1-5)
116
+ - Higher numbers = faster but more server load
117
+
118
+ 3. **Click "Validate TIN"** and wait for results
119
+
120
+ 4. **Review Results**:
121
+ - Summary shows success/failure
122
+ - Table shows all combinations tested
123
+ - Download CSV for records
124
+
125
+ ## πŸ” Name Combinations Tested
126
+
127
+ The system automatically tests these name format variations:
128
+
129
+ 1. **Standard**: `First | Middle | Last`
130
+ 2. **Combined**: `First Middle | | Last`
131
+ 3. **No Middle**: `First | | Last`
132
+ 4. **Dotted Middle**: `First | Middle. | Last`
133
+ 5. **Full with Dot**: `First Middle. | | Last`
134
+ 6. **Reversed**: `Last | First | Middle`
135
+ 7. **Rearranged**: `Middle Last | | First`
136
+
137
+ ## πŸ”’ Security & Privacy
138
+
139
+ - **No Data Storage**: Personal information is not stored permanently
140
+ - **Secure Transmission**: HTTPS requests to BIR servers
141
+ - **Local Processing**: Validation logic runs in your browser session
142
+ - **No Logging**: Sensitive data is not logged to files
143
+
144
+ ## πŸ› Troubleshooting
145
+
146
+ ### Common Issues
147
+
148
+ 1. **"Request Error" Messages**:
149
+ - Check internet connection
150
+ - Verify BIR website is accessible
151
+ - API endpoint may need updating
152
+
153
+ 2. **All Validations Fail**:
154
+ - Double-check input data format
155
+ - Verify TIN number is correct
156
+ - Try reducing parallel workers
157
+
158
+ 3. **Slow Performance**:
159
+ - Reduce number of parallel workers
160
+ - Check Hugging Face Spaces resource limits
161
+
162
+ ### Debug Mode
163
+
164
+ For local development, add debug logging:
165
+
166
+ ```python
167
+ import logging
168
+ logging.basicConfig(level=logging.DEBUG)
169
+ ```
170
+
171
+ ## πŸ“Š Hugging Face Spaces Configuration
172
+
173
+ ### Space Settings
174
+
175
+ - **SDK**: Gradio
176
+ - **Python Version**: 3.8+
177
+ - **Hardware**: CPU Basic (sufficient for this app)
178
+ - **Timeout**: Default (should be adequate)
179
+
180
+ ### Environment Variables (if needed)
181
+
182
+ ```bash
183
+ # Add in Space settings if you need custom configuration
184
+ API_BASE_URL=https://revie.bir.gov.ph
185
+ MAX_WORKERS=3
186
+ TIMEOUT_SECONDS=30
187
+ ```
188
+
189
+ ## 🀝 Contributing
190
+
191
+ 1. Fork the repository
192
+ 2. Create feature branch (`git checkout -b feature/amazing-feature`)
193
+ 3. Commit changes (`git commit -m 'Add amazing feature'`)
194
+ 4. Push to branch (`git push origin feature/amazing-feature`)
195
+ 5. Open Pull Request
196
+
197
+ ## πŸ“„ License
198
+
199
+ This project is for educational and demonstration purposes. Ensure compliance with BIR terms of service when using with real data.
200
+
201
+ ## ⚠️ Disclaimer
202
+
203
+ - This tool is for **demonstration purposes**
204
+ - Always verify results through official BIR channels
205
+ - Respect BIR website terms of service and rate limits
206
+ - Keep personal TIN information secure and private
207
+
208
+ ## πŸ“ž Support
209
+
210
+ If you encounter issues:
211
+
212
+ 1. Check this README for troubleshooting
213
+ 2. Review Hugging Face Spaces documentation
214
+ 3. Open an issue in the repository
215
+ 4. Contact the maintainer
216
+
217
+ ---
218
+
219
+ **Made with ❀️ for the Philippine developer community**
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ gradio==4.44.0
2
+ pandas==2.0.3
3
+ requests==2.31.0
4
+ beautifulsoup4==4.12.2
5
+ python-dateutil==2.8.2