{"id":28324508,"url":"https://github.com/lscasas/direcmex","last_synced_at":"2026-05-08T03:37:36.036Z","repository":{"id":281975068,"uuid":"940715804","full_name":"LSCasas/DirecMex","owner":"LSCasas","description":"DirecMex is a Flask and PostgreSQL web app demo to search location details by ZIP code.","archived":false,"fork":false,"pushed_at":"2025-05-04T04:18:13.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-02T03:25:15.561Z","etag":null,"topics":["flask","postgresql","psycopg2"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LSCasas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2025-02-28T16:59:36.000Z","updated_at":"2025-05-04T04:21:39.000Z","dependencies_parsed_at":"2025-03-12T06:22:44.095Z","dependency_job_id":"09e91266-42a9-4b3c-9933-9a9687e8b57d","html_url":"https://github.com/LSCasas/DirecMex","commit_stats":null,"previous_names":["lscasas/domicilio"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LSCasas/DirecMex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LSCasas%2FDirecMex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LSCasas%2FDirecMex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LSCasas%2FDirecMex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LSCasas%2FDirecMex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LSCasas","download_url":"https://codeload.github.com/LSCasas/DirecMex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LSCasas%2FDirecMex/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261591558,"owners_count":23181746,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["flask","postgresql","psycopg2"],"created_at":"2025-05-25T18:10:59.139Z","updated_at":"2026-05-08T03:37:31.009Z","avatar_url":"https://github.com/LSCasas.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DirecMex\n\nDirecMex is a simple web application built with Flask and PostgreSQL that allows users to search for location details (such as neighborhood, city, municipality, and state) by entering a 5-digit ZIP code.\n\n---\n\n## Table of Contents\n\n- [Project Structure](#project-structure)\n- [Features](#features)\n- [Installation](#installation)\n- [Usage](#how-to-use-this-project)\n- [Requirements](#requirements)\n- [Contribution](#contribution)\n- [Learn More](#learn-more)\n\n---\n\n## Project Structure\n\n```\ndirecmex/\n├── src/\n│   ├── app.py              # Flask main application\n│   ├── templates/\n│   │   └── index.html      # HTML frontend form\n├── requirements.txt        # Python dependencies\n└── README.md               # Project documentation\n```\n\n---\n\n## Features\n\n- Simple web form to input ZIP codes.\n- PostgreSQL query to retrieve detailed address info.\n- Data normalized by neighborhood, municipality, city, and state.\n- Lightweight Flask application.\n- Basic error handling for invalid or unregistered ZIP codes.\n\n---\n\n## Installation\n\n1. **Clone the repository:**\n\n   ```bash\n   git clone https://github.com/LSCasas/direcmex.git\n   cd direcmex/src\n   ```\n\n2. **Create a virtual environment (optional but recommended):**\n\n   ```bash\n   python -m venv venv\n   source venv/bin/activate   # On Windows: venv\\Scripts\\activate\n   ```\n\n3. **Install dependencies:**\n\n   ```bash\n   pip install -r ../requirements.txt\n   ```\n\n4. **Run the server:**\n\n   ```bash\n   python app.py\n   ```\n\n---\n\n## How to Use This Project\n\n1. Start the Flask development server.\n2. Open your browser and go to:\n\n```\nhttp://localhost:5000\n```\n\n3. Enter a 5-digit ZIP code in the input field and submit the form.\n4. The system will query the database and return the following information:\n\n- Colonias (neighborhoods)\n- Municipio (municipality)\n- Ciudad (city)\n- Estado (state)\n\n---\n\n## ZIP Code Lookup Example\n\nWhen a valid ZIP code is submitted (e.g., `50000`), the app will perform the following query:\n\n```sql\nSELECT c.descripcion AS colonia, m.descripcion AS municipio,\n       ci.descripcion AS ciudad, e.descripcion AS estado\nFROM cp cp\nJOIN colonias c ON cp.id_colonia = c.id_colonia\nJOIN municipios m ON c.id_municipio = m.id_municipio AND c.id_estado = m.id_estado\nJOIN ciudades ci ON ci.id_municipio = m.id_municipio AND ci.id_estado = m.id_estado\nJOIN estados e ON e.id_estado = m.id_estado\nWHERE cp.cp = %s\n```\n\nIf found, you’ll get results like:\n\n```json\n{\n  \"colonias\": [\"Centro\", \"Del Valle\", \"San Pedro\"],\n  \"municipio\": \"Toluca\",\n  \"ciudad\": \"Toluca de Lerdo\",\n  \"estado\": \"Estado de México\"\n}\n```\n\nIf not found, the system will display:\n\n```\nNo se encontró información para ese C.P.\n```\n\n---\n\n## Requirements\n\n- Python 3.x\n- PostgreSQL\n- Flask == 3.1.0\n- psycopg2-binary == 2.9.10\n\n---\n\n## Contribution\n\nIf you want to contribute to this project:\n\n1. Fork the repository.\n2. Create a new branch:\n\n   ```bash\n   git checkout -b feature/your-feature\n   ```\n\n3. Make your changes and commit:\n\n   ```bash\n   git commit -am 'Add new feature'\n   ```\n\n4. Push to your fork:\n\n   ```bash\n   git push origin feature/your-feature\n   ```\n\n5. Open a Pull Request.\n\n---\n\n## Learn More\n\n- [Flask Documentation](https://flask.palletsprojects.com/) – Web framework used in this project.\n- [PostgreSQL Documentation](https://www.postgresql.org/docs/) – SQL database used for storing location data.\n\nYour feedback and suggestions are always welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flscasas%2Fdirecmex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flscasas%2Fdirecmex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flscasas%2Fdirecmex/lists"}