{"id":19491316,"url":"https://github.com/faisal-fida/real-time-cyber-attacks","last_synced_at":"2026-05-17T05:34:15.946Z","repository":{"id":216309313,"uuid":"740999176","full_name":"faisal-fida/Real-time-Cyber-Attacks","owner":"faisal-fida","description":"This project is a FastAPI-based web application designed to scrape real-time cyber attack data from an external source, parse the data, and store it in a database using Tortoise ORM.","archived":false,"fork":false,"pushed_at":"2024-10-06T07:43:25.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-25T19:44:20.602Z","etag":null,"topics":["cyberattacks","fastapi","realtime","requests","tortoise-orm","webapp"],"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/faisal-fida.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":"2024-01-09T13:50:33.000Z","updated_at":"2024-10-06T07:44:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"96503df0-60e0-41a6-b3dc-4680ba246d37","html_url":"https://github.com/faisal-fida/Real-time-Cyber-Attacks","commit_stats":null,"previous_names":["faisal-fida/real-time-cyber-attacks-fastapi-db","faisal-fida/real-time-cyber-attacks"],"tags_count":0,"template":false,"template_full_name":"github/codespaces-blank","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faisal-fida%2FReal-time-Cyber-Attacks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faisal-fida%2FReal-time-Cyber-Attacks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faisal-fida%2FReal-time-Cyber-Attacks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faisal-fida%2FReal-time-Cyber-Attacks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/faisal-fida","download_url":"https://codeload.github.com/faisal-fida/Real-time-Cyber-Attacks/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240738091,"owners_count":19849546,"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":["cyberattacks","fastapi","realtime","requests","tortoise-orm","webapp"],"created_at":"2024-11-10T21:16:30.152Z","updated_at":"2026-05-17T05:34:15.914Z","avatar_url":"https://github.com/faisal-fida.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Real-time Cyber Attacks FastAPI DB\n\nThis project is a FastAPI-based web application designed to scrape real-time cyber attack data from an external source, parse the data, and store it in a database using Tortoise ORM.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Complexities](#complexities)\n- [Solutions](#solutions)\n- [Challenges](#challenges)\n- [License](#license)\n\n## Installation\n\n1. Clone the repository:\n\n```sh\ngit clone https://github.com/faisal-fida/Real-time-Cyber-Attacks-FastAPI-DB.git\ncd Real-time-Cyber-Attacks-FastAPI-DB\n```\n\n2. Install the dependencies:\n\n```sh\npip install -r requirements.txt\n```\n\n3. Create a `.env` file with the following content:\n\n```\nDB_URL=\u003cyour_database_url\u003e\n```\n\n4. Run the application:\n\n```sh\nuvicorn main:app --reload\n```\n\n## Usage\n\nThe application provides the following endpoints:\n\n1. `GET /` - Returns the status of the API.\n2. `GET /attacks/{limit}` - Fetches a limited number of real-time cyber attack data and stores it in the database.\n3. `GET /attacks` - Retrieves all stored cyber attack data from the database.\n\n## Features\n\n- **Asynchronous Data Scraping**: The project uses asynchronous programming to efficiently scrape data from an external API. This ensures non-blocking operations and better performance.\n- **Database Integration**: Utilizes Tortoise ORM to interact with the database, including initializing the database and defining data models.\n- **Data Parsing and Validation**: Uses Pydantic models to parse and validate the scraped data before storing it in the database.\n- **Efficient Scraping**: Implemented an asynchronous data scraper using the `httpx` library to handle multiple requests concurrently, reducing the time taken to fetch data.\n- **Database Initialization**: The `init_db` function in `database.py` sets up the database connection and registers the models, ensuring a seamless integration with the FastAPI application.\n- **Data Model Definition**: Defined a `DataModel` class in `models.py` using Tortoise ORM to represent the structure of the data being stored, ensuring data integrity and consistency.\n- **Error Handling**: Managing errors during data scraping, such as handling non-200 HTTP responses and network issues, required robust error handling mechanisms.\n- **Concurrency Management**: Ensuring that multiple asynchronous operations do not lead to race conditions or data corruption was a key challenge.\n- **Data Consistency**: Maintaining data consistency when parsing and storing large volumes of real-time data required careful design and validation.\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaisal-fida%2Freal-time-cyber-attacks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffaisal-fida%2Freal-time-cyber-attacks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaisal-fida%2Freal-time-cyber-attacks/lists"}