{"id":27217420,"url":"https://github.com/ruslantsykaliak/septa_api","last_synced_at":"2026-04-17T11:31:26.963Z","repository":{"id":286804350,"uuid":"962602328","full_name":"RuslanTsykaliak/SEPTA_API","owner":"RuslanTsykaliak","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-08T12:20:37.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T13:25:17.490Z","etag":null,"topics":["docker","fastapi","mongodb","pyhon3","unicorn"],"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/RuslanTsykaliak.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}},"created_at":"2025-04-08T11:58:53.000Z","updated_at":"2025-04-08T12:22:07.000Z","dependencies_parsed_at":"2025-04-08T13:36:03.187Z","dependency_job_id":null,"html_url":"https://github.com/RuslanTsykaliak/SEPTA_API","commit_stats":null,"previous_names":["ruslantsykaliak/septa_api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RuslanTsykaliak%2FSEPTA_API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RuslanTsykaliak%2FSEPTA_API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RuslanTsykaliak%2FSEPTA_API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RuslanTsykaliak%2FSEPTA_API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RuslanTsykaliak","download_url":"https://codeload.github.com/RuslanTsykaliak/SEPTA_API/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248162601,"owners_count":21057782,"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":["docker","fastapi","mongodb","pyhon3","unicorn"],"created_at":"2025-04-10T05:28:33.374Z","updated_at":"2026-04-17T11:31:26.922Z","avatar_url":"https://github.com/RuslanTsykaliak.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚉 SEPTA Regional Rail Station Finder API\n\nThis project is a FastAPI-based microservice that provides the nearest SEPTA Regional Rail station in **GeoJSON** format based on a given geographic location.\n\n## ✅ Features Implemented\n\n- ✅ Accepts a latitude and longitude as input\n- ✅ Finds the nearest SEPTA Regional Rail station using provided GeoJSON dataset\n- ✅ Returns the result as valid GeoJSON\n- ✅ HTTP API built with FastAPI\n- ✅ Dockerized for container-based deployment\n- ✅ Uses MongoDB Atlas as a hosted cloud database\n- ✅ Designed for cost-effective operation and scalability\n\n## 📂 Project Structure\n\n```\n.\n├── app/\n│   └── main.py                # FastAPI application code\n│\n├── data/\n│   └── doc.geojson            # Source data for SEPTA Regional Rail stations\n│\n├── Dockerfile                 # Container setup for FastAPI\n├── docker-compose.yml         # Service definition for local deployment\n├── requirements.txt           # Python dependencies\n└── README.md                  # Project documentation\n```\n\n## ⚙️ Tech Stack\n\n- Python 3\n- FastAPI\n- Uvicorn\n- MongoDB Atlas\n- Docker \u0026 Docker Compose\n\n\n## 🗂️ Dataset\n\nThe train station data is loaded from a local GeoJSON file:  \n[SEPTA Regional Rail Stations](https://drive.google.com/file/d/11ZfHYz3w77-aM4ZQnQIxSSdxcGnWcFjA/view?usp=drive_link)\n\n## 🧾 Requirements\n\nPython dependencies (in `requirements.txt`):\n\n```\nfastapi\nuvicorn\npymongo[srv]\n```\n\n## 🧼 Clean Code \u0026 Best Practices\n\n- Code is modular and separated by responsibility\n- Uses environment variables for sensitive configuration\n- Dockerized for easy deployment and reproducibility\n\n## 🔒 Security Considerations\n\n- Avoids redundant searches using MongoDB uniqueness constraints\n- MongoDB credentials are kept out of the codebase\n- The project is designed with production isolation in mind\n\n## 💰 Cost Efficiency\n\n- Lightweight FastAPI application\n- Deployed with Docker for resource-efficient hosting\n- Uses a single optimized endpoint to reduce overhead\n\n## 🌍 Global Support\n\n- Accepts any valid lat/lon input\n- Returns GeoJSON, a standardized format supported globally\n\n\n\n# 🧠 Approach \u0026 Design Write-Up\n\n## ✅ **Approach**\n\nThe goal was to build a lightweight, scalable HTTP API that returns the nearest SEPTA Regional Rail station in GeoJSON format, using a provided dataset.\n\n1. **FastAPI** was chosen as the web framework due to its speed, ease of development, and built-in OpenAPI support.\n2. The dataset (`doc.geojson`) was preloaded and parsed at application startup to enable fast access without querying a large database each time.\n3. A **nearest-neighbor search** is performed by calculating geospatial distances between the input coordinates and each station.\n4. MongoDB Atlas was used for cloud database storage, with potential caching or logging use in mind.\n5. The application was containerized with **Docker** to support consistent deployments and future scalability.\n\n---\n\n## ⚠️ **Challenges Faced**\n\n- **GeoJSON Parsing:** Ensuring proper handling of GeoJSON format and consistent return of valid GeoJSON required testing and validation.\n- **Distance Calculations:** Handling accurate distance comparisons (using Haversine formula or geopy) without relying on heavyweight GIS libraries.\n- **Cost Management:** Striving for low resource usage while still allowing future scalability.\n- **Docker Setup:** Structuring the project for clean Docker image builds without hardcoding environment-specific settings.\n\n---\n\n## 🧱 **Design Decisions**\n\n- **Cloud MongoDB Atlas** was selected for flexibility, free tier availability, and the ability to scale later if needed.\n- **Local GeoJSON File Loading** was preferred over storing all records in MongoDB to reduce read costs and minimize API latency.\n- **Docker \u0026 Compose** were used to isolate the service, simplifying future deployment to cloud infrastructure or orchestration platforms like Kubernetes.\n- **No External APIs** were used for directions to ensure offline support and zero reliance on costly third-party services.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruslantsykaliak%2Fsepta_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruslantsykaliak%2Fsepta_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruslantsykaliak%2Fsepta_api/lists"}