{"id":50414703,"url":"https://github.com/protonspy/nfe-parser-gemma3n","last_synced_at":"2026-05-31T05:03:34.514Z","repository":{"id":306117597,"uuid":"1024525034","full_name":"protonspy/nfe-parser-gemma3n","owner":"protonspy","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-24T05:12:47.000Z","size":158,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-18T17:16:18.348Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/protonspy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-22T20:53:00.000Z","updated_at":"2025-07-24T05:12:50.000Z","dependencies_parsed_at":"2025-07-23T20:12:44.683Z","dependency_job_id":"b911ccd5-beb8-47b3-a5fb-d1908005d9a6","html_url":"https://github.com/protonspy/nfe-parser-gemma3n","commit_stats":null,"previous_names":["prodesk98/nfe-parser-gemma3n","protonspy/nfe-parser-gemma3n"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/protonspy/nfe-parser-gemma3n","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protonspy%2Fnfe-parser-gemma3n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protonspy%2Fnfe-parser-gemma3n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protonspy%2Fnfe-parser-gemma3n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protonspy%2Fnfe-parser-gemma3n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/protonspy","download_url":"https://codeload.github.com/protonspy/nfe-parser-gemma3n/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protonspy%2Fnfe-parser-gemma3n/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33719601,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-31T02:00:06.040Z","response_time":95,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-05-31T05:03:34.449Z","updated_at":"2026-05-31T05:03:34.505Z","avatar_url":"https://github.com/protonspy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NF-e Parser using Gemma3n\n\nA FastAPI application for parsing Brazilian electronic invoices (NF-e - Nota Fiscal Eletrônica) from images using the Gemma3n language model.\n\n## Description\n\nThis project provides an API that extracts structured data from NF-e document images. It uses the Ollama API with the Gemma3n model to perform optical character recognition (OCR) and structured data extraction, converting the visual information from NF-e documents into a well-defined JSON format.\n\n## Features\n\n- Extract comprehensive NF-e data from images\n- Structured output with detailed invoice information\n- REST API with FastAPI\n- Docker containerization for easy deployment\n- GPU acceleration support\n\n## Requirements\n\n- Python 3.12 or higher\n- Docker and Docker Compose (for containerized deployment)\n- NVIDIA GPU (optional, for improved performance)\n\n## Installation\n\n### Using Docker (Recommended)\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/yourusername/nfe-parser-gemma3n.git\n   cd nfe-parser-gemma3n\n   ```\n\n2. Create a `.env` file from the template:\n   ```bash\n   cp template.env .env\n   ```\n\n3. Edit the `.env` file with your configuration:\n   ```\n   OLLAMA_API_URL=http://ollama:11434\n   OLLAMA_API_KEY=your-ollama-api-key (if required)\n   OLLAMA_MODEL=gemma3n:e4b\n   ```\n\n4. Start the application with Docker Compose:\n   ```bash\n   docker-compose up -d\n   ```\n\n### Manual Installation\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/yourusername/nfe-parser-gemma3n.git\n   cd nfe-parser-gemma3n\n   ```\n\n2. Create a virtual environment and install dependencies:\n   ```bash\n   python -m venv .venv\n   .venv\\Scripts\\activate  # On Windows\n   # OR\n   source .venv/bin/activate  # On Unix/macOS\n   \n   pip install uv\n   uv pip install -e .\n   ```\n\n3. Create a `.env` file from the template:\n   ```bash\n   cp template.env .env\n   ```\n\n4. Edit the `.env` file with your configuration:\n   ```\n   OLLAMA_API_URL=http://localhost:11434\n   OLLAMA_API_KEY=your-ollama-api-key (if required)\n   OLLAMA_MODEL=gemma3n:e4b\n   ```\n\n5. Start the application:\n   ```bash\n   fastapi dev main.py\n   ```\n\n## Usage\n\n### API Endpoint\n\nThe API provides a single endpoint for parsing NF-e images:\n\n- **POST /parse**\n  - Accepts a multipart/form-data request with an image file\n  - Returns the structured NF-e data in JSON format\n\n### Example Request\n\nUsing curl:\n\n```bash\ncurl -X POST \"http://localhost:8000/parse\" \\\n  -H \"accept: application/json\" \\\n  -H \"Content-Type: multipart/form-data\" \\\n  -F \"image=@path/to/your/nfe-image.jpg\"\n```\n\nUsing Python requests:\n\n```python\nimport requests\n\nurl = \"http://localhost:8000/parse\"\nfiles = {\"image\": open(\"path/to/your/nfe-image.jpg\", \"rb\")}\n\nresponse = requests.post(url, files=files)\nnfe_data = response.json()\nprint(nfe_data)\n```\n\n### Response Structure\n\nThe API returns a structured JSON object containing the parsed NF-e data, including:\n\n- Invoice identification details\n- Issuer information\n- Recipient information\n- Product details with tax information\n- Invoice totals\n- Transportation information\n- Billing and payment details\n- Additional information\n\n## Configuration\n\nThe application can be configured using environment variables:\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| OLLAMA_API_URL | URL of the Ollama API | http://localhost:11434 |\n| OLLAMA_API_KEY | API key for Ollama (if required) | None |\n| OLLAMA_MODEL | Ollama model to use | gemma3n:e4b |\n\n## Project Structure\n\n- `main.py` - FastAPI application entry point\n- `core.py` - Core functionality for parsing NF-e images\n- `schemas.py` - Pydantic models defining the NF-e data structure\n- `environment.py` - Environment configuration\n- `Dockerfile` - Container definition\n- `docker-compose.yaml` - Multi-container Docker configuration\n\n## Dependencies\n\n- FastAPI - Web framework for building APIs\n- langchain-ollama - Interface to Ollama language models\n- Pillow - Image processing library\n- Pydantic - Data validation and settings management\n- python-dotenv - Environment variable management\n\n## License\n\n[CC0-1.0 license](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprotonspy%2Fnfe-parser-gemma3n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprotonspy%2Fnfe-parser-gemma3n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprotonspy%2Fnfe-parser-gemma3n/lists"}