├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── assets ├── architecture.png ├── code_interpreter.png ├── erd_diagram.png ├── screenshot-agent.png └── screenshot-trace.png ├── bin └── agentic-text2sql.ts ├── cdk.json ├── jest.config.js ├── lib ├── agent-stack.ts ├── assets │ ├── data │ │ ├── accounts │ │ │ └── accounts.csv │ │ ├── bank_branches │ │ │ └── bank_branches.csv │ │ ├── card_transactions │ │ │ └── card_transactions.csv │ │ ├── cards │ │ │ └── cards.csv │ │ ├── customers │ │ │ └── customers.csv │ │ ├── devices │ │ │ └── devices.csv │ │ ├── fraud_alerts │ │ │ └── fraud_alerts.csv │ │ ├── locations │ │ │ └── locations.csv │ │ ├── merchants │ │ │ └── merchants.csv │ │ ├── rules_engine │ │ │ └── rules_engine.csv │ │ ├── suspicious_patterns │ │ │ └── suspicious_patterns.csv │ │ ├── transaction_history │ │ │ └── transaction_history.csv │ │ └── transactions │ │ │ └── transactions.csv │ └── tables.json └── db-stack.ts ├── package-lock.json ├── package.json ├── prompt └── instruction.txt ├── src ├── athena_query │ ├── __init__.py │ ├── athena_query.py │ └── openapi.json ├── athena_schema_reader │ ├── __init__.py │ ├── athena_schema_reader.py │ └── openapi.json ├── common │ ├── __init__.py │ └── python │ │ ├── __init__.py │ │ ├── athena_utils.py │ │ ├── error_utils.py │ │ ├── request_utils.py │ │ └── response_utils.py └── layers │ ├── aws_lambda_powertools │ └── requirements.txt │ └── pydantic │ └── requirements.txt ├── test └── agentic-text2sql.test.ts └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.d.ts 3 | *.js 4 | cdk.out -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/sample-Dynamic-Text-to-SQL-with-Amazon-Bedrock-Agent/22e4713ac5c7d08923704190d062abcddea506b9/CHANGELOG.md -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | 10 | ## Reporting Bugs/Feature Requests 11 | 12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 13 | 14 | When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already 15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 16 | 17 | * A reproducible test case or series of steps 18 | * The version of our code being used 19 | * Any modifications you've made relevant to the bug 20 | * Anything unusual about your environment or deployment 21 | 22 | 23 | ## Contributing via Pull Requests 24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 25 | 26 | 1. You are working against the latest source on the *main* branch. 27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 29 | 30 | To send us a pull request, please: 31 | 32 | 1. Fork the repository. 33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 34 | 3. Ensure local tests pass. 35 | 4. Commit to your fork using clear commit messages. 36 | 5. Send us a pull request, answering any default questions in the pull request interface. 37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 38 | 39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 41 | 42 | 43 | ## Finding contributions to work on 44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start. 45 | 46 | 47 | ## Code of Conduct 48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 50 | opensource-codeofconduct@amazon.com with any additional questions or comments. 51 | 52 | 53 | ## Security issue notifications 54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 55 | 56 | 57 | ## Licensing 58 | 59 | See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT No Attribution 2 | 3 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 13 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 14 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 15 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 16 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 | 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dynamic Text-to-SQL for Enterprise Workloads with Amazon Bedrock Agent 2 | 3 | Elevate your data analysis with an end-to-end agentic Text-to-SQL solution, built on AWS for enterprise-scale adaptability and resilience. Ideal for complex scenarios like fraud detection in financial services. 4 | 5 | 🚀 Key Differentiators: 6 | 7 | 1. **Fully Agentic Process**: Leveraging Amazon Bedrock, the AI agent manages the entire workflow from question to insight. 8 | 2. **Dynamic Schema Discovery**: Adapts to evolving database structures in Amazon Athena in real-time. 9 | 3. **Intelligent Error Handling**: Autonomous troubleshooting and query refinement using AWS Lambda. 10 | 11 | This solution goes beyond basic Text-to-SQL, offering a robust, self-adapting system for complex enterprise environments. 12 | 13 | Visit AWS Machine Learning Blog - [Dynamic text-to-SQL for enterprise workloads with Amazon Bedrock Agents](https://aws.amazon.com/blogs/machine-learning/dynamic-text-to-sql-for-enterprise-workloads-with-amazon-bedrock-agents/) to learn more about this solution. 14 | 15 | ## Sample Database Overview 16 | 17 | This example demonstrates a fraud detection database schema commonly used in financial institutions. The schema represents core tables needed for transaction monitoring and fraud investigation. 18 | 19 | ### Use Case: Fraud Investigation 20 | 21 | Business analysts can query complex transaction patterns by asking questions in natural language, such as: 22 | 23 | - "Show fraudulent transactions in the U.S. with device details" 24 | - "List all transactions by John Doe in 2023 with fraud flags and merchant info" 25 | 26 | Without Text2SQL capabilities, these queries would require: 27 | 28 | - Knowledge of multiple table relationships 29 | - Complex JOIN operations 30 | - Understanding of specific column names and data types 31 | 32 | ### Schema Structure 33 | 34 | The following ERD shows the key tables used in fraud detection: 35 | ![ERD diagram](assets/erd_diagram.png) 36 | 37 | > **Note:** This is a simplified version of a typical fraud detection database. Production environments often contain dozens or hundreds of interconnected tables. 38 | 39 | ### Using the Agentic Text2SQL System 40 | 41 | The system provides a natural language interface to your database through Amazon Bedrock Agent. Here's how it works: 42 | 43 | 1. **Schema Discovery** 44 | - Lists available tables in the database 45 | - Provides detailed schema information including column names, data types, and descriptions 46 | - Helps users understand data structure without SQL knowledge 47 | 48 | 2. **Natural Language Query Processing** 49 | - Converts natural language questions into SQL queries 50 | - Executes queries against Amazon Athena 51 | - Returns results in user-friendly format 52 | 53 | 3. **Intelligent Error Handling** 54 | - Analyzes Athena error messages 55 | - Identifies root causes (syntax errors, missing tables, datatype mismatches) 56 | - Suggests and implements query modifications 57 | - Automatically retries corrected queries 58 | 59 | **Note:** Detailed agent instructions can be found in [the sample agent prompt](prompt/instruction.txt). 60 | 61 | **Important:** This system is designed for Amazon Athena which uses AWS Glue Data Catalog for metadata storage. When adapting to other databases: 62 | 63 | - Schema retrieval syntax will differ (e.g., PostgreSQL, MySQL have different commands for accessing column comments) 64 | - Column comments are crucial for the Text2SQL agent's accuracy 65 | - Ensure proper access to metadata in your target database 66 | 67 | ### Agentic Text2SQL Flow 68 | 69 | ![architecture](assets/architecture.png) 70 | 71 | 1. User asks questions to the Amazon Bedrock Agent. 72 | 2. To serve the user's questions, Agent determines the appropriate action to invoke: 73 | 1. to execute the generated query with confidence, Agent will invoke athena-query tool 74 | 2. to confirm the database schema first, it will invoke athena-schema-reader tool 75 | 1. to understand what tables it has access to: /list_tables, 76 | 2. to find out specific schema of a certain table: /describe_table 77 | 3. The Lambda function sends the query to Athena to execute 78 | 4. Athena queries the data from the S3 data bucket, and stores the query results in the S3 output bucket. 79 | 5. The Lambda function retrieves and processes the results. If an error occurs: 80 | - The Lambda function captures and formats the error message for Agent to understand 81 | - The error message is returned to the Amazon Bedrock Agent. 82 | The agent analyzes the error message and tries to resolve. To retry with the modified query, Agent may repeat 2-5. 83 | 6. The agent formats and presents the final responses to the user. 84 | 85 | ## Getting Started 86 | 87 | ### Prerequisites 88 | 89 | - Node.js (>=v20) 90 | - AWS CLI configured with appropriate credentials 91 | - AWS CDK CLI installed (`npm install -g aws-cdk`) (>= 2.1000.2) 92 | - Docker (Alternative: Rancher Desktop) 93 | - Enable the model access to use Claude Sonnet 3.5 from AWS console 94 | 95 | ## AWS Generative AI CDK Constructs 96 | 97 | This project utilizes [AWS Generative AI CDK Constructs](https://github.com/awslabs/generative-ai-cdk-constructs), a collection of AWS CDK constructs for building generative AI applications. These constructs provide high-level components that make it easier to integrate AWS AI/ML services into your infrastructure. 98 | 99 | ### Regional Configuration 100 | 101 | The project is configured to use Amazon Bedrock in the US region by default. If you need to deploy in a different region, modify the `geoRegion` parameter in the cross-region inference profile configuration: 102 | 103 | ```typescript 104 | const anthropicClaudeRegionInferenceProfile = bedrock.CrossRegionInferenceProfile.fromConfig({ 105 | // Change this to your desired region: 106 | // US (default) - bedrock.CrossRegionInferenceProfileRegion.US 107 | // EU - bedrock.CrossRegionInferenceProfileRegion.EU, 108 | // APAC - bedrock.CrossRegionInferenceProfileRegion.APAC 109 | geoRegion: bedrock.CrossRegionInferenceProfileRegion.US, 110 | model: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V2_0 111 | }) 112 | ``` 113 | 114 | Note: Ensure that Amazon Bedrock and the selected model are available in your chosen region. 115 | 116 | ### Repository Structure 117 | 118 | ```filetree 119 | . 120 | ├── bin/ 121 | │ └── Entry point for the CDK application 122 | ├── lib/ 123 | │ ├── agent-stack.ts 124 | │ │ └── Defines the Bedrock Agent and related Lambda functions 125 | │ ├── db-stack.ts 126 | │ │ └── Sets up the Athena database and related S3 buckets 127 | │ └── assets/ 128 | │ └── Sample data CSV files and JSON schema definitions 129 | ├── src/ 130 | │ ├── athena_query/ 131 | │ │ └── Lambda function for executing Athena queries 132 | │ ├── athena_schema_reader/ 133 | │ │ └── Lambda function for reading Athena schema information 134 | │ └── common/ 135 | │ └── Shared utilities and helper functions 136 | └── prompt/ 137 | └── Agent instruction for Text2SQL 138 | ``` 139 | 140 | ### CDK Deployment 141 | 142 | The project is deployed using AWS CDK. The `bin/agentic-text2sql.ts` file is the entry point for the CDK application. It creates two main stacks: 143 | 144 | 1. AthenaStack: Sets up the Athena database, S3 buckets, and Glue tables. 145 | 2. AgentStack: Creates the Bedrock Agent, Lambda functions, and associated resources. 146 | 147 | ### Deployment 148 | 149 | 1. Clone the repository: 150 | 151 | ```bash 152 | git clone https://github.com/aws-samples/sample-Dynamic-Text-to-SQL-with-Amazon-Bedrock-Agent.git 153 | cd sample-Dynamic-Text-to-SQL-with-Amazon-Bedrock-Agent 154 | ``` 155 | 156 | 2. Install dependencies: 157 | 158 | ```bash 159 | npm install 160 | ``` 161 | 162 | 3. Bootstrap your AWS environment (if not already done): 163 | 164 | ```bash 165 | cdk bootstrap aws://ACCOUNT-NUMBER/REGION 166 | ``` 167 | 168 | 4. Deploy the stacks: 169 | 170 | ```bash 171 | cdk deploy --all 172 | ``` 173 | 174 | ## How to Test 175 | 176 | 1. To examine the sample data, go to Athena and run queries, for example: 177 | 178 | ```sql 179 | SELECT * FROM fraud_data.accounts; 180 | ``` 181 | 182 | 2. If you run the DESCRIBE clause, you can see detailed descriptions for each column. Without these descriptions, the Agent will attempt to interpret your database schema independently, and in most cases, it will understand generic terms like transaction_id. However, keep in mind that column comments are used to help the LLM better understand the data. Try to provide descriptions that are as detailed as possible. 183 | 184 | ```sql 185 | DESCRIBE fraud_data.transaction_history 186 | ``` 187 | 188 | 3. Go to [Amazon Bedrock](https://console.aws.amazon.com/bedrock) and select **Agents.** 189 | 190 | 4. Select **AwsText2Sql-AgentStack-DynamicAgent** and test by asking questions in **Test** window on your right. 191 | 192 | Example interactions: 193 | 194 | - What specific methods or techniques are commonly used by perpetrators in the reported fraud cases? 195 | - What patterns or trends can we identify in the timing and location of fraud incidents? 196 | - Show the details of customers who have made transactions with merchants located in Denver 197 | - Provide a list of all merchants along with the total number of transactions they have processed and the number of those transactions that were flagged as fraudulent 198 | - List the top 5 customers based on the highest transaction amounts they have made 199 | 200 | ![agent test](assets/screenshot-agent.png) 201 | 202 | 1. Click Show trace and examine each step to understand what tools are used and the agent's rationale for approaching your question. 203 | 204 | ![agent trace](assets/screenshot-trace.png) 205 | 206 | ### Code Interpreter 207 | 208 | In the context of TEXT2SQL, [Code Interpreter](https://docs.aws.amazon.com/bedrock/latest/userguide/agents-code-interpretation.html) can be particularly useful for: 209 | 210 | - Creating data visualizations from SQL query results 211 | - Performing additional data analysis beyond simple SQL queries 212 | 213 | Example interactions: 214 | 215 | - "Create a bar chart showing the top 3 cities that have the most fraud cases" 216 | 217 | - ![code_interpreter](assets/code_interpreter.png) 218 | 219 | ## Troubleshooting 220 | 221 | - If you encounter unexpected responses in the test window, clear the session history: 222 | - Click the broom icon (🧹) in the top right corner of the test window 223 | - Start a new conversation 224 | - Check agent's rationale to understand agent's approach 225 | - If queries consistently fail, check the CloudWatch logs for the relevant Lambda functions (Athena Query and Athena Schema Reader). 226 | - Enable [Bedrock model invocation logging](https://docs.aws.amazon.com/bedrock/latest/userguide/model-invocation-logging.html) to troubleshoot 227 | 228 | ## Customization Considerations 229 | 230 | When adapting this solution to your environment: 231 | 232 | - **Agent Instructions**: Update the agent instructions in `prompt/instruction.txt` to reflect your specific database environment and schema discovery methods. 233 | 234 | - **Database Metadata Sources**: This sample uses AWS Glue Data Catalog via Athena's `SHOW tables` and `DESCRIBE table` commands. If your metadata is stored elsewhere (PostgreSQL's information_schema, Oracle's data dictionary, etc.), you'll need to modify the schema discovery approach accordingly. 235 | 236 | - **Metadata Enrichment**: If your database doesn't provide sufficient context through column comments, consider implementing a supplementary metadata repository to provide the agent with richer information about your data model, business context, and table relationships. 237 | 238 | - **Tool Interaction Optimization**: Our sample implementation processes one table at a time, which is simple but may require multiple turns for complex queries. In production environments, consider implementing bulk metadata retrieval or caching strategies to reduce latency and provide more complete context to the agent. 239 | 240 | ## License 241 | 242 | - [MIT-0](/LICENSE) 243 | 244 | ## Clean Up 245 | 246 | If you've decided to remove the resources, follow these steps carefully: 247 | 248 | 1. Destroy the stacks: 249 | 250 | ```bash 251 | cdk destroy --all --force 252 | ``` 253 | 254 | This command will destroy the CDK application without asking for confirmation. 255 | 256 | 2. Verify deletion in [CloudFormation](https://console.aws.amazon.com/cloudformation) 257 | 258 | 3. Manually force delete any remaining resources if necessary. 259 | 260 | 4. Delete CloudWatch Log Groups or set retention period in CloudWatch console. 261 | -------------------------------------------------------------------------------- /assets/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/sample-Dynamic-Text-to-SQL-with-Amazon-Bedrock-Agent/22e4713ac5c7d08923704190d062abcddea506b9/assets/architecture.png -------------------------------------------------------------------------------- /assets/code_interpreter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/sample-Dynamic-Text-to-SQL-with-Amazon-Bedrock-Agent/22e4713ac5c7d08923704190d062abcddea506b9/assets/code_interpreter.png -------------------------------------------------------------------------------- /assets/erd_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/sample-Dynamic-Text-to-SQL-with-Amazon-Bedrock-Agent/22e4713ac5c7d08923704190d062abcddea506b9/assets/erd_diagram.png -------------------------------------------------------------------------------- /assets/screenshot-agent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/sample-Dynamic-Text-to-SQL-with-Amazon-Bedrock-Agent/22e4713ac5c7d08923704190d062abcddea506b9/assets/screenshot-agent.png -------------------------------------------------------------------------------- /assets/screenshot-trace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/sample-Dynamic-Text-to-SQL-with-Amazon-Bedrock-Agent/22e4713ac5c7d08923704190d062abcddea506b9/assets/screenshot-trace.png -------------------------------------------------------------------------------- /bin/agentic-text2sql.ts: -------------------------------------------------------------------------------- 1 | import 'source-map-support/register'; 2 | import * as cdk from 'aws-cdk-lib'; 3 | import { AgentStack } from '../lib/agent-stack'; 4 | import { AthenaStack } from '../lib/db-stack'; 5 | import { AwsSolutionsChecks, NagSuppressions } from 'cdk-nag' 6 | import { Aspects } from 'aws-cdk-lib'; 7 | 8 | const app = new cdk.App(); 9 | Aspects.of(app).add(new AwsSolutionsChecks({ verbose: true })) 10 | 11 | // Setting Common Environment 12 | const env = { 13 | account: process.env.CDK_DEFAULT_ACCOUNT, 14 | region: process.env.CDK_DEFAULT_REGION 15 | }; 16 | 17 | // * Setting stack name prefix 18 | const stackNamePrefix = "AwsText2Sql-"; 19 | 20 | // * Create AthenaStack 21 | const athenaStack = new AthenaStack(app, stackNamePrefix + 'DbStack', { 22 | env: env, 23 | }); 24 | 25 | const agentStack = new AgentStack(app, stackNamePrefix + 'AgentStack', { 26 | env: env, 27 | ATHENA_OUTPUT_BUCKET: athenaStack.ATHENA_OUTPUT_BUCKET, 28 | ATHENA_DATA_BUCKET: athenaStack.ATHENA_DATA_BUCKET, 29 | }); 30 | agentStack.addDependency(athenaStack); 31 | 32 | NagSuppressions.addStackSuppressions(agentStack, [ 33 | { 34 | id: 'AwsSolutions-IAM5', 35 | reason: 'Required wildcards are scoped to specific resources and service integrations', 36 | }, 37 | ]); 38 | 39 | NagSuppressions.addStackSuppressions(athenaStack, [ 40 | { 41 | id: 'AwsSolutions-IAM4', 42 | reason: 'CDK generated custom Lambda function', 43 | }, 44 | { 45 | id: 'AwsSolutions-IAM5', 46 | reason: 'CDK generated custom Lambda function', 47 | }, 48 | { 49 | id: 'AwsSolutions-L1', 50 | reason: 'CDK generated custom Lambda function', 51 | }, 52 | ]); 53 | -------------------------------------------------------------------------------- /cdk.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": "npx ts-node --prefer-ts-exts bin/agentic-text2sql.ts", 3 | "watch": { 4 | "include": [ 5 | "**" 6 | ], 7 | "exclude": [ 8 | "README.md", 9 | "cdk*.json", 10 | "**/*.d.ts", 11 | "**/*.js", 12 | "tsconfig.json", 13 | "package*.json", 14 | "yarn.lock", 15 | "node_modules", 16 | "test" 17 | ] 18 | }, 19 | "context": { 20 | "@aws-cdk/aws-lambda:recognizeLayerVersion": true, 21 | "@aws-cdk/core:checkSecretUsage": true, 22 | "@aws-cdk/core:target-partitions": [ 23 | "aws", 24 | "aws-cn" 25 | ], 26 | "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true, 27 | "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true, 28 | "@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true, 29 | "@aws-cdk/aws-iam:minimizePolicies": true, 30 | "@aws-cdk/core:validateSnapshotRemovalPolicy": true, 31 | "@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true, 32 | "@aws-cdk/aws-s3:createDefaultLoggingPolicy": true, 33 | "@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true, 34 | "@aws-cdk/aws-apigateway:disableCloudWatchRole": true, 35 | "@aws-cdk/core:enablePartitionLiterals": true, 36 | "@aws-cdk/aws-events:eventsTargetQueueSameAccount": true, 37 | "@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true, 38 | "@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true, 39 | "@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true, 40 | "@aws-cdk/aws-route53-patters:useCertificate": true, 41 | "@aws-cdk/customresources:installLatestAwsSdkDefault": false, 42 | "@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true, 43 | "@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true, 44 | "@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true, 45 | "@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true, 46 | "@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true, 47 | "@aws-cdk/aws-redshift:columnId": true, 48 | "@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true, 49 | "@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true, 50 | "@aws-cdk/aws-apigateway:requestValidatorUniqueId": true, 51 | "@aws-cdk/aws-kms:aliasNameRef": true, 52 | "@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true, 53 | "@aws-cdk/core:includePrefixInUniqueNameGeneration": true, 54 | "@aws-cdk/aws-efs:denyAnonymousAccess": true, 55 | "@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true, 56 | "@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true, 57 | "@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true, 58 | "@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true, 59 | "@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true, 60 | "@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true, 61 | "@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true, 62 | "@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true, 63 | "@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true, 64 | "@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true, 65 | "@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true, 66 | "@aws-cdk/aws-eks:nodegroupNameAttribute": true, 67 | "@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true, 68 | "@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true, 69 | "@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false, 70 | "@aws-cdk/aws-s3:keepNotificationInImportedBucket": false, 71 | "@aws-cdk/aws-ecs:reduceEc2FargateCloudWatchPermissions": true, 72 | "@aws-cdk/aws-dynamodb:resourcePolicyPerReplica": true, 73 | "@aws-cdk/aws-ec2:ec2SumTImeoutEnabled": true, 74 | "@aws-cdk/aws-appsync:appSyncGraphQLAPIScopeLambdaPermission": true, 75 | "@aws-cdk/aws-rds:setCorrectValueForDatabaseInstanceReadReplicaInstanceResourceId": true, 76 | "@aws-cdk/core:cfnIncludeRejectComplexResourceUpdateCreatePolicyIntrinsics": true, 77 | "@aws-cdk/aws-lambda-nodejs:sdkV3ExcludeSmithyPackages": true, 78 | "@aws-cdk/aws-stepfunctions-tasks:fixRunEcsTaskPolicy": true 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest' 7 | } 8 | }; 9 | -------------------------------------------------------------------------------- /lib/agent-stack.ts: -------------------------------------------------------------------------------- 1 | import * as cdk from 'aws-cdk-lib'; 2 | import * as path from "path"; 3 | import { Construct } from 'constructs'; 4 | import { readFileSync } from "fs"; 5 | import { 6 | PythonFunction, 7 | PythonLayerVersion, 8 | } from "@aws-cdk/aws-lambda-python-alpha"; 9 | import { 10 | bedrock, 11 | } from "@cdklabs/generative-ai-cdk-constructs"; 12 | import { AgentActionGroup } from "@cdklabs/generative-ai-cdk-constructs/lib/cdk-lib/bedrock"; 13 | import { Stack, StackProps, Duration } from "aws-cdk-lib"; 14 | import * as iam from "aws-cdk-lib/aws-iam"; 15 | import { Runtime, LayerVersion, Code } from "aws-cdk-lib/aws-lambda"; 16 | import * as s3 from "aws-cdk-lib/aws-s3"; 17 | import * as sqs from "aws-cdk-lib/aws-sqs"; 18 | 19 | interface AgentsStackProps extends StackProps { 20 | ATHENA_OUTPUT_BUCKET: s3.Bucket; 21 | ATHENA_DATA_BUCKET: s3.Bucket; 22 | } 23 | 24 | export class AgentStack extends Stack { 25 | constructor(scope: Construct, id: string, props: AgentsStackProps) { 26 | super(scope, id, props); 27 | 28 | const lambdaPowertoolsLayer = new PythonLayerVersion( 29 | this, 30 | "LambdaPowertoolsLayer", 31 | { 32 | entry: path.join("src", "layers", "aws_lambda_powertools"), 33 | compatibleRuntimes: [Runtime.PYTHON_3_13], 34 | description: "Lambda Powertools for Python", 35 | }, 36 | ); 37 | 38 | const lambdaPydanticLayer = new PythonLayerVersion( 39 | this, 40 | "PydanticLayer", 41 | { 42 | entry: path.join("src", "layers", "pydantic"), 43 | compatibleRuntimes: [Runtime.PYTHON_3_13], 44 | } 45 | ); 46 | 47 | // Common Layer for Athena utilities 48 | const athenaCommonLayer = new LayerVersion(this, "AthenaCommonLayer", { 49 | code: Code.fromAsset( 50 | path.join("src", "common"), 51 | ), 52 | description: "Common utilities for Athena operations", 53 | compatibleRuntimes: [Runtime.PYTHON_3_13], 54 | }); 55 | 56 | // Define a function to create Athena Lambdas - 1. query execution, 2. schema read 57 | function createAthenaLambdaRole( 58 | parentScope: Construct, 59 | roleId: string, 60 | athenaDataBucket: s3.Bucket, 61 | athenaOutputBucket: s3.Bucket, 62 | ): iam.Role { 63 | const stack = Stack.of(parentScope); 64 | const role = new iam.Role(parentScope, roleId, { 65 | assumedBy: new iam.ServicePrincipal("lambda.amazonaws.com"), 66 | }); 67 | 68 | // Sample tables list 69 | const glueTables = [ 70 | 'accounts', 'bank_branches', 'card_transactions', 'cards', 'customers', 71 | 'devices', 'fraud_alerts', 'locations', 'merchants', 'rules_engine', 72 | 'suspicious_patterns', 'transaction_history', 'transactions' 73 | ]; 74 | 75 | role.addToPolicy( 76 | new iam.PolicyStatement({ 77 | actions: [ 78 | "logs:CreateLogGroup", 79 | "logs:CreateLogStream", 80 | "logs:PutLogEvents", 81 | ], 82 | resources: [ 83 | `arn:aws:logs:${stack.region}:${stack.account}:log-group:*` 84 | ], 85 | }), 86 | ); 87 | 88 | role.addToPolicy( 89 | new iam.PolicyStatement({ 90 | actions: [ 91 | "athena:StartQueryExecution", 92 | "athena:GetQueryExecution", 93 | "athena:GetQueryResults", 94 | ], 95 | resources: [ 96 | `arn:aws:athena:${stack.region}:${stack.account}:workgroup/primary`, 97 | ], 98 | }), 99 | ); 100 | 101 | role.addToPolicy( 102 | new iam.PolicyStatement({ 103 | actions: [ 104 | "glue:GetDatabase", 105 | "glue:GetTable", 106 | "glue:GetTables", 107 | "glue:GetPartitions", 108 | ], 109 | resources: [ 110 | `arn:aws:glue:${stack.region}:${stack.account}:catalog`, 111 | `arn:aws:glue:${stack.region}:${stack.account}:database/default`, 112 | `arn:aws:glue:${stack.region}:${stack.account}:database/fraud_data`, 113 | `arn:aws:glue:${stack.region}:${stack.account}:table/default/fraud_data`, 114 | ...glueTables.map(table => 115 | `arn:aws:glue:${stack.region}:${stack.account}:table/fraud_data/${table}` 116 | ) 117 | ], 118 | }), 119 | ); 120 | 121 | role.addToPolicy( 122 | new iam.PolicyStatement({ 123 | actions: [ 124 | "s3:GetBucketLocation", 125 | "s3:GetObject", 126 | "s3:ListBucket", 127 | "s3:PutObject", 128 | ], 129 | resources: [ 130 | athenaDataBucket.bucketArn, 131 | ...glueTables.map(table => `${athenaDataBucket.bucketArn}/${table}/${table}.csv`), 132 | athenaOutputBucket.bucketArn, 133 | `${athenaOutputBucket.bucketArn}/query-results/*`, 134 | ], 135 | }), 136 | ); 137 | 138 | return role; 139 | } 140 | 141 | // Define a function to create Agent action group Lambdas 142 | function createLambdaFunction( 143 | parentScope: Construct, 144 | lambdaId: string, 145 | lambdaProps: { 146 | entry: string; 147 | role?: iam.Role; 148 | layers?: PythonLayerVersion[]; 149 | environment?: { [key: string]: string }; 150 | deadLetterQueue?: sqs.Queue; 151 | }, 152 | ): PythonFunction { 153 | // Extract the file name, which is set to be same as the directory base name 154 | const fileName = path.basename(lambdaProps.entry); 155 | return new PythonFunction(parentScope, lambdaId, { 156 | functionName: `${path.parse(fileName).name}-${id}`, 157 | entry: lambdaProps.entry, 158 | index: fileName + ".py", 159 | handler: "lambda_handler", 160 | runtime: Runtime.PYTHON_3_13, 161 | timeout: Duration.minutes(5), 162 | memorySize: 256, 163 | environment: lambdaProps.environment, 164 | layers: lambdaProps.layers, 165 | role: lambdaProps.role, 166 | deadLetterQueue: lambdaProps.deadLetterQueue, 167 | }); 168 | } 169 | 170 | // Export agent instruction for Agent 171 | const instruction = readFileSync( 172 | path.join(__dirname, "../prompt", "instruction.txt"), 173 | "utf8", 174 | ); 175 | 176 | // Change this to your desired region: 177 | // US (default) - bedrock.CrossRegionInferenceProfileRegion.US 178 | // EU - bedrock.CrossRegionInferenceProfileRegion.EU, 179 | // APAC - bedrock.CrossRegionInferenceProfileRegion.APAC 180 | const anthropicClaudeRegionInferenceProfile = bedrock.CrossRegionInferenceProfile.fromConfig({ 181 | geoRegion: bedrock.CrossRegionInferenceProfileRegion.US, 182 | model: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V2_0 183 | }) 184 | 185 | // Create Dynamic Bedrock Agent with Dynamic Schema Discovery 186 | const dynamicAgent = new bedrock.Agent(this, "DynamicAgent", { 187 | name: cdk.Stack.of(this) + "-" + "DynamicAgent", 188 | foundationModel: anthropicClaudeRegionInferenceProfile, 189 | shouldPrepareAgent: true, 190 | userInputEnabled: true, 191 | codeInterpreterEnabled: true, 192 | instruction: 193 | "You are " + 194 | this.node.tryGetContext("custom:agentName") + 195 | ", a SQL analyst AI created specifically for " + 196 | this.node.tryGetContext("custom:companyName") + 197 | ". If Human says Hello, Greet the human with your name. " + 198 | "\n" + 199 | instruction, 200 | }); 201 | 202 | // Create IAM role for Athena Schema Reader Lambda 203 | const athenaSchemaReaderRole = createAthenaLambdaRole( 204 | this, 205 | "AthenaSchemaReaderRole", 206 | props.ATHENA_DATA_BUCKET, 207 | props.ATHENA_OUTPUT_BUCKET, 208 | ); 209 | 210 | // Create Athena Schema Reader Lambda 211 | const athenaSchemaReaderLambda = createLambdaFunction( 212 | this, 213 | "AthenaSchemaReaderLambda", 214 | { 215 | entry: path.join( 216 | "src", 217 | "athena_schema_reader", 218 | ), 219 | role: athenaSchemaReaderRole, 220 | layers: [ 221 | lambdaPowertoolsLayer, 222 | lambdaPydanticLayer, 223 | athenaCommonLayer, 224 | ], 225 | environment: { 226 | S3_OUTPUT: props.ATHENA_OUTPUT_BUCKET.bucketName, 227 | S3_DATA_BUCKET: props.ATHENA_DATA_BUCKET.bucketName, 228 | }, 229 | }, 230 | ); 231 | 232 | // Create DLQ for Athena Query Lambda 233 | const athenaQueryLambdaDLQ = new sqs.Queue(this, "AthenaQueryLambdaDLQ", { 234 | queueName: `AthenaQueryLambdaDLQs-Fraud-${this.account}-${this.region}`, 235 | encryption: sqs.QueueEncryption.SQS_MANAGED, 236 | enforceSSL: true, 237 | }); 238 | 239 | // Create IAM role for Athena Query Execution Lambda 240 | const athenaQueryLambdaRole = createAthenaLambdaRole( 241 | this, 242 | "AthenaQueryLambdaRole", 243 | props.ATHENA_DATA_BUCKET, 244 | props.ATHENA_OUTPUT_BUCKET, 245 | ); 246 | athenaQueryLambdaRole.addToPolicy( 247 | new iam.PolicyStatement({ 248 | actions: ["sqs:SendMessage"], 249 | resources: [athenaQueryLambdaDLQ.queueArn], 250 | }), 251 | ); 252 | 253 | // Create Athena Query Execution Lambda 254 | const athenaQueryLambda = createLambdaFunction(this, "AthenaQueryLambda", { 255 | entry: path.join( 256 | "src", 257 | "athena_query", 258 | ), 259 | role: athenaQueryLambdaRole, 260 | layers: [ 261 | lambdaPowertoolsLayer, 262 | lambdaPydanticLayer, 263 | athenaCommonLayer, 264 | ], 265 | environment: { 266 | S3_OUTPUT: props.ATHENA_OUTPUT_BUCKET.bucketName, 267 | S3_DATA_BUCKET: props.ATHENA_DATA_BUCKET.bucketName, 268 | }, 269 | deadLetterQueue: athenaQueryLambdaDLQ, 270 | }); 271 | 272 | // Grant permissions to the Lambda function 273 | props.ATHENA_DATA_BUCKET.grantReadWrite( 274 | athenaQueryLambda, 275 | athenaSchemaReaderLambda, 276 | ); 277 | props.ATHENA_OUTPUT_BUCKET.grantReadWrite( 278 | athenaQueryLambda, 279 | athenaSchemaReaderLambda, 280 | ); 281 | 282 | 283 | // Add Athena Query Action Group 284 | const athenaQueryActionGroup = new bedrock.AgentActionGroup({ 285 | name: "AthenaQueryActionGroup", 286 | description: "This action group is used to query information about data", 287 | executor: bedrock.ActionGroupExecutor.fromlambdaFunction(athenaQueryLambda), 288 | apiSchema: bedrock.ApiSchema.fromLocalAsset( 289 | path.join(__dirname, "../src/athena_query", "openapi.json") 290 | ) 291 | }) 292 | dynamicAgent.addActionGroup(athenaQueryActionGroup) 293 | 294 | // Add Athena Schema Reader Action Group 295 | const athenaSchemaReaderActionGroup = new bedrock.AgentActionGroup({ 296 | name: "AthenaSchemaReaderActionGroup", 297 | description: "This action group is used to read schema from Athena", 298 | executor: bedrock.ActionGroupExecutor.fromlambdaFunction(athenaSchemaReaderLambda), 299 | apiSchema: bedrock.ApiSchema.fromLocalAsset( 300 | path.join(__dirname, "../src/athena_schema_reader", "openapi.json") 301 | ) 302 | }) 303 | dynamicAgent.addActionGroup(athenaSchemaReaderActionGroup); 304 | } 305 | } 306 | -------------------------------------------------------------------------------- /lib/assets/data/accounts/accounts.csv: -------------------------------------------------------------------------------- 1 | account_id,customer_id,account_type,account_status,created_date,closed_date,current_balance,branch_id 2 | 1,1,Checking,Active,2023-01-01,,5000.00,101 3 | 2,2,Savings,Active,2023-02-15,,10000.00,102 4 | 3,3,Checking,Inactive,2022-11-20,2023-10-01,0.00,103 5 | 4,4,Checking,Active,2023-03-12,,2000.00,104 6 | 5,5,Savings,Active,2023-05-25,,15000.00,105 7 | 6,6,Checking,Active,2023-07-18,,2500.00,106 8 | 7,7,Savings,Active,2023-09-01,,12000.00,107 9 | 8,8,Checking,Closed,2023-06-01,2023-12-01,0.00,108 10 | 9,9,Checking,Active,2023-08-22,,8000.00,109 11 | 10,10,Savings,Active,2023-04-10,,5000.00,110 12 | -------------------------------------------------------------------------------- /lib/assets/data/bank_branches/bank_branches.csv: -------------------------------------------------------------------------------- 1 | branch_id,branch_name,address,city,state 2 | 101,Downtown Branch,123 Main St,New York,NY 3 | 102,Westside Branch,456 Oak Rd,Los Angeles,CA 4 | 103,Lakeshore Branch,789 Pine Ave,Chicago,IL 5 | 104,Midtown Branch,101 Maple Ln,Houston,TX 6 | 105,Desert Branch,202 Elm St,Phoenix,AZ 7 | 106,Liberty Branch,303 Birch Rd,Philadelphia,PA 8 | 107,Riverwalk Branch,404 Cedar St,San Antonio,TX 9 | 108,Seaside Branch,505 Walnut Blvd,San Diego,CA 10 | 109,Skyline Branch,606 Spruce Dr,Dallas,TX 11 | 110,Golden Gate Branch,707 Aspen Way,San Francisco,CA 12 | -------------------------------------------------------------------------------- /lib/assets/data/card_transactions/card_transactions.csv: -------------------------------------------------------------------------------- 1 | card_transaction_id,card_id,transaction_id,transaction_type,amount,transaction_date,merchant_id,location,currency,transaction_status,fraud_flag,flagged_by,fraud_reason 2 | 11,5,i,Withdrawal,11.59,2024-10-20,8,Philadelphia, PA,USD,Completed,false,, 3 | 12,10,i,Withdrawal,12.29,2024-12-05,6,Houston, TX,USD,Completed,false,, 4 | 13,5,i,Purchase,10.15,2024-12-20,4,Phoenix, AZ,USD,Completed,false,, 5 | 14,1,i,Purchase,13.11,2024-12-15,9,Dallas, TX,USD,Completed,false,, 6 | 15,10,i,Purchase,11.06,2024-10-25,5,Phoenix, AZ,USD,Completed,false,, 7 | 16,4,i,Withdrawal,11.10,2024-12-06,2,Chicago, IL,USD,Completed,true,System,Exceeds daily limit 8 | 17,6,i,Purchase,10.83,2024-12-06,8,Dallas, TX,USD,Completed,false,, 9 | 18,9,i,Purchase,12.40,2024-10-04,1,Dallas, TX,USD,Completed,false,, 10 | 19,7,i,Purchase,12.53,2024-12-02,3,New York, NY,USD,Completed,true,System,Multiple password attempts 11 | 20,4,i,Purchase,10.39,2024-10-16,3,Chicago, IL,USD,Completed,true,System,Unusual location 12 | 21,1,i,Withdrawal,11.19,2024-11-06,8,San Diego, CA,USD,Completed,false,, 13 | 22,5,i,Withdrawal,11.72,2024-11-13,8,Philadelphia, PA,USD,Completed,false,, 14 | 23,8,i,Purchase,10.10,2024-12-28,5,Phoenix, AZ,USD,Completed,false,, 15 | 24,3,i,Purchase,10.52,2024-11-07,7,San Antonio, TX,USD,Completed,false,, 16 | 25,10,i,Withdrawal,10.69,2024-10-13,1,Los Angeles, CA,USD,Completed,false,, 17 | 26,1,i,Purchase,11.80,2024-12-18,7,Phoenix, AZ,USD,Completed,false,, 18 | 27,2,i,Purchase,10.37,2024-11-13,9,Dallas, TX,USD,Completed,false,, 19 | 28,1,i,Purchase,12.66,2024-11-04,7,Philadelphia, PA,USD,Completed,false,, 20 | 29,5,i,Withdrawal,10.29,2024-12-12,4,Houston, TX,USD,Completed,true,System,Unusual location 21 | 30,7,i,Withdrawal,11.12,2024-12-24,10,San Francisco, CA,USD,Completed,false,, 22 | 31,10,i,Withdrawal,12.22,2024-11-05,2,San Francisco, CA,USD,Completed,true,System,Large transaction 23 | 32,7,i,Purchase,12.88,2024-12-02,1,Dallas, TX,USD,Completed,false,, 24 | 33,3,i,Purchase,12.04,2024-12-12,1,Dallas, TX,USD,Completed,false,, 25 | 34,8,i,Withdrawal,12.87,2024-10-17,8,Philadelphia, PA,USD,Completed,false,, 26 | 35,2,i,Withdrawal,11.73,2024-11-15,4,Chicago, IL,USD,Completed,false,, 27 | 36,4,i,Withdrawal,11.91,2024-11-27,6,Houston, TX,USD,Completed,false,, 28 | 37,1,i,Withdrawal,11.31,2024-11-14,10,New York, NY,USD,Completed,false,, 29 | 38,5,i,Purchase,11.71,2024-10-28,10,Dallas, TX,USD,Completed,false,, 30 | 39,8,i,Withdrawal,12.62,2024-10-05,10,San Diego, CA,USD,Completed,false,, 31 | 40,5,i,Purchase,11.66,2024-10-03,7,Phoenix, AZ,USD,Completed,false,, 32 | 41,7,i,Withdrawal,13.16,2024-12-13,10,New York, NY,USD,Completed,false,, 33 | 42,8,i,Purchase,11.62,2024-10-07,5,Chicago, IL,USD,Completed,false,, 34 | 43,7,i,Purchase,10.77,2024-11-10,3,Chicago, IL,USD,Completed,true,System,Unusual location 35 | 44,2,i,Withdrawal,10.33,2024-12-27,7,San Diego, CA,USD,Completed,false,, 36 | 45,2,i,Purchase,11.69,2024-10-15,5,Chicago, IL,USD,Completed,false,, 37 | 46,5,i,Withdrawal,10.98,2024-12-04,8,San Diego, CA,USD,Completed,false,, 38 | 47,5,i,Purchase,11.87,2024-12-24,10,Dallas, TX,USD,Completed,false,, 39 | 48,3,i,Withdrawal,12.78,2024-12-08,8,Philadelphia, PA,USD,Completed,false,, 40 | 49,8,i,Purchase,11.54,2024-10-05,3,New York, NY,USD,Completed,true,System,Multiple password attempts 41 | 50,8,i,Withdrawal,10.55,2024-10-23,2,Los Angeles, CA,USD,Completed,false,, 42 | 51,4,i,Withdrawal,12.43,2024-10-02,6,Houston, TX,USD,Completed,false,, 43 | 52,3,i,Purchase,12.77,2024-12-13,4,Chicago, IL,USD,Completed,false,, 44 | 53,9,i,Purchase,10.99,2024-12-03,3,Chicago, IL,USD,Completed,true,System,Unusual location 45 | 54,2,i,Purchase,11.72,2024-11-27,9,San Antonio, TX,USD,Completed,false,, 46 | 55,5,i,Purchase,11.67,2024-10-01,9,San Antonio, TX,USD,Completed,false,, 47 | 56,1,i,Purchase,10.67,2024-11-23,9,Dallas, TX,USD,Completed,false,, 48 | 57,8,i,Withdrawal,12.21,2024-12-16,10,San Diego, CA,USD,Completed,false,, 49 | 58,4,i,Purchase,11.12,2024-12-21,2,Chicago, IL,USD,Completed,true,System,Exceeds daily limit 50 | 59,4,i,Withdrawal,11.73,2024-10-10,2,San Francisco, CA,USD,Completed,false,, 51 | 60,8,i,Purchase,12.72,2024-12-02,9,San Antonio, TX,USD,Completed,false,, 52 | 61,3,i,Withdrawal,10.19,2024-10-10,8,San Diego, CA,USD,Completed,false,, 53 | 62,7,i,Purchase,11.48,2024-10-14,9,San Francisco, CA,USD,Completed,false,, 54 | 63,5,i,Purchase,13.18,2024-10-13,5,Phoenix, AZ,USD,Completed,false,, 55 | 64,6,i,Withdrawal,10.27,2024-10-09,6,Philadelphia, PA,USD,Completed,false,, 56 | 65,2,i,Purchase,13.08,2024-10-15,2,New York, NY,USD,Completed,true,System,Exceeds daily limit 57 | 66,6,i,Purchase,12.00,2024-11-18,3,New York, NY,USD,Completed,true,System,Large transaction 58 | 67,1,i,Purchase,11.29,2024-11-22,7,San Antonio, TX,USD,Completed,false,, 59 | 68,4,i,Purchase,12.26,2024-12-17,1,Dallas, TX,USD,Completed,false,, 60 | 69,2,i,Purchase,12.19,2024-10-10,7,Phoenix, AZ,USD,Completed,false,, 61 | 70,5,i,Purchase,10.14,2024-11-26,1,Los Angeles, CA,USD,Completed,false,, 62 | 71,5,i,Purchase,12.15,2024-11-15,9,San Antonio, TX,USD,Completed,false,, 63 | 72,8,i,Withdrawal,11.08,2024-11-26,3,Houston, TX,USD,Completed,true,System,Unusual location 64 | 73,1,i,Withdrawal,11.41,2024-12-10,6,Philadelphia, PA,USD,Completed,false,, 65 | 74,9,i,Purchase,12.38,2024-11-28,5,Chicago, IL,USD,Completed,false,, 66 | 75,3,i,Withdrawal,11.67,2024-11-28,8,Philadelphia, PA,USD,Completed,false,, 67 | 76,1,i,Withdrawal,12.26,2024-10-07,3,Los Angeles, CA,USD,Completed,true,System,Multiple password attempts 68 | 77,4,i,Withdrawal,12.41,2024-10-27,10,San Diego, CA,USD,Completed,false,, 69 | 78,7,i,Purchase,13.18,2024-10-04,3,Chicago, IL,USD,Completed,true,System,Unusual location 70 | 79,6,i,Withdrawal,12.70,2024-12-26,4,Los Angeles, CA,USD,Completed,true,System,Exceeds daily limit 71 | 80,3,i,Withdrawal,11.62,2024-10-07,8,San Antonio, TX,USD,Completed,false,, 72 | 81,5,i,Withdrawal,12.44,2024-10-17,2,San Francisco, CA,USD,Completed,false,, 73 | 82,4,i,Withdrawal,10.77,2024-10-18,10,San Francisco, CA,USD,Completed,false,, 74 | 83,9,i,Withdrawal,13.22,2024-11-26,10,San Francisco, CA,USD,Completed,false,, 75 | 84,5,i,Withdrawal,12.23,2024-12-09,9,San Diego, CA,USD,Completed,false,, 76 | 85,9,i,Purchase,10.01,2024-11-24,9,Dallas, TX,USD,Completed,false,, 77 | 86,6,i,Withdrawal,10.43,2024-11-16,4,Houston, TX,USD,Completed,true,System,Amount pattern 78 | 87,8,i,Purchase,13.17,2024-11-17,7,San Diego, CA,USD,Completed,false,, 79 | 88,6,i,Purchase,10.25,2024-10-21,7,San Antonio, TX,USD,Completed,false,, 80 | 89,3,i,Withdrawal,12.01,2024-10-11,6,Phoenix, AZ,USD,Completed,false,, 81 | 90,8,i,Withdrawal,10.86,2024-11-27,8,San Diego, CA,USD,Completed,false,, 82 | 91,7,i,Purchase,11.78,2024-10-16,3,Los Angeles, CA,USD,Completed,true,System,Multiple password attempts 83 | 92,5,i,Withdrawal,12.23,2024-11-10,6,Houston, TX,USD,Completed,false,, 84 | 93,5,i,Purchase,12.26,2024-11-28,3,New York, NY,USD,Completed,true,System,Multiple password attempts 85 | 94,9,i,Withdrawal,13.25,2024-11-27,6,San Antonio, TX,USD,Completed,false,, 86 | 95,9,i,Withdrawal,11.33,2024-10-05,6,Philadelphia, PA,USD,Completed,false,, 87 | 96,6,i,Withdrawal,12.98,2024-11-17,3,Los Angeles, CA,USD,Completed,true,System,Multiple password attempts 88 | 97,9,i,Purchase,11.63,2024-11-21,5,Chicago, IL,USD,Completed,false,, 89 | 98,5,i,Withdrawal,13.15,2024-12-06,1,Los Angeles, CA,USD,Completed,false,, 90 | 99,9,i,Withdrawal,10.01,2024-11-18,2,Los Angeles, CA,USD,Completed,false,, 91 | 100,5,i,Purchase,12.14,2024-10-15,1,Dallas, TX,USD,Completed,false,, 92 | 101,9,i,Withdrawal,10.57,2024-11-01,4,Houston, TX,USD,Completed,true,System,Amount pattern 93 | 102,9,i,Purchase,12.44,2024-11-23,9,San Antonio, TX,USD,Completed,false,, 94 | 103,1,i,Withdrawal,12.20,2024-10-28,6,Houston, TX,USD,Completed,false,, 95 | 104,4,i,Purchase,11.71,2024-12-22,1,New York, NY,USD,Completed,false,, 96 | 105,5,i,Purchase,12.63,2024-10-17,3,New York, NY,USD,Completed,true,System,Multiple password attempts 97 | 106,3,i,Withdrawal,11.57,2024-12-27,2,San Francisco, CA,USD,Completed,true,System,Large transaction 98 | 107,9,i,Purchase,12.17,2024-10-19,5,Chicago, IL,USD,Completed,false,, 99 | 108,9,i,Withdrawal,11.45,2024-10-25,1,Los Angeles, CA,USD,Completed,true,System,Multiple password attempts 100 | 109,2,i,Purchase,12.07,2024-10-11,9,San Diego, CA,USD,Completed,false,, 101 | 110,5,i,Withdrawal,11.66,2024-10-08,6,Houston, TX,USD,Completed,false,, 102 | 111,7,i,Purchase,12.70,2024-10-10,1,Dallas, TX,USD,Completed,false,, 103 | 112,9,i,Withdrawal,12.30,2024-10-06,4,Los Angeles, CA,USD,Completed,true,System,Exceeds daily limit 104 | 113,8,i,Withdrawal,12.64,2024-10-15,7,Philadelphia, PA,USD,Completed,false,, 105 | 114,8,i,Purchase,11.95,2024-10-12,7,Philadelphia, PA,USD,Completed,false,, 106 | 115,3,i,Purchase,11.10,2024-10-25,5,Phoenix, AZ,USD,Completed,false,, 107 | 116,8,i,Withdrawal,11.87,2024-10-25,5,Houston, TX,USD,Completed,false,, 108 | 117,4,i,Purchase,12.56,2024-11-04,7,Philadelphia, PA,USD,Completed,false,, 109 | 118,3,i,Withdrawal,11.97,2024-10-01,2,San Francisco, CA,USD,Completed,false,, 110 | 119,3,i,Purchase,10.03,2024-10-02,9,Dallas, TX,USD,Completed,false,, 111 | 120,7,i,Withdrawal,12.10,2024-11-20,8,San Antonio, TX,USD,Completed,false,, 112 | 121,2,i,Withdrawal,11.95,2024-10-22,9,San Diego, CA,USD,Completed,false,, 113 | 122,8,i,Purchase,11.82,2024-12-14,1,Dallas, TX,USD,Completed,false,, 114 | 123,5,i,Withdrawal,12.58,2024-11-18,4,Los Angeles, CA,USD,Completed,true,System,Multiple password attempts 115 | 124,5,i,Withdrawal,10.37,2024-10-23,3,Houston, TX,USD,Completed,true,System,Unusual location 116 | 125,2,i,Withdrawal,10.11,2024-10-08,4,Houston, TX,USD,Completed,true,System,Amount pattern 117 | 126,9,i,Withdrawal,12.17,2024-12-24,5,Houston, TX,USD,Completed,false,, 118 | 127,5,i,Withdrawal,12.38,2024-11-17,4,Chicago, IL,USD,Completed,false,, 119 | 128,1,i,Purchase,12.85,2024-11-28,5,Chicago, IL,USD,Completed,false,, 120 | 129,7,i,Withdrawal,11.27,2024-12-27,1,Los Angeles, CA,USD,Completed,false,, 121 | 130,1,i,Purchase,11.70,2024-12-02,9,San Antonio, TX,USD,Completed,false,, 122 | 131,4,i,Withdrawal,13.21,2024-10-17,5,Philadelphia, PA,USD,Completed,false,, 123 | 132,7,i,Withdrawal,12.57,2024-11-28,10,San Diego, CA,USD,Completed,false,, 124 | 133,7,i,Purchase,13.00,2024-10-13,9,San Antonio, TX,USD,Completed,false,, 125 | 134,1,i,Withdrawal,10.19,2024-12-17,4,Houston, TX,USD,Completed,false,, 126 | 135,4,i,Withdrawal,11.55,2024-10-14,6,Houston, TX,USD,Completed,false,, 127 | 136,1,i,Purchase,10.12,2024-12-08,1,New York, NY,USD,Completed,false,, 128 | 137,3,i,Withdrawal,11.78,2024-12-09,8,Philadelphia, PA,USD,Completed,false,, 129 | 138,3,i,Withdrawal,12.98,2024-10-26,10,San Diego, CA,USD,Completed,false,, 130 | 139,2,i,Withdrawal,11.51,2024-10-12,6,Houston, TX,USD,Completed,false,, 131 | 140,4,i,Withdrawal,12.73,2024-12-09,2,San Francisco, CA,USD,Completed,true,System,Large transaction 132 | 141,7,i,Purchase,12.57,2024-11-10,5,Chicago, IL,USD,Completed,false,, 133 | 142,7,i,Withdrawal,10.80,2024-10-26,4,Houston, TX,USD,Completed,false,, 134 | 143,2,i,Purchase,12.63,2024-10-07,1,San Francisco, CA,USD,Completed,false,, 135 | 144,4,i,Withdrawal,11.95,2024-11-04,8,Philadelphia, PA,USD,Completed,false,, 136 | 145,8,i,Withdrawal,10.54,2024-10-05,2,Los Angeles, CA,USD,Completed,false,, 137 | 146,9,i,Withdrawal,12.49,2024-10-18,4,Los Angeles, CA,USD,Completed,false,, 138 | 147,5,i,Withdrawal,10.42,2024-11-04,4,Houston, TX,USD,Completed,false,, 139 | 148,2,i,Withdrawal,11.91,2024-11-18,8,Philadelphia, PA,USD,Completed,false,, 140 | 149,1,i,Withdrawal,10.68,2024-11-27,7,San Diego, CA,USD,Completed,false,, 141 | 150,8,i,Withdrawal,11.73,2024-12-05,2,San Francisco, CA,USD,Completed,false,, 142 | 151,7,i,Purchase,10.93,2024-12-27,4,Phoenix, AZ,USD,Completed,false,, 143 | 152,7,i,Withdrawal,13.04,2024-12-05,10,San Diego, CA,USD,Completed,false,, 144 | 153,8,i,Withdrawal,13.24,2024-12-09,10,San Francisco, CA,USD,Completed,false,, 145 | 154,3,i,Purchase,11.26,2024-11-01,3,Chicago, IL,USD,Completed,true,System,Unusual location 146 | 155,3,i,Purchase,12.91,2024-10-04,5,Chicago, IL,USD,Completed,false,, 147 | 156,10,i,Withdrawal,10.09,2024-10-13,8,San Diego, CA,USD,Completed,false,, 148 | 157,1,i,Purchase,12.83,2024-10-25,2,New York, NY,USD,Completed,true,System,Large transaction 149 | 158,10,i,Withdrawal,10.20,2024-10-28,6,San Antonio, TX,USD,Completed,false,, 150 | 159,1,i,Withdrawal,10.64,2024-11-13,8,San Diego, CA,USD,Completed,false,, 151 | 160,10,i,Withdrawal,12.13,2024-10-22,4,Los Angeles, CA,USD,Completed,false,, 152 | 161,1,i,Purchase,11.87,2024-10-28,5,Chicago, IL,USD,Completed,false,, 153 | 162,7,i,Withdrawal,12.65,2024-10-10,2,San Francisco, CA,USD,Completed,true,System,Large transaction 154 | 163,2,i,Withdrawal,13.20,2024-12-12,8,San Diego, CA,USD,Completed,false,, 155 | 164,4,i,Withdrawal,11.76,2024-12-12,10,San Diego, CA,USD,Completed,false,, 156 | 165,10,i,Withdrawal,12.18,2024-10-21,2,San Francisco, CA,USD,Completed,false,, 157 | 166,9,i,Withdrawal,11.28,2024-10-04,2,Los Angeles, CA,USD,Completed,true,System,Exceeds daily limit 158 | 167,7,i,Purchase,12.65,2024-12-24,2,New York, NY,USD,Completed,true,System,Large transaction 159 | 168,2,i,Withdrawal,11.88,2024-11-07,1,San Francisco, CA,USD,Completed,false,, 160 | 169,8,i,Purchase,11.77,2024-11-22,7,Phoenix, AZ,USD,Completed,false,, 161 | 170,8,i,Withdrawal,12.64,2024-12-15,2,San Francisco, CA,USD,Completed,false,, 162 | 171,1,i,Withdrawal,10.04,2024-11-07,6,Philadelphia, PA,USD,Completed,false,, 163 | 172,2,i,Purchase,10.98,2024-11-18,7,San Diego, CA,USD,Completed,false,, 164 | 173,9,i,Withdrawal,11.13,2024-12-06,2,Los Angeles, CA,USD,Completed,false,, 165 | 174,10,i,Purchase,10.69,2024-12-09,5,Phoenix, AZ,USD,Completed,false,, 166 | 175,8,i,Purchase,10.83,2024-11-13,9,Dallas, TX,USD,Completed,false,, 167 | 176,8,i,Purchase,12.08,2024-12-18,3,New York, NY,USD,Completed,true,System,Multiple password attempts 168 | 177,7,i,Withdrawal,12.90,2024-11-22,10,San Diego, CA,USD,Completed,false,, 169 | 178,1,i,Withdrawal,11.44,2024-12-05,8,Dallas, TX,USD,Completed,false,, 170 | 179,7,i,Withdrawal,11.63,2024-12-09,6,Houston, TX,USD,Completed,false,, 171 | 180,10,i,Withdrawal,12.39,2024-12-16,6,Houston, TX,USD,Completed,false,, 172 | 181,5,i,Withdrawal,11.38,2024-10-21,6,Philadelphia, PA,USD,Completed,false,, 173 | 182,2,i,Withdrawal,12.32,2024-11-05,6,Phoenix, AZ,USD,Completed,false,, 174 | 183,8,i,Withdrawal,10.69,2024-11-28,10,San Francisco, CA,USD,Completed,false,, 175 | 184,8,i,Withdrawal,12.83,2024-11-14,2,San Francisco, CA,USD,Completed,false,, 176 | 185,5,i,Withdrawal,12.22,2024-12-18,2,San Francisco, CA,USD,Completed,false,, 177 | 186,1,i,Purchase,11.82,2024-11-16,5,Chicago, IL,USD,Completed,false,, 178 | 187,9,i,Withdrawal,10.66,2024-10-08,8,Dallas, TX,USD,Completed,false,, 179 | 188,10,i,Purchase,10.68,2024-10-27,7,San Diego, CA,USD,Completed,false,, 180 | 189,6,i,Withdrawal,11.78,2024-12-28,9,San Diego, CA,USD,Completed,false,, 181 | 190,1,i,Withdrawal,11.55,2024-12-08,3,Los Angeles, CA,USD,Completed,true,System,Multiple password attempts 182 | 191,3,i,Withdrawal,13.00,2024-10-03,3,Los Angeles, CA,USD,Completed,true,System,Multiple password attempts 183 | 192,10,i,Purchase,11.32,2024-10-05,7,San Diego, CA,USD,Completed,false,, 184 | 193,10,i,Withdrawal,10.17,2024-10-24,6,Philadelphia, PA,USD,Completed,false,, 185 | 194,4,i,Purchase,10.12,2024-10-26,7,San Antonio, TX,USD,Completed,false,, 186 | 195,2,i,Purchase,11.31,2024-10-09,6,San Antonio, TX,USD,Completed,false,, 187 | 196,7,i,Purchase,10.82,2024-12-10,4,Phoenix, AZ,USD,Completed,false,, 188 | 197,3,i,Purchase,12.32,2024-10-06,1,Dallas, TX,USD,Completed,false,, 189 | 198,2,i,Purchase,12.39,2024-11-20,4,Chicago, IL,USD,Completed,false,, 190 | 199,3,i,Withdrawal,11.89,2024-10-14,2,San Francisco, CA,USD,Completed,false,, 191 | 200,6,i,Purchase,10.22,2024-11-04,9,Dallas, TX,USD,Completed,false,, 192 | 201,10,i,Withdrawal,13.20,2024-10-17,8,San Diego, CA,USD,Completed,false,, 193 | 202,4,i,Withdrawal,11.05,2024-12-10,10,San Francisco, CA,USD,Completed,false,, 194 | 203,4,i,Purchase,11.18,2024-11-04,7,San Antonio, TX,USD,Completed,false,, 195 | 204,6,i,Withdrawal,11.15,2024-12-09,8,San Diego, CA,USD,Completed,false,, 196 | 205,4,i,Withdrawal,12.28,2024-12-12,10,San Diego, CA,USD,Completed,false,, 197 | 206,9,i,Purchase,12.60,2024-11-12,5,Chicago, IL,USD,Completed,false,, 198 | 207,1,i,Withdrawal,10.54,2024-12-12,8,San Diego, CA,USD,Completed,false,, 199 | 208,1,i,Purchase,11.35,2024-10-12,5,Phoenix, AZ,USD,Completed,false,, 200 | 209,4,i,Purchase,12.25,2024-11-16,1,Dallas, TX,USD,Completed,false,, 201 | 210,5,i,Withdrawal,10.36,2024-11-22,6,San Antonio, TX,USD,Completed,false,, 202 | 211,8,i,Purchase,13.24,2024-11-16,3,Chicago, IL,USD,Completed,true,System,Unusual location 203 | 212,10,i,Purchase,10.18,2024-11-02,9,Dallas, TX,USD,Completed,false,, 204 | 213,3,i,Purchase,10.74,2024-10-05,1,Los Angeles, CA,USD,Completed,false,, 205 | 214,10,i,Withdrawal,12.38,2024-12-09,8,Philadelphia, PA,USD,Completed,false,, 206 | 215,2,i,Purchase,10.45,2024-10-24,9,Dallas, TX,USD,Completed,false,, 207 | 216,1,i,Withdrawal,11.42,2024-10-18,6,Philadelphia, PA,USD,Completed,false,, 208 | 217,5,i,Purchase,10.74,2024-12-12,1,New York, NY,USD,Completed,false,, 209 | 218,5,i,Purchase,12.24,2024-11-14,8,San Antonio, TX,USD,Completed,false,, 210 | 219,8,i,Purchase,11.96,2024-12-01,9,San Diego, CA,USD,Completed,false,, 211 | 220,4,i,Withdrawal,11.76,2024-10-05,2,New York, NY,USD,Completed,true,System,Large transaction 212 | 221,2,i,Withdrawal,12.01,2024-11-11,8,Philadelphia, PA,USD,Completed,false,, 213 | 222,4,i,Purchase,10.11,2024-11-25,1,New York, NY,USD,Completed,false,, 214 | 223,4,i,Withdrawal,11.28,2024-11-09,1,Los Angeles, CA,USD,Completed,false,, 215 | 224,2,i,Purchase,12.47,2024-11-25,9,San Antonio, TX,USD,Completed,false,, 216 | 225,5,i,Purchase,11.47,2024-10-21,5,Phoenix, AZ,USD,Completed,false,, 217 | 226,8,i,Purchase,10.51,2024-11-17,5,Phoenix, AZ,USD,Completed,false,, 218 | 227,4,i,Purchase,10.38,2024-12-19,6,San Antonio, TX,USD,Completed,false,, 219 | 228,1,i,Purchase,12.78,2024-10-12,5,Chicago, IL,USD,Completed,false,, 220 | 229,4,i,Purchase,11.74,2024-11-18,7,Phoenix, AZ,USD,Completed,false,, 221 | 230,1,i,Withdrawal,12.98,2024-11-12,4,Los Angeles, CA,USD,Completed,true,System,Exceeds daily limit 222 | 231,5,i,Withdrawal,12.42,2024-11-14,10,San Diego, CA,USD,Completed,false,, 223 | 232,8,i,Withdrawal,12.35,2024-12-20,10,San Diego, CA,USD,Completed,false,, 224 | 233,4,i,Withdrawal,11.46,2024-12-08,6,Philadelphia, PA,USD,Completed,false,, 225 | 234,7,i,Withdrawal,12.17,2024-10-16,3,Los Angeles, CA,USD,Completed,true,System,Multiple password attempts 226 | 235,10,i,Withdrawal,10.84,2024-12-10,2,Los Angeles, CA,USD,Completed,true,System,Exceeds daily limit 227 | 236,6,i,Withdrawal,12.74,2024-12-14,10,San Diego, CA,USD,Completed,false,, 228 | 237,10,i,Withdrawal,12.13,2024-12-27,2,New York, NY,USD,Completed,true,System,Large transaction 229 | 238,8,i,Purchase,11.43,2024-10-27,5,Philadelphia, PA,USD,Completed,false,, 230 | 239,8,i,Withdrawal,10.73,2024-11-12,4,Houston, TX,USD,Completed,false,, 231 | 240,4,i,Withdrawal,11.10,2024-10-27,7,San Diego, CA,USD,Completed,false,, 232 | 241,2,i,Withdrawal,11.03,2024-10-08,6,Philadelphia, PA,USD,Completed,false,, 233 | 242,6,i,Purchase,11.38,2024-12-05,4,Phoenix, AZ,USD,Completed,false,, 234 | 243,2,i,Withdrawal,13.04,2024-10-14,1,San Francisco, CA,USD,Completed,false,, 235 | 244,4,i,Purchase,11.53,2024-11-28,7,Philadelphia, PA,USD,Completed,false,, 236 | 245,5,i,Purchase,12.97,2024-11-12,9,San Antonio, TX,USD,Completed,false,, 237 | 246,4,i,Withdrawal,12.54,2024-10-17,2,San Francisco, CA,USD,Completed,true,System,Large transaction 238 | 247,2,i,Purchase,10.51,2024-11-12,3,New York, NY,USD,Completed,true,System,Multiple password attempts 239 | 248,10,i,Purchase,11.69,2024-10-02,1,Dallas, TX,USD,Completed,false,, 240 | 249,5,i,Purchase,12.37,2024-12-04,3,New York, NY,USD,Completed,true,System,Multiple password attempts 241 | 250,2,i,Purchase,11.79,2024-12-21,1,Dallas, TX,USD,Completed,false,, 242 | -------------------------------------------------------------------------------- /lib/assets/data/cards/cards.csv: -------------------------------------------------------------------------------- 1 | card_id,customer_id,card_number,card_type,expiration_date,cvv,issue_date,status,last_used_date 2 | 1,1,4532XXXXXXXX1234,Credit,2025-12-31,123,2024-10-01,Active,2024-12-15 3 | 2,2,4532XXXXXXXX5678,Debit,2025-12-31,456,2024-11-15,Active,2024-12-15 4 | 3,3,4532XXXXXXXX9012,Credit,2025-12-31,789,2024-12-01,Active,2024-12-15 5 | 4,4,4532XXXXXXXX3456,Credit,2025-12-31,012,2024-12-12,Active,2024-12-15 6 | 5,5,4532XXXXXXXX7890,Debit,2025-12-31,345,2024-10-25,Active,2024-12-15 7 | 6,6,4532XXXXXXXX2345,Credit,2025-12-31,678,2024-11-18,Active,2024-12-15 8 | 7,7,4532XXXXXXXX6789,Debit,2025-12-31,901,2024-12-01,Active,2024-12-15 9 | 8,8,4532XXXXXXXX0123,Credit,2025-12-31,234,2024-11-01,Active,2024-12-15 10 | 9,9,4532XXXXXXXX4567,Debit,2025-12-31,567,2024-12-22,Active,2024-12-15 11 | 10,10,4532XXXXXXXX8901,Credit,2025-12-31,890,2024-10-10,Active,2024-12-15 12 | -------------------------------------------------------------------------------- /lib/assets/data/customers/customers.csv: -------------------------------------------------------------------------------- 1 | customer_id,first_name,last_name,email,phone,date_of_birth,address,city,state,zipcode 2 | 1,Alice,Smith,alice.smith@example.com,123-456-7890,1990-01-01,123 Main St,New York,NY,10001 3 | 2,Bob,Johnson,bob.johnson@example.com,234-567-8901,1985-05-15,456 Oak Rd,Los Angeles,CA,90001 4 | 3,Charlie,Brown,charlie.brown@example.com,345-678-9012,1992-07-20,789 Pine Ave,Chicago,IL,60601 5 | 4,David,Williams,david.williams@example.com,456-789-0123,1988-03-12,101 Maple Ln,Houston,TX,77001 6 | 5,Eva,Taylor,eva.taylor@example.com,567-890-1234,1995-11-30,202 Elm St,Phoenix,AZ,85001 7 | 6,Frank,Lee,frank.lee@example.com,678-901-2345,1983-08-08,303 Birch Rd,Philadelphia,PA,19101 8 | 7,Grace,Kim,grace.kim@example.com,789-012-3456,1991-09-25,404 Cedar St,San Antonio,TX,78201 9 | 8,Hannah,Davis,hannah.davis@example.com,890-123-4567,1987-12-10,505 Walnut Blvd,San Diego,CA,92101 10 | 9,Ian,Thomas,ian.thomas@example.com,901-234-5678,1989-02-18,606 Spruce Dr,Dallas,TX,75201 11 | 10,Jack,White,jack.white@example.com,012-345-6789,1993-06-05,707 Aspen Way,San Francisco,CA,94101 12 | -------------------------------------------------------------------------------- /lib/assets/data/devices/devices.csv: -------------------------------------------------------------------------------- 1 | device_id,customer_id,device_type,device_os,device_model,last_login_date,is_blacklisted,fraud_score 2 | 1,1,Smartphone,iOS,iPhone 13,2024-12-15,false,0.02 3 | 2,2,Laptop,Windows,Dell XPS 15,2024-12-14,false,0.01 4 | 3,3,Tablet,Android,Samsung Tab S7,2024-12-13,true,0.85 5 | 4,4,Smartphone,Android,Samsung S21,2024-12-15,false,0.03 6 | 5,5,Laptop,macOS,MacBook Pro,2024-12-14,false,0.01 7 | 6,6,Smartphone,iOS,iPhone 12,2024-12-15,false,0.02 8 | 7,7,Tablet,iPadOS,iPad Pro,2024-12-14,false,0.01 9 | 8,8,Laptop,Windows,HP Spectre,2024-12-13,false,0.04 10 | 9,9,Smartphone,Android,Google Pixel 6,2024-12-15,false,0.02 11 | 10,10,Desktop,Windows,Custom Build,2024-12-14,false,0.01 12 | -------------------------------------------------------------------------------- /lib/assets/data/fraud_alerts/fraud_alerts.csv: -------------------------------------------------------------------------------- 1 | alert_id,transaction_id,alert_type,generated_by,alert_date,alert_status,severity_level,notes 2 | 11,187,Large Transaction,System,2024-10-28,Resolved,High,Generated alert for transaction 187 3 | 12,162,Large Transaction,System,2024-11-21,Under Review,Medium,Generated alert for transaction 162 4 | 13,144,Authentication,System,2024-11-19,Under Review,Low,Generated alert for transaction 144 5 | 14,147,Cross-border,ML Model,2024-10-01,Under Review,High,Generated alert for transaction 147 6 | 15,18,Cross-border,ML Model,2024-12-19,Open,Low,Generated alert for transaction 18 7 | 16,81,Amount Pattern,ML Model,2024-10-25,Under Review,Low,Generated alert for transaction 81 8 | 17,63,New Device,System,2024-11-16,Under Review,Low,Generated alert for transaction 63 9 | 18,37,Amount Pattern,System,2024-12-20,Under Review,Low,Generated alert for transaction 37 10 | 19,189,Large Transaction,System,2024-12-01,Under Review,Low,Generated alert for transaction 189 11 | 20,138,Amount Pattern,System,2024-11-18,Open,Low,Generated alert for transaction 138 12 | 21,206,Off-hours Activity,System,2024-12-01,Under Review,Medium,Generated alert for transaction 206 13 | 22,116,Off-hours Activity,ML Model,2024-10-23,Open,High,Generated alert for transaction 116 14 | 23,100,Card Present,ML Model,2024-12-01,Under Review,Medium,Generated alert for transaction 100 15 | 24,159,Card Present,ML Model,2024-12-05,Under Review,Low,Generated alert for transaction 159 16 | 25,103,New Device,System,2024-12-04,Resolved,Low,Generated alert for transaction 103 17 | 26,72,Large Transaction,System,2024-12-16,Open,Low,Generated alert for transaction 72 18 | 27,61,Authentication,ML Model,2024-12-01,Under Review,Low,Generated alert for transaction 61 19 | 28,72,Rapid Succession,ML Model,2024-11-07,Resolved,High,Generated alert for transaction 72 20 | 29,19,New Device,System,2024-11-26,Under Review,Low,Generated alert for transaction 19 21 | 30,156,New Device,System,2024-10-16,Open,High,Generated alert for transaction 156 22 | 31,60,Geographic Anomaly,System,2024-10-10,Open,Low,Generated alert for transaction 60 23 | 32,119,Geographic Anomaly,ML Model,2024-12-09,Under Review,Low,Generated alert for transaction 119 24 | 33,224,Large Transaction,System,2024-12-03,Open,Low,Generated alert for transaction 224 25 | 34,24,Velocity Check,System,2024-11-03,Under Review,High,Generated alert for transaction 24 26 | 35,61,Amount Pattern,System,2024-12-28,Under Review,Medium,Generated alert for transaction 61 27 | 36,227,Geographic Anomaly,ML Model,2024-12-02,Under Review,Low,Generated alert for transaction 227 28 | 37,156,New Device,System,2024-12-06,Under Review,Medium,Generated alert for transaction 156 29 | 38,174,Velocity Check,System,2024-11-24,Under Review,High,Generated alert for transaction 174 30 | 39,155,Authentication,System,2024-12-03,Open,Medium,Generated alert for transaction 155 31 | 40,213,Cross-border,System,2024-10-14,Resolved,High,Generated alert for transaction 213 32 | 41,215,Large Transaction,System,2024-11-02,Resolved,Low,Generated alert for transaction 215 33 | 42,10,Rapid Succession,System,2024-10-03,Open,Low,Generated alert for transaction 10 34 | 43,6,Rapid Succession,ML Model,2024-11-17,Open,High,Generated alert for transaction 6 35 | 44,158,Large Transaction,System,2024-10-18,Under Review,High,Generated alert for transaction 158 36 | 45,41,Off-hours Activity,ML Model,2024-10-24,Open,Low,Generated alert for transaction 41 37 | 46,177,Off-hours Activity,System,2024-11-13,Under Review,Low,Generated alert for transaction 177 38 | 47,62,Rapid Succession,ML Model,2024-12-07,Under Review,Medium,Generated alert for transaction 62 39 | 48,122,Amount Pattern,System,2024-12-21,Under Review,Medium,Generated alert for transaction 122 40 | 49,79,Authentication,System,2024-11-04,Under Review,Low,Generated alert for transaction 79 41 | 50,244,Authentication,System,2024-12-04,Under Review,Medium,Generated alert for transaction 244 42 | 51,48,Rapid Succession,ML Model,2024-10-22,Under Review,High,Generated alert for transaction 48 43 | 52,95,Card Present,ML Model,2024-12-13,Under Review,Low,Generated alert for transaction 95 44 | 53,16,Off-hours Activity,ML Model,2024-12-18,Open,Low,Generated alert for transaction 16 45 | 54,134,New Device,System,2024-11-19,Resolved,Low,Generated alert for transaction 134 46 | 55,50,Amount Pattern,System,2024-10-26,Under Review,Low,Generated alert for transaction 50 47 | 56,52,Rapid Succession,ML Model,2024-10-18,Open,High,Generated alert for transaction 52 48 | 57,90,Rapid Succession,ML Model,2024-12-13,Resolved,Low,Generated alert for transaction 90 49 | 58,216,Rapid Succession,ML Model,2024-11-05,Under Review,Low,Generated alert for transaction 216 50 | 59,17,New Device,System,2024-12-08,Under Review,Low,Generated alert for transaction 17 51 | 60,166,Off-hours Activity,ML Model,2024-11-05,Open,High,Generated alert for transaction 166 52 | 61,96,Cross-border,ML Model,2024-11-19,Under Review,Low,Generated alert for transaction 96 53 | 62,14,Amount Pattern,ML Model,2024-10-25,Resolved,Low,Generated alert for transaction 14 54 | 63,225,New Device,System,2024-12-12,Resolved,Low,Generated alert for transaction 225 55 | 64,18,Rapid Succession,ML Model,2024-11-28,Under Review,Medium,Generated alert for transaction 18 56 | 65,18,Off-hours Activity,ML Model,2024-12-07,Under Review,Low,Generated alert for transaction 18 57 | 66,164,Card Present,ML Model,2024-11-11,Under Review,High,Generated alert for transaction 164 58 | 67,143,Off-hours Activity,ML Model,2024-10-18,Open,Medium,Generated alert for transaction 143 59 | 68,121,Off-hours Activity,ML Model,2024-10-02,Open,High,Generated alert for transaction 121 60 | 69,113,New Device,System,2024-10-23,Open,High,Generated alert for transaction 113 61 | 70,129,Cross-border,System,2024-10-28,Under Review,High,Generated alert for transaction 129 62 | 71,55,Amount Pattern,ML Model,2024-10-17,Resolved,High,Generated alert for transaction 55 63 | 72,65,New Device,System,2024-12-09,Open,Medium,Generated alert for transaction 65 64 | 73,240,Off-hours Activity,ML Model,2024-10-05,Open,Low,Generated alert for transaction 240 65 | 74,40,Velocity Check,System,2024-10-14,Resolved,High,Generated alert for transaction 40 66 | 75,65,Off-hours Activity,ML Model,2024-10-05,Under Review,High,Generated alert for transaction 65 67 | 76,137,Velocity Check,System,2024-12-04,Under Review,Low,Generated alert for transaction 137 68 | 77,102,Velocity Check,System,2024-11-12,Resolved,High,Generated alert for transaction 102 69 | 78,215,Large Transaction,System,2024-12-06,Under Review,Low,Generated alert for transaction 215 70 | 79,53,Velocity Check,ML Model,2024-10-08,Under Review,High,Generated alert for transaction 53 71 | 80,90,Rapid Succession,System,2024-12-01,Resolved,Low,Generated alert for transaction 90 72 | 81,242,Card Present,ML Model,2024-11-11,Under Review,Low,Generated alert for transaction 242 73 | 82,181,Cross-border,System,2024-11-21,Open,High,Generated alert for transaction 181 74 | 83,114,Geographic Anomaly,System,2024-12-07,Resolved,Low,Generated alert for transaction 114 75 | 84,41,New Device,System,2024-10-16,Open,Medium,Generated alert for transaction 41 76 | 85,140,Authentication,System,2024-10-13,Open,High,Generated alert for transaction 140 77 | 86,174,Amount Pattern,System,2024-10-02,Open,Low,Generated alert for transaction 174 78 | 87,146,Cross-border,ML Model,2024-11-02,Under Review,Low,Generated alert for transaction 146 79 | 88,90,Large Transaction,System,2024-11-21,Resolved,Low,Generated alert for transaction 90 80 | 89,246,Rapid Succession,ML Model,2024-12-14,Open,Low,Generated alert for transaction 246 81 | 90,21,Rapid Succession,ML Model,2024-11-04,Resolved,Low,Generated alert for transaction 21 82 | 91,74,Amount Pattern,ML Model,2024-12-26,Under Review,Low,Generated alert for transaction 74 83 | 92,213,Rapid Succession,System,2024-12-22,Under Review,Medium,Generated alert for transaction 213 84 | 93,61,Geographic Anomaly,System,2024-12-20,Resolved,High,Generated alert for transaction 61 85 | 94,106,Cross-border,ML Model,2024-10-20,Open,High,Generated alert for transaction 106 86 | 95,93,Cross-border,ML Model,2024-11-07,Under Review,High,Generated alert for transaction 93 87 | 96,78,Large Transaction,ML Model,2024-11-07,Under Review,Low,Generated alert for transaction 78 88 | 97,94,Off-hours Activity,System,2024-12-02,Under Review,Medium,Generated alert for transaction 94 89 | 98,242,Card Present,ML Model,2024-10-22,Open,Low,Generated alert for transaction 242 90 | 99,20,Off-hours Activity,ML Model,2024-12-24,Under Review,Low,Generated alert for transaction 20 91 | 100,186,Large Transaction,System,2024-11-22,Under Review,Low,Generated alert for transaction 186 92 | -------------------------------------------------------------------------------- /lib/assets/data/locations/locations.csv: -------------------------------------------------------------------------------- 1 | location_id,transaction_id,country,city,state,zipcode 2 | 1,1,USA,New York,NY,10001 3 | 2,2,USA,Los Angeles,CA,90001 4 | 3,3,USA,Chicago,IL,60601 5 | 4,4,USA,Houston,TX,77001 6 | 5,5,USA,Phoenix,AZ,85001 7 | 6,6,USA,Philadelphia,PA,19101 8 | 7,7,USA,San Antonio,TX,78201 9 | 8,8,USA,San Diego,CA,92101 10 | 9,9,USA,Dallas,TX,75201 11 | 10,10,USA,San Francisco,CA,94101 12 | -------------------------------------------------------------------------------- /lib/assets/data/merchants/merchants.csv: -------------------------------------------------------------------------------- 1 | merchant_id,merchant_name,category,address,city,state,zipcode,country 2 | 1,QuickMart,E-commerce,123 Tech Lane,Springfield,IL,62704,USA 3 | 2,SuperValue,Retail,456 Market Rd,Fairview,CA,94536,USA 4 | 3,Brew Haven,Coffee Shop,789 Coffee Blvd,Riverside,TX,77320,USA 5 | 4,TechSphere,Electronics,101 Innovation Way,Havenport,NY,10018,USA 6 | 5,ActiveEdge,Sportswear,202 Sporty Dr,Evergreen,CO,80439,USA 7 | 6,FoodCo,Restaurant,303 Food Court,Miami,FL,33101,USA 8 | 7,TechStore,Electronics,404 Tech Ave,Seattle,WA,98101,USA 9 | 8,BookWorld,Retail,505 Reader St,Boston,MA,02101,USA 10 | 9,SportZone,Sports,606 Athletic Dr,Denver,CO,80201,USA 11 | 10,HomeGoods,Home Improvement,707 Home St,Portland,OR,97201,USA 12 | -------------------------------------------------------------------------------- /lib/assets/data/rules_engine/rules_engine.csv: -------------------------------------------------------------------------------- 1 | rule_id,rule_name,rule_description,severity_level,created_date,modified_date,is_active,last_reviewed 2 | 1,Large Transaction,Flags transactions over $10000,High,2024-10-01,2024-12-01,true,2024-12-15 3 | 2,Rapid Succession,Multiple transactions within 5 minutes,Medium,2024-11-01,2024-12-01,true,2024-12-15 4 | 3,Geographic Anomaly,Transactions from multiple countries,High,2024-12-01,2024-12-01,true,2024-12-15 5 | 4,Off-hours Activity,Transactions between 1AM-4AM,Low,2024-10-01,2024-12-01,false,2024-12-15 6 | 5,Velocity Check,Transaction frequency monitoring,Medium,2024-11-01,2024-12-01,true,2024-12-15 7 | 6,Amount Pattern,Structured transactions,High,2024-12-01,2024-12-01,true,2024-12-15 8 | 7,New Device,First-time device usage,Medium,2024-10-01,2024-12-01,true,2024-12-15 9 | 8,Cross-border,International transactions,High,2024-11-01,2024-12-01,true,2024-12-15 10 | 9,Authentication,3D Secure failures,Critical,2024-12-01,2024-12-01,true,2024-12-15 11 | 10,Card Present,Unusual in-person usage,Medium,2024-10-01,2024-12-01,true,2024-12-15 12 | -------------------------------------------------------------------------------- /lib/assets/data/suspicious_patterns/suspicious_patterns.csv: -------------------------------------------------------------------------------- 1 | pattern_id,transaction_id,pattern_type,pattern_description,severity_level,date_detected,is_resolved,resolved_date,resolved_by,comments 2 | 11,177,Velocity Check,Suspicious pattern detected for Velocity Check,High,2024-11-25,false,,,Generated suspicious pattern for transaction 177 3 | 12,194,Cross-border,Suspicious pattern detected for Cross-border,Low,2024-12-15,false,,,Generated suspicious pattern for transaction 194 4 | 13,91,Geographic Anomaly,Suspicious pattern detected for Geographic Anomaly,High,2024-12-23,false,,,Generated suspicious pattern for transaction 91 5 | 14,170,Cross-border,Suspicious pattern detected for Cross-border,High,2024-11-14,true,2024-10-19,Fraud Team,Generated suspicious pattern for transaction 170 6 | 15,225,Authentication,Suspicious pattern detected for Authentication,Low,2024-11-13,false,,,Generated suspicious pattern for transaction 225 7 | 16,41,Authentication,Suspicious pattern detected for Authentication,High,2024-11-19,false,,,Generated suspicious pattern for transaction 41 8 | 17,214,Off-hours Activity,Suspicious pattern detected for Off-hours Activity,High,2024-11-28,true,2024-10-06,Fraud Team,Generated suspicious pattern for transaction 214 9 | 18,249,Cross-border,Suspicious pattern detected for Cross-border,Low,2024-11-18,true,2024-11-23,Fraud Team,Generated suspicious pattern for transaction 249 10 | 19,48,Off-hours Activity,Suspicious pattern detected for Off-hours Activity,High,2024-10-01,true,2024-10-06,Fraud Team,Generated suspicious pattern for transaction 48 11 | 20,28,Card Present,Suspicious pattern detected for Card Present,High,2024-11-25,true,2024-10-02,Fraud Team,Generated suspicious pattern for transaction 28 12 | 21,37,Large Transaction,Suspicious pattern detected for Large Transaction,High,2024-10-17,false,,,Generated suspicious pattern for transaction 37 13 | 22,240,Amount Pattern,Suspicious pattern detected for Amount Pattern,Low,2024-11-17,true,2024-11-22,Fraud Team,Generated suspicious pattern for transaction 240 14 | 23,250,Amount Pattern,Suspicious pattern detected for Amount Pattern,Low,2024-11-04,true,2024-11-09,Fraud Team,Generated suspicious pattern for transaction 250 15 | 24,62,Authentication,Suspicious pattern detected for Authentication,Medium,2024-11-04,false,,,Generated suspicious pattern for transaction 62 16 | 25,18,Amount Pattern,Suspicious pattern detected for Amount Pattern,Low,2024-10-25,true,2024-10-02,Fraud Team,Generated suspicious pattern for transaction 18 17 | 26,127,Large Transaction,Suspicious pattern detected for Large Transaction,Low,2024-11-19,false,,,Generated suspicious pattern for transaction 127 18 | 27,225,New Device,Suspicious pattern detected for New Device,Low,2024-12-11,false,,,Generated suspicious pattern for transaction 225 19 | 28,36,Large Transaction,Suspicious pattern detected for Large Transaction,Low,2024-11-23,false,,,Generated suspicious pattern for transaction 36 20 | 29,172,Cross-border,Suspicious pattern detected for Cross-border,Low,2024-11-15,true,2024-11-20,Fraud Team,Generated suspicious pattern for transaction 172 21 | 30,102,Rapid Succession,Suspicious pattern detected for Rapid Succession,High,2024-10-07,true,2024-10-12,Fraud Team,Generated suspicious pattern for transaction 102 22 | 31,99,Velocity Check,Suspicious pattern detected for Velocity Check,Low,2024-11-01,false,,,Generated suspicious pattern for transaction 99 23 | 32,37,Card Present,Suspicious pattern detected for Card Present,Low,2024-11-27,false,,,Generated suspicious pattern for transaction 37 24 | 33,202,Large Transaction,Suspicious pattern detected for Large Transaction,High,2024-12-10,true,2024-12-15,Fraud Team,Generated suspicious pattern for transaction 202 25 | 34,207,Cross-border,Suspicious pattern detected for Cross-border,Low,2024-12-07,true,2024-12-12,Fraud Team,Generated suspicious pattern for transaction 207 26 | 35,27,Cross-border,Suspicious pattern detected for Cross-border,Low,2024-10-20,true,2024-10-25,Fraud Team,Generated suspicious pattern for transaction 27 27 | 36,179,Rapid Succession,Suspicious pattern detected for Rapid Succession,Low,2024-10-03,false,,,Generated suspicious pattern for transaction 179 28 | 37,158,Large Transaction,Suspicious pattern detected for Large Transaction,Low,2024-12-20,true,2024-12-26,Fraud Team,Generated suspicious pattern for transaction 158 29 | 38,28,Authentication,Suspicious pattern detected for Authentication,High,2024-10-24,false,,,Generated suspicious pattern for transaction 28 30 | 39,120,Authentication,Suspicious pattern detected for Authentication,Low,2024-10-19,false,,,Generated suspicious pattern for transaction 120 31 | 40,23,Geographic Anomaly,Suspicious pattern detected for Geographic Anomaly,Low,2024-10-21,false,,,Generated suspicious pattern for transaction 23 32 | 41,60,Large Transaction,Suspicious pattern detected for Large Transaction,Low,2024-11-12,false,,,Generated suspicious pattern for transaction 60 33 | 42,69,Large Transaction,Suspicious pattern detected for Large Transaction,High,2024-11-03,false,,,Generated suspicious pattern for transaction 69 34 | 43,234,Geographic Anomaly,Suspicious pattern detected for Geographic Anomaly,Medium,2024-12-02,false,,,Generated suspicious pattern for transaction 234 35 | 44,68,Authentication,Suspicious pattern detected for Authentication,Medium,2024-11-27,false,,,Generated suspicious pattern for transaction 68 36 | 45,57,New Device,Suspicious pattern detected for New Device,Low,2024-12-25,false,,,Generated suspicious pattern for transaction 57 37 | 46,178,Off-hours Activity,Suspicious pattern detected for Off-hours Activity,Low,2024-11-23,true,2024-11-28,Fraud Team,Generated suspicious pattern for transaction 178 38 | 47,245,Large Transaction,Suspicious pattern detected for Large Transaction,Low,2024-12-28,false,,,Generated suspicious pattern for transaction 245 39 | 48,57,Amount Pattern,Suspicious pattern detected for Amount Pattern,Medium,2024-12-28,true,2024-11-05,Fraud Team,Generated suspicious pattern for transaction 57 40 | 49,43,Geographic Anomaly,Suspicious pattern detected for Geographic Anomaly,Low,2024-11-25,false,,,Generated suspicious pattern for transaction 43 41 | 50,104,Cross-border,Suspicious pattern detected for Cross-border,Medium,2024-12-05,true,2024-11-10,Fraud Team,Generated suspicious pattern for transaction 104 42 | 51,132,New Device,Suspicious pattern detected for New Device,Low,2024-11-22,false,,,Generated suspicious pattern for transaction 132 43 | 52,96,Geographic Anomaly,Suspicious pattern detected for Geographic Anomaly,High,2024-10-11,true,2024-10-16,Fraud Team,Generated suspicious pattern for transaction 96 44 | 53,202,New Device,Suspicious pattern detected for New Device,High,2024-10-12,false,,,Generated suspicious pattern for transaction 202 45 | 54,201,Large Transaction,Suspicious pattern detected for Large Transaction,Medium,2024-11-09,false,,,Generated suspicious pattern for transaction 201 46 | 55,220,Off-hours Activity,Suspicious pattern detected for Off-hours Activity,Low,2024-12-05,true,2024-12-02,Fraud Team,Generated suspicious pattern for transaction 220 47 | 56,13,Amount Pattern,Suspicious pattern detected for Amount Pattern,Low,2024-10-01,true,2024-12-06,Fraud Team,Generated suspicious pattern for transaction 13 48 | 57,78,Geographic Anomaly,Suspicious pattern detected for Geographic Anomaly,High,2024-10-21,false,,,Generated suspicious pattern for transaction 78 49 | 58,229,Amount Pattern,Suspicious pattern detected for Amount Pattern,High,2024-12-12,true,2024-12-18,Fraud Team,Generated suspicious pattern for transaction 229 50 | 59,165,Off-hours Activity,Suspicious pattern detected for Off-hours Activity,Medium,2024-12-08,true,2024-11-14,Fraud Team,Generated suspicious pattern for transaction 165 51 | 60,106,Geographic Anomaly,Suspicious pattern detected for Geographic Anomaly,Low,2024-11-22,true,2024-11-27,Fraud Team,Generated suspicious pattern for transaction 106 52 | 61,237,Amount Pattern,Suspicious pattern detected for Amount Pattern,High,2024-10-14,true,2024-12-19,Fraud Team,Generated suspicious pattern for transaction 237 53 | 62,5,Velocity Check,Suspicious pattern detected for Velocity Check,Low,2024-11-28,false,,,Generated suspicious pattern for transaction 5 54 | 63,96,Authentication,Suspicious pattern detected for Authentication,High,2024-11-14,false,,,Generated suspicious pattern for transaction 96 55 | 64,33,Rapid Succession,Suspicious pattern detected for Rapid Succession,Low,2024-12-08,true,2024-12-13,Fraud Team,Generated suspicious pattern for transaction 33 56 | 65,78,Authentication,Suspicious pattern detected for Authentication,Low,2024-11-08,false,,,Generated suspicious pattern for transaction 78 57 | 66,120,Amount Pattern,Suspicious pattern detected for Amount Pattern,Low,2024-12-08,true,2024-12-05,Fraud Team,Generated suspicious pattern for transaction 120 58 | 67,158,Rapid Succession,Suspicious pattern detected for Rapid Succession,High,2024-10-02,true,2024-12-07,Fraud Team,Generated suspicious pattern for transaction 158 59 | 68,228,Authentication,Suspicious pattern detected for Authentication,High,2024-12-25,false,,,Generated suspicious pattern for transaction 228 60 | 69,20,Card Present,Suspicious pattern detected for Card Present,Low,2024-11-12,true,2024-11-17,Fraud Team,Generated suspicious pattern for transaction 20 61 | 70,112,Amount Pattern,Suspicious pattern detected for Amount Pattern,Medium,2024-12-19,true,2024-11-24,Fraud Team,Generated suspicious pattern for transaction 112 62 | 71,162,Amount Pattern,Suspicious pattern detected for Amount Pattern,Medium,2024-11-24,false,,,Generated suspicious pattern for transaction 162 63 | 72,194,New Device,Suspicious pattern detected for New Device,High,2024-11-24,false,,,Generated suspicious pattern for transaction 194 64 | 73,88,Rapid Succession,Suspicious pattern detected for Rapid Succession,Medium,2024-11-23,true,2024-11-28,Fraud Team,Generated suspicious pattern for transaction 88 65 | 74,106,Card Present,Suspicious pattern detected for Card Present,Medium,2024-11-04,true,2024-11-09,Fraud Team,Generated suspicious pattern for transaction 106 66 | 75,238,Rapid Succession,Suspicious pattern detected for Rapid Succession,Low,2024-11-10,true,2024-11-15,Fraud Team,Generated suspicious pattern for transaction 238 67 | 76,3,Rapid Succession,Suspicious pattern detected for Rapid Succession,High,2024-10-25,true,2024-12-02,Fraud Team,Generated suspicious pattern for transaction 3 68 | 77,107,Cross-border,Suspicious pattern detected for Cross-border,Medium,2024-11-20,false,,,Generated suspicious pattern for transaction 107 69 | 78,25,Card Present,Suspicious pattern detected for Card Present,Medium,2024-10-28,true,2024-10-05,Fraud Team,Generated suspicious pattern for transaction 25 70 | 79,81,Amount Pattern,Suspicious pattern detected for Amount Pattern,Low,2024-10-05,true,2024-12-10,Fraud Team,Generated suspicious pattern for transaction 81 71 | 80,29,Card Present,Suspicious pattern detected for Card Present,High,2024-12-06,false,,,Generated suspicious pattern for transaction 29 72 | 81,67,Velocity Check,Suspicious pattern detected for Velocity Check,Medium,2024-11-18,false,,,Generated suspicious pattern for transaction 67 73 | 82,15,Card Present,Suspicious pattern detected for Card Present,Medium,2024-10-10,false,,,Generated suspicious pattern for transaction 15 74 | 83,143,Large Transaction,Suspicious pattern detected for Large Transaction,Medium,2024-11-13,false,,,Generated suspicious pattern for transaction 143 75 | 84,195,New Device,Suspicious pattern detected for New Device,Low,2024-12-19,false,,,Generated suspicious pattern for transaction 195 76 | 85,45,Velocity Check,Suspicious pattern detected for Velocity Check,Medium,2024-12-06,false,,,Generated suspicious pattern for transaction 45 77 | 86,175,Large Transaction,Suspicious pattern detected for Large Transaction,High,2024-10-04,false,,,Generated suspicious pattern for transaction 175 78 | 87,185,Rapid Succession,Suspicious pattern detected for Rapid Succession,Low,2024-12-21,true,2024-11-26,Fraud Team,Generated suspicious pattern for transaction 185 79 | 88,7,Cross-border,Suspicious pattern detected for Cross-border,Medium,2024-11-26,true,2024-10-04,Fraud Team,Generated suspicious pattern for transaction 7 80 | 89,127,Amount Pattern,Suspicious pattern detected for Amount Pattern,Medium,2024-11-09,true,2024-11-14,Fraud Team,Generated suspicious pattern for transaction 127 81 | 90,198,Off-hours Activity,Suspicious pattern detected for Off-hours Activity,Medium,2024-11-06,true,2024-11-11,Fraud Team,Generated suspicious pattern for transaction 198 82 | 91,191,Rapid Succession,Suspicious pattern detected for Rapid Succession,Low,2024-10-17,true,2024-10-22,Fraud Team,Generated suspicious pattern for transaction 191 83 | 92,193,Authentication,Suspicious pattern detected for Authentication,High,2024-12-02,false,,,Generated suspicious pattern for transaction 193 84 | 93,3,Velocity Check,Suspicious pattern detected for Velocity Check,Medium,2024-12-18,false,,,Generated suspicious pattern for transaction 3 85 | 94,39,Cross-border,Suspicious pattern detected for Cross-border,Medium,2024-10-17,true,2024-10-22,Fraud Team,Generated suspicious pattern for transaction 39 86 | 95,47,Amount Pattern,Suspicious pattern detected for Amount Pattern,Low,2024-11-19,true,2024-10-24,Fraud Team,Generated suspicious pattern for transaction 47 87 | 96,87,Rapid Succession,Suspicious pattern detected for Rapid Succession,High,2024-10-05,true,2024-12-10,Fraud Team,Generated suspicious pattern for transaction 87 88 | 97,126,Geographic Anomaly,Suspicious pattern detected for Geographic Anomaly,High,2024-11-01,false,,,Generated suspicious pattern for transaction 126 89 | 98,91,Geographic Anomaly,Suspicious pattern detected for Geographic Anomaly,Medium,2024-10-12,false,,,Generated suspicious pattern for transaction 91 90 | 99,114,Velocity Check,Suspicious pattern detected for Velocity Check,Low,2024-10-24,false,,,Generated suspicious pattern for transaction 114 91 | 100,29,Cross-border,Suspicious pattern detected for Cross-border,High,2024-10-06,true,2024-10-11,Fraud Team,Generated suspicious pattern for transaction 29 92 | 101,142,Amount Pattern,Suspicious pattern detected for Amount Pattern,High,2024-12-28,true,2024-12-05,Fraud Team,Generated suspicious pattern for transaction 142 93 | 102,185,Large Transaction,Suspicious pattern detected for Large Transaction,Medium,2024-11-09,false,,,Generated suspicious pattern for transaction 185 94 | 103,185,New Device,Suspicious pattern detected for New Device,High,2024-10-19,false,,,Generated suspicious pattern for transaction 185 95 | 104,31,Authentication,Suspicious pattern detected for Authentication,Medium,2024-11-03,false,,,Generated suspicious pattern for transaction 31 96 | 105,158,Cross-border,Suspicious pattern detected for Cross-border,Low,2024-10-21,true,2024-12-26,Fraud Team,Generated suspicious pattern for transaction 158 97 | 106,108,Large Transaction,Suspicious pattern detected for Large Transaction,Low,2024-10-05,false,,,Generated suspicious pattern for transaction 108 98 | 107,163,Card Present,Suspicious pattern detected for Card Present,Low,2024-12-26,false,,,Generated suspicious pattern for transaction 163 99 | 108,225,New Device,Suspicious pattern detected for New Device,Medium,2024-10-23,false,,,Generated suspicious pattern for transaction 225 100 | 109,237,New Device,Suspicious pattern detected for New Device,Low,2024-11-18,false,,,Generated suspicious pattern for transaction 237 101 | 110,220,Authentication,Suspicious pattern detected for Authentication,Low,2024-11-20,false,,,Generated suspicious pattern for transaction 220 102 | 111,162,Cross-border,Suspicious pattern detected for Cross-border,Medium,2024-11-05,true,2024-10-10,Fraud Team,Generated suspicious pattern for transaction 162 103 | 112,226,Card Present,Suspicious pattern detected for Card Present,Medium,2024-11-26,true,2024-11-03,Fraud Team,Generated suspicious pattern for transaction 226 104 | 113,80,Authentication,Suspicious pattern detected for Authentication,Low,2024-10-22,false,,,Generated suspicious pattern for transaction 80 105 | 114,2,Off-hours Activity,Suspicious pattern detected for Off-hours Activity,Medium,2024-12-18,true,2024-12-15,Fraud Team,Generated suspicious pattern for transaction 2 106 | 115,170,Geographic Anomaly,Suspicious pattern detected for Geographic Anomaly,High,2024-10-06,false,,,Generated suspicious pattern for transaction 170 107 | 116,63,Geographic Anomaly,Suspicious pattern detected for Geographic Anomaly,High,2024-10-06,false,,,Generated suspicious pattern for transaction 63 108 | 117,226,Cross-border,Suspicious pattern detected for Cross-border,High,2024-12-11,true,2024-12-16,Fraud Team,Generated suspicious pattern for transaction 226 109 | 118,114,Off-hours Activity,Suspicious pattern detected for Off-hours Activity,High,2024-10-03,true,2024-10-08,Fraud Team,Generated suspicious pattern for transaction 114 110 | 119,62,Geographic Anomaly,Suspicious pattern detected for Geographic Anomaly,High,2024-10-06,false,,,Generated suspicious pattern for transaction 62 111 | 120,163,Cross-border,Suspicious pattern detected for Cross-border,Low,2024-10-15,true,2024-10-20,Fraud Team,Generated suspicious pattern for transaction 163 112 | 121,242,Cross-border,Suspicious pattern detected for Cross-border,High,2024-11-11,true,2024-10-16,Fraud Team,Generated suspicious pattern for transaction 242 113 | 122,34,Card Present,Suspicious pattern detected for Card Present,High,2024-10-03,true,2024-10-08,Fraud Team,Generated suspicious pattern for transaction 34 114 | 123,51,Authentication,Suspicious pattern detected for Authentication,High,2024-12-19,true,2024-12-24,Fraud Team,Generated suspicious pattern for transaction 51 115 | 124,194,Authentication,Suspicious pattern detected for Authentication,High,2024-11-25,false,,,Generated suspicious pattern for transaction 194 116 | 125,67,Card Present,Suspicious pattern detected for Card Present,Low,2024-10-20,true,2024-10-25,Fraud Team,Generated suspicious pattern for transaction 67 117 | 126,230,Amount Pattern,Suspicious pattern detected for Amount Pattern,High,2024-12-18,true,2024-12-23,Fraud Team,Generated suspicious pattern for transaction 230 118 | 127,250,Amount Pattern,Suspicious pattern detected for Amount Pattern,High,2024-10-18,true,2024-10-24,Fraud Team,Generated suspicious pattern for transaction 250 119 | 128,213,Velocity Check,Suspicious pattern detected for Velocity Check,High,2024-11-07,false,,,Generated suspicious pattern for transaction 213 120 | 129,225,Rapid Succession,Suspicious pattern detected for Rapid Succession,Medium,2024-11-21,true,2024-10-26,Fraud Team,Generated suspicious pattern for transaction 225 121 | 130,235,Large Transaction,Suspicious pattern detected for Large Transaction,High,2024-12-14,false,,,Generated suspicious pattern for transaction 235 122 | 131,148,Amount Pattern,Suspicious pattern detected for Amount Pattern,Low,2024-12-03,true,2024-11-08,Fraud Team,Generated suspicious pattern for transaction 148 123 | 132,104,Cross-border,Suspicious pattern detected for Cross-border,Medium,2024-10-18,true,2024-10-23,Fraud Team,Generated suspicious pattern for transaction 104 124 | 133,61,Rapid Succession,Suspicious pattern detected for Rapid Succession,Low,2024-12-10,true,2024-12-15,Fraud Team,Generated suspicious pattern for transaction 61 125 | 134,156,Card Present,Suspicious pattern detected for Card Present,Low,2024-11-21,true,2024-10-26,Fraud Team,Generated suspicious pattern for transaction 156 126 | 135,127,New Device,Suspicious pattern detected for New Device,Low,2024-12-17,false,,,Generated suspicious pattern for transaction 127 127 | 136,229,Amount Pattern,Suspicious pattern detected for Amount Pattern,Medium,2024-11-22,true,2024-11-28,Fraud Team,Generated suspicious pattern for transaction 229 128 | 137,101,Velocity Check,Suspicious pattern detected for Velocity Check,Low,2024-11-03,false,,,Generated suspicious pattern for transaction 101 129 | 138,53,Velocity Check,Suspicious pattern detected for Velocity Check,High,2024-10-19,false,,,Generated suspicious pattern for transaction 53 130 | 139,15,Amount Pattern,Suspicious pattern detected for Amount Pattern,Medium,2024-10-20,true,2024-12-25,Fraud Team,Generated suspicious pattern for transaction 15 131 | 140,208,Off-hours Activity,Suspicious pattern detected for Off-hours Activity,High,2024-10-02,true,2024-10-07,Fraud Team,Generated suspicious pattern for transaction 208 132 | 141,71,Authentication,Suspicious pattern detected for Authentication,High,2024-12-25,true,2024-12-03,Fraud Team,Generated suspicious pattern for transaction 71 133 | 142,110,Velocity Check,Suspicious pattern detected for Velocity Check,High,2024-10-28,false,,,Generated suspicious pattern for transaction 110 134 | 143,69,Rapid Succession,Suspicious pattern detected for Rapid Succession,Medium,2024-10-13,true,2024-10-18,Fraud Team,Generated suspicious pattern for transaction 69 135 | 144,118,Geographic Anomaly,Suspicious pattern detected for Geographic Anomaly,Low,2024-12-11,false,,,Generated suspicious pattern for transaction 118 136 | 145,102,Amount Pattern,Suspicious pattern detected for Amount Pattern,Low,2024-11-23,true,2024-11-28,Fraud Team,Generated suspicious pattern for transaction 102 137 | 146,220,Geographic Anomaly,Suspicious pattern detected for Geographic Anomaly,Low,2024-10-20,false,,,Generated suspicious pattern for transaction 220 138 | 147,69,Large Transaction,Suspicious pattern detected for Large Transaction,Low,2024-12-19,false,,,Generated suspicious pattern for transaction 69 139 | 148,8,Card Present,Suspicious pattern detected for Card Present,Medium,2024-10-14,true,2024-10-19,Fraud Team,Generated suspicious pattern for transaction 8 140 | 149,212,Amount Pattern,Suspicious pattern detected for Amount Pattern,High,2024-12-19,true,2024-12-24,Fraud Team,Generated suspicious pattern for transaction 212 141 | 150,150,Large Transaction,Suspicious pattern detected for Large Transaction,Low,2024-11-14,false,,,Generated suspicious pattern for transaction 150 142 | -------------------------------------------------------------------------------- /lib/assets/data/transaction_history/transaction_history.csv: -------------------------------------------------------------------------------- 1 | history_id,transaction_id,previous_balance,new_balance,transaction_date,transaction_time,is_fraud,fraud_check_level,processed_by,review_status,review_date,reviewer_comments 2 | 11,11,1029.46,1016.34,2024-12-16,17:10:36,true,High,System,Flagged,2024-11-04,Generated comment for transaction 11 3 | 12,12,1020.80,1008.54,2024-12-28,04:14:14,false,Enhanced,AI Model,Flagged,2024-11-16,Generated comment for transaction 12 4 | 13,13,1012.14,1000.75,2024-11-21,08:18:51,false,High,AI Model,Flagged,2024-11-28,Generated comment for transaction 13 5 | 14,14,1003.48,992.95,2024-12-05,11:22:29,false,Enhanced,System,Flagged,2024-10-20,Generated comment for transaction 14 6 | 15,15,1027.59,1014.65,2024-12-17,22:27:06,false,High,AI Model,Under Review,2024-11-05,Generated comment for transaction 15 7 | 16,16,1018.93,1006.86,2024-12-01,01:31:44,false,High,System,Flagged,2024-11-17,Generated comment for transaction 16 8 | 17,17,1010.26,999.06,2024-11-14,05:43:21,true,High,AI Model,Flagged,2024-11-01,Generated comment for transaction 17 9 | 18,18,1001.60,991.26,2024-11-26,08:47:59,true,High,AI Model,Under Review,2024-10-14,Generated comment for transaction 18 10 | 19,19,1025.71,1012.96,2024-12-10,19:52:36,false,High,System,Approved,, 11 | 20,20,1000.21,990.01,2024-12-24,08:45:08,false,High,AI Model,Flagged,2024-10-11,Generated comment for transaction 20 12 | 21,21,1024.32,1011.71,2024-12-08,19:50:46,false,Enhanced,System,Approved,, 13 | 22,22,1031.59,1021.53,2024-12-22,08:35:18,false,High,AI Model,Under Review,2024-10-09,Generated comment for transaction 22 14 | 23,23,1022.93,1010.46,2024-12-06,19:48:47,false,High,System,Approved,, 15 | 24,24,1030.20,1017.00,2024-12-20,08:33:19,false,High,AI Model,Flagged,2024-11-07,Generated comment for transaction 24 16 | 25,25,1021.54,1009.21,2024-12-04,19:37:56,false,Enhanced,System,Flagged,2024-11-19,Generated comment for transaction 25 17 | 26,26,1012.87,1001.41,2024-12-16,22:50:34,false,High,AI Model,Under Review,2024-11-04,Generated comment for transaction 26 18 | 27,27,1004.21,993.61,2024-11-28,02:54:11,true,High,AI Model,Under Review,2024-10-16,Generated comment for transaction 27 19 | 28,28,1028.32,1015.31,2024-12-13,05:58:49,false,High,System,Flagged,2024-10-28,Generated comment for transaction 28 20 | 29,29,1019.66,1007.52,2024-12-05,16:02:27,false,High,AI Model,Approved,, 21 | 30,30,1026.93,1014.06,2024-12-11,13:56:58,false,Enhanced,System,Under Review,2024-11-26,Generated comment for transaction 30 22 | 31,31,1018.27,1006.27,2024-12-23,16:00:36,false,High,AI Model,Approved,, 23 | 32,32,1025.54,1012.81,2024-12-08,13:46:08,false,High,System,Approved,, 24 | 33,33,1000.04,989.86,2024-12-22,02:40:39,false,High,AI Model,Flagged,2024-11-10,Generated comment for transaction 33 25 | 34,34,1024.15,1011.56,2024-12-06,13:44:17,false,Enhanced,System,Approved,, 26 | 35,35,1031.41,1021.37,2024-12-12,02:38:49,false,Enhanced,AI Model,Flagged,2024-11-28,Generated comment for transaction 35 27 | 36,36,1022.75,1010.30,2024-12-04,13:42:26,false,High,System,Under Review,2024-11-20,Generated comment for transaction 36 28 | 37,37,1014.09,1002.50,2024-12-16,17:46:04,true,High,AI Model,Flagged,2024-11-04,Generated comment for transaction 37 29 | 38,38,1005.43,994.71,2024-11-01,20:50:33,false,High,AI Model,Under Review,2024-10-16,Generated comment for transaction 38 30 | 39,39,1029.54,1016.41,2024-12-13,23:03:11,false,High,System,Flagged,2024-10-01,Generated comment for transaction 39 31 | 40,40,1020.88,1008.61,2024-12-25,10:07:48,false,High,AI Model,Approved,, 32 | 41,41,1012.22,1000.82,2024-11-10,13:11:26,false,Enhanced,System,Under Review,2024-11-25,Generated comment for transaction 41 33 | 42,42,1003.56,993.03,2024-11-02,17:15:04,false,High,System,Flagged,2024-10-09,Generated comment for transaction 42 34 | 43,43,1027.66,1014.72,2024-11-14,04:20:41,false,Enhanced,AI Model,Flagged,2024-10-02,Generated comment for transaction 43 35 | 44,44,1019.00,1006.92,2024-12-26,07:24:19,true,High,System,Approved,, 36 | 45,45,1026.27,1013.47,2024-12-12,04:18:50,true,High,AI Model,Approved,, 37 | 46,46,1000.77,990.52,2024-12-18,17:11:22,false,Enhanced,System,Under Review,2024-10-05,Generated comment for transaction 46 38 | 47,47,1024.88,1012.21,2024-12-02,04:15:00,false,High,AI Model,Approved,, 39 | 48,48,1032.15,1022.03,2024-12-15,17:01:31,false,High,System,Flagged,2024-10-03,Generated comment for transaction 48 40 | 49,49,1023.49,1010.96,2024-12-28,04:13:09,false,Enhanced,AI Model,Approved,, 41 | 50,50,1030.76,1017.51,2024-12-13,17:59:41,false,Enhanced,System,Flagged,2024-11-01,Generated comment for transaction 50 42 | 51,51,1022.10,1009.71,2024-12-26,04:03:18,false,High,AI Model,Approved,, 43 | 52,52,1029.37,1016.26,2024-12-11,17:57:50,false,High,System,Under Review,2024-11-27,Generated comment for transaction 52 44 | 53,53,1020.70,1008.45,2024-12-24,04:01:28,false,High,AI Model,Flagged,2024-11-11,Generated comment for transaction 53 45 | 54,54,1012.04,1000.66,2024-11-08,08:05:57,false,High,System,Under Review,2024-11-23,Generated comment for transaction 54 46 | 55,55,1003.38,992.86,2024-11-20,11:18:35,false,High,System,Flagged,2024-10-08,Generated comment for transaction 55 47 | 56,56,1027.49,1014.56,2024-12-04,22:22:12,false,High,AI Model,Flagged,2024-11-20,Generated comment for transaction 56 48 | 57,57,1018.83,1006.77,2024-11-23,07:37:56,false,High,System,Flagged,2024-10-11,Generated comment for transaction 57 49 | 58,58,1027.01,1014.13,2024-11-07,19:49:33,false,Standard,System,Flagged,2024-10-23,Generated comment for transaction 58 50 | 59,59,1018.35,1006.34,2024-12-20,22:53:11,false,Enhanced,AI Model,Approved,, 51 | 60,60,1025.62,1014.47,2024-11-11,15:08:54,false,Standard,System,Under Review,2024-10-26,Generated comment for transaction 60 52 | 61,61,1017.86,1007.49,2024-11-28,15:42:43,true,Standard,System,Under Review,2024-10-16,Generated comment for transaction 61 53 | 62,62,1010.11,998.92,2024-10-12,18:54:20,false,Standard,AI Model,Approved,, 54 | 63,63,1017.38,1005.46,2024-11-26,15:39:52,false,Standard,System,Approved,, 55 | 64,64,1024.65,1012.01,2024-11-04,12:33:24,false,Standard,AI Model,Flagged,2024-10-19,Generated comment for transaction 64 56 | 65,65,1015.99,1004.21,2024-11-24,15:37:02,false,Standard,System,Approved,, 57 | 66,66,1023.26,1010.76,2024-11-01,12:31:33,false,Standard,AI Model,Approved,, 58 | 67,67,1030.53,1017.30,2024-11-15,01:17:05,false,Enhanced,System,Approved,, 59 | 68,68,1005.03,994.35,2024-11-01,22:10:37,false,Enhanced,AI Model,Approved,, 60 | 69,69,1012.30,1000.89,2024-12-06,19:04:01,false,High,System,Approved,, 61 | 70,70,1019.56,1007.43,2024-12-20,16:50:32,false,Enhanced,AI Model,Approved,, 62 | 71,71,1026.83,1013.97,2024-12-06,13:43:04,true,Standard,System,Flagged,2024-10-13,Generated comment for transaction 71 63 | 72,72,1018.17,1006.18,2024-12-18,16:48:42,true,High,AI Model,Approved,, 64 | 73,73,1025.44,1012.72,2024-12-24,13:41:14,false,Enhanced,System,Approved,, 65 | 74,74,1032.71,1022.54,2024-12-09,02:35:45,false,Enhanced,AI Model,Under Review,2024-10-25,Generated comment for transaction 74 66 | 75,75,1024.05,1011.47,2024-12-22,13:39:23,false,High,System,Approved,, 67 | 76,76,1031.32,1021.29,2024-12-07,02:25:55,false,High,AI Model,Flagged,2024-11-23,Generated comment for transaction 76 68 | 77,77,1022.66,1010.22,2024-12-19,13:37:32,false,Enhanced,System,Approved,, 69 | 78,78,1029.93,1016.76,2024-12-05,02:23:04,false,Enhanced,AI Model,Flagged,2024-11-21,Generated comment for transaction 78 70 | 79,79,1021.27,1008.97,2024-12-17,13:27:42,false,High,System,Under Review,2024-11-05,Generated comment for transaction 79 71 | 80,80,1012.60,1001.16,2024-12-02,17:31:19,false,High,AI Model,Flagged,2024-11-17,Generated comment for transaction 80 72 | 81,81,1003.94,993.37,2024-11-14,20:43:57,true,Enhanced,AI Model,Flagged,2024-10-01,Generated comment for transaction 81 73 | 82,82,1028.05,1015.07,2024-12-26,07:48:34,false,High,System,Under Review,2024-10-14,Generated comment for transaction 82 74 | 83,83,1019.39,1007.27,2024-12-10,10:52:12,false,High,AI Model,Approved,, 75 | 84,84,1026.66,1013.82,2024-12-24,07:46:44,false,High,System,Flagged,2024-11-12,Generated comment for transaction 84 76 | 85,85,1018.00,1006.02,2024-12-08,10:50:13,false,Enhanced,AI Model,Approved,, 77 | 86,86,1025.27,1012.57,2024-12-22,07:35:45,false,High,System,Approved,, 78 | 87,87,1032.54,1022.39,2024-12-08,20:29:17,false,Enhanced,AI Model,Under Review,2024-11-15,Generated comment for transaction 87 79 | 88,88,1023.88,1011.32,2024-12-20,07:33:54,false,High,System,Approved,, 80 | 89,89,1031.14,1021.13,2024-12-25,20:27:26,false,High,AI Model,Under Review,2024-11-13,Generated comment for transaction 89 81 | 90,90,1022.48,1010.05,2024-12-18,07:31:03,false,Enhanced,System,Flagged,2024-11-25,Generated comment for transaction 90 82 | 91,91,1013.82,1002.26,2024-12-02,11:36:41,true,High,AI Model,Under Review,2024-11-18,Generated comment for transaction 91 83 | 92,92,1005.16,994.47,2024-11-14,14:40:19,false,High,AI Model,Flagged,2024-10-02,Generated comment for transaction 92 84 | 93,93,1029.27,1016.17,2024-12-26,17:52:56,false,Enhanced,System,Flagged,2024-11-14,Generated comment for transaction 93 85 | 94,94,1020.61,1008.37,2024-12-11,04:56:34,false,High,AI Model,Approved,, 86 | 95,95,1027.88,1014.92,2024-12-24,01:42:05,false,High,System,Under Review,2024-11-12,Generated comment for transaction 95 87 | 96,96,1019.22,1007.12,2024-12-09,04:46:43,false,High,AI Model,Flagged,2024-11-24,Generated comment for transaction 96 88 | 97,97,1010.56,999.33,2024-11-21,08:58:20,false,Enhanced,System,Flagged,2024-11-08,Generated comment for transaction 97 89 | 98,98,1001.90,991.53,2024-11-05,11:03:58,true,High,System,Under Review,2024-10-21,Generated comment for transaction 98 90 | 99,99,1026.00,1013.22,2024-11-24,04:18:41,false,High,AI Model,Approved,, 91 | 100,100,1017.34,1005.43,2024-12-10,01:11:13,false,Enhanced,System,Approved,, 92 | 101,101,1024.61,1011.97,2024-12-15,22:05:37,false,Enhanced,AI Model,Approved,, 93 | 102,102,1031.88,1021.79,2024-12-01,11:51:09,false,High,System,Under Review,2024-10-17,Generated comment for transaction 102 94 | 103,103,1023.22,1010.72,2024-12-13,22:03:46,false,High,AI Model,Approved,, 95 | 104,104,1030.49,1017.26,2024-12-27,11:48:18,false,High,System,Flagged,2024-11-14,Generated comment for transaction 104 96 | 105,105,1021.83,1009.47,2024-12-11,22:53:56,false,Enhanced,AI Model,Approved,, 97 | 106,106,1029.10,1016.01,2024-12-25,11:46:27,false,Enhanced,System,Flagged,2024-11-04,Generated comment for transaction 106 98 | 107,107,1020.43,1008.21,2024-12-09,22:51:05,false,High,AI Model,Under Review,2024-11-25,Generated comment for transaction 107 99 | 108,108,1011.77,1000.42,2024-11-21,02:55:42,false,High,System,Flagged,2024-11-09,Generated comment for transaction 108 100 | 109,109,1003.11,992.62,2024-11-05,05:07:20,false,Enhanced,System,Under Review,2024-10-21,Generated comment for transaction 109 101 | 110,110,1027.22,1014.32,2024-12-18,16:11:57,false,High,AI Model,Under Review,2024-11-05,Generated comment for transaction 110 102 | 111,111,1018.56,1006.53,2024-12-02,19:16:35,false,High,System,Approved,, 103 | 112,112,1025.83,1013.07,2024-12-16,16:01:07,false,High,AI Model,Approved,, 104 | 113,113,1000.33,990.12,2024-12-01,05:55:39,false,High,System,Flagged,2024-11-17,Generated comment for transaction 113 105 | 114,114,1024.44,1011.82,2024-12-14,16:59:16,false,Enhanced,AI Model,Approved,, 106 | 115,115,1031.71,1021.64,2024-12-27,05:53:48,false,Enhanced,System,Flagged,2024-11-07,Generated comment for transaction 115 107 | 116,116,1023.04,1010.56,2024-12-11,16:57:17,false,High,AI Model,Under Review,2024-11-27,Generated comment for transaction 116 108 | 117,117,1014.38,1002.76,2024-12-24,20:01:55,false,Enhanced,System,Flagged,2024-11-11,Generated comment for transaction 117 109 | 118,118,1005.72,994.97,2024-11-08,23:06:32,false,High,System,Under Review,2024-10-24,Generated comment for transaction 118 110 | 119,119,1029.83,1016.67,2024-12-20,02:18:10,false,High,AI Model,Under Review,2024-10-08,Generated comment for transaction 119 111 | 120,120,1021.17,1008.88,2024-12-04,13:22:48,false,High,System,Approved,, 112 | 121,121,1028.44,1015.42,2024-12-18,02:08:19,false,Enhanced,AI Model,Flagged,2024-11-06,Generated comment for transaction 121 113 | 122,122,1019.78,1007.63,2024-12-02,13:20:57,false,Enhanced,System,Approved,, 114 | 123,123,1027.05,1014.17,2024-12-16,10:06:29,false,High,AI Model,Under Review,2024-11-04,Generated comment for transaction 123 115 | 124,124,1018.39,1006.37,2024-12-28,13:10:06,false,High,System,Flagged,2024-11-16,Generated comment for transaction 124 116 | 125,125,1009.73,998.58,2024-11-13,17:22:44,true,Enhanced,AI Model,Under Review,2024-11-28,Generated comment for transaction 125 117 | 126,126,1001.06,990.78,2024-11-25,20:26:21,true,High,AI Model,Under Review,2024-10-12,Generated comment for transaction 126 118 | 127,127,1025.17,1012.48,2024-12-09,07:31:59,false,High,System,Approved,, 119 | 128,128,1032.44,1022.30,2024-12-23,20:16:31,false,Enhanced,AI Model,Flagged,2024-10-10,Generated comment for transaction 128 120 | 129,129,1023.78,1011.22,2024-12-07,07:29:08,false,Enhanced,System,Approved,, 121 | 130,130,1031.05,1021.04,2024-12-21,20:14:40,false,Enhanced,AI Model,Under Review,2024-11-08,Generated comment for transaction 130 122 | 131,131,1022.39,1009.97,2024-12-05,07:18:17,false,High,System,Approved,, 123 | 132,132,1029.66,1016.52,2024-12-19,20:12:41,false,High,AI Model,Flagged,2024-11-06,Generated comment for transaction 132 124 | 133,133,1021.00,1008.72,2024-12-03,07:16:19,false,Enhanced,System,Flagged,2024-11-18,Generated comment for transaction 133 125 | 134,134,1012.33,1000.92,2024-12-15,11:21:56,false,High,AI Model,Under Review,2024-11-03,Generated comment for transaction 134 126 | 135,135,1003.67,993.03,2024-11-04,10:02:45,false,Enhanced,AI Model,Under Review,2024-10-20,Generated comment for transaction 135 127 | 136,136,1028.69,1017.24,2024-11-22,10:36:34,false,High,AI Model,Approved,, 128 | 137,137,1004.10,993.51,2024-11-08,07:21:06,false,High,System,Approved,, 129 | 138,138,1011.37,1000.06,2024-11-21,04:15:38,false,High,AI Model,Approved,, 130 | 139,139,1018.64,1006.60,2024-12-27,01:08:10,false,Standard,System,Approved,, 131 | 140,140,1025.91,1013.14,2024-11-13,22:54:41,false,Standard,AI Model,Approved,, 132 | 141,141,1000.41,990.19,2024-11-26,11:48:13,false,High,System,Under Review,2024-10-06,Generated comment for transaction 141 133 | 142,142,1024.51,1011.88,2024-12-10,22:52:51,false,High,AI Model,Approved,, 134 | 143,143,1031.78,1021.70,2024-11-16,11:46:23,true,High,System,Flagged,2024-10-04,Generated comment for transaction 143 135 | 144,144,1023.12,1010.63,2024-12-08,22:50:00,true,Enhanced,AI Model,Approved,, 136 | 145,145,1030.39,1017.17,2024-12-14,11:44:32,false,Enhanced,System,Flagged,2024-10-02,Generated comment for transaction 145 137 | 146,146,1021.73,1009.38,2024-12-26,22:48:09,false,High,AI Model,Approved,, 138 | 147,147,1029.00,1015.92,2024-12-12,11:34:41,false,High,System,Flagged,2024-11-28,Generated comment for transaction 147 139 | 148,148,1020.34,1008.13,2024-12-24,22:46:11,false,High,AI Model,Approved,, 140 | 149,149,1027.61,1014.67,2024-12-10,19:31:43,false,Enhanced,System,Flagged,2024-11-25,Generated comment for transaction 149 141 | 150,150,1018.95,1006.88,2024-12-22,22:36:20,false,High,AI Model,Under Review,2024-11-10,Generated comment for transaction 150 142 | 151,151,1010.29,999.08,2024-11-06,02:48:58,false,High,System,Under Review,2024-11-22,Generated comment for transaction 151 143 | 152,152,1001.63,991.29,2024-11-19,05:52:35,true,High,System,Flagged,2024-10-06,Generated comment for transaction 152 144 | 153,153,1025.73,1012.98,2024-12-03,16:56:13,true,High,AI Model,Approved,, 145 | 154,154,1000.23,990.03,2024-12-16,05:50:44,false,Enhanced,System,Under Review,2024-10-04,Generated comment for transaction 154 146 | 155,155,1024.34,1011.73,2024-12-01,16:54:22,false,High,AI Model,Approved,, 147 | 156,156,1031.61,1021.55,2024-12-14,05:40:54,false,High,System,Flagged,2024-10-02,Generated comment for transaction 156 148 | 157,157,1022.95,1010.48,2024-12-27,16:52:31,false,Enhanced,AI Model,Approved,, 149 | 158,158,1030.22,1017.02,2024-12-11,19:56:09,false,High,System,Under Review,2024-11-27,Generated comment for transaction 158 150 | 159,159,1005.63,994.89,2024-11-23,23:01:46,false,High,System,Flagged,2024-10-11,Generated comment for transaction 159 151 | 160,160,1029.73,1016.58,2024-11-15,02:05:24,false,Enhanced,AI Model,Flagged,2024-10-23,Generated comment for transaction 160 152 | 161,161,1021.07,1008.79,2024-12-28,13:09:01,true,High,System,Approved,, 153 | 162,162,1028.34,1015.33,2024-12-05,02:03:33,true,High,AI Model,Under Review,2024-10-21,Generated comment for transaction 162 154 | 163,163,1019.68,1007.53,2024-12-18,13:07:03,false,High,System,Approved,, 155 | 164,164,1026.95,1014.08,2024-12-03,10:01:35,false,High,AI Model,Flagged,2024-11-19,Generated comment for transaction 164 156 | 165,165,1018.29,1006.28,2024-12-15,13:05:12,false,Enhanced,System,Approved,, 157 | 166,166,1025.56,1012.83,2024-12-01,10:51:44,false,High,AI Model,Approved,, 158 | 167,167,1000.06,989.88,2024-12-15,23:44:16,false,High,System,Under Review,2024-11-02,Generated comment for transaction 167 159 | 168,168,1024.17,1011.58,2024-12-27,10:49:53,false,High,AI Model,Approved,, 160 | 169,169,1031.44,1021.40,2024-12-05,23:42:25,false,High,System,Flagged,2024-11-20,Generated comment for transaction 169 161 | 170,170,1022.77,1010.32,2024-12-25,10:47:03,false,Enhanced,AI Model,Flagged,2024-11-05,Generated comment for transaction 170 162 | 171,171,1014.11,1002.52,2024-12-09,14:51:40,false,High,System,Under Review,2024-11-25,Generated comment for transaction 171 163 | 172,172,1005.45,994.73,2024-11-21,17:55:18,false,High,System,Flagged,2024-10-09,Generated comment for transaction 172 164 | 173,173,1029.56,1016.43,2024-12-06,20:07:55,false,Enhanced,AI Model,Under Review,2024-10-21,Generated comment for transaction 173 165 | 174,174,1020.90,1008.63,2024-12-18,07:12:33,false,High,System,Approved,, 166 | 175,175,1028.17,1015.18,2024-12-04,04:57:04,false,High,AI Model,Flagged,2024-11-19,Generated comment for transaction 175 167 | 176,176,1019.51,1007.38,2024-12-16,07:09:42,false,Enhanced,System,Flagged,2024-11-03,Generated comment for transaction 176 168 | 177,177,1010.85,999.59,2024-11-28,10:14:20,false,Enhanced,AI Model,Flagged,2024-11-16,Generated comment for transaction 177 169 | 178,178,1002.19,991.79,2024-11-12,14:18:57,false,High,AI Model,Under Review,2024-10-28,Generated comment for transaction 178 170 | 179,179,1026.29,1013.48,2024-12-25,01:22:27,true,High,System,Approved,, 171 | 180,180,1000.79,990.53,2024-12-10,14:16:58,true,High,AI Model,Flagged,2024-10-26,Generated comment for transaction 180 172 | 181,181,1024.90,1012.23,2024-12-23,01:20:36,false,Enhanced,System,Approved,, 173 | 182,182,1032.17,1022.05,2024-12-08,14:06:08,false,High,AI Model,Under Review,2024-10-24,Generated comment for transaction 182 174 | 183,183,1023.51,1010.98,2024-12-20,01:18:45,false,High,System,Approved,, 175 | 184,184,1030.78,1017.52,2024-12-06,14:04:17,false,High,AI Model,Flagged,2024-11-22,Generated comment for transaction 184 176 | 185,185,1022.12,1009.73,2024-12-18,01:08:55,false,Enhanced,System,Approved,, 177 | 186,186,1029.39,1016.27,2024-12-04,14:02:26,false,Enhanced,AI Model,Flagged,2024-11-12,Generated comment for transaction 186 178 | 187,187,1020.73,1008.48,2024-12-16,01:06:04,false,High,System,Under Review,2024-11-04,Generated comment for transaction 187 179 | 188,188,1012.06,1000.68,2024-11-28,05:10:41,false,High,AI Model,Flagged,2024-11-16,Generated comment for transaction 188 180 | 189,189,1003.40,992.88,2024-11-13,08:22:19,true,High,AI Model,Under Review,2024-10-28,Generated comment for transaction 189 181 | 190,190,1027.51,1014.58,2024-12-25,19:27:57,false,High,System,Under Review,2024-11-13,Generated comment for transaction 190 182 | 191,191,1018.85,1006.79,2024-12-09,22:31:34,false,High,AI Model,Approved,, 183 | 192,192,1026.12,1013.33,2024-12-23,19:24:06,false,Enhanced,System,Approved,, 184 | 193,193,1000.62,990.38,2024-12-09,08:10:38,false,High,AI Model,Flagged,2024-11-24,Generated comment for transaction 193 185 | 194,194,1024.73,1012.08,2024-12-21,19:14:15,false,High,System,Approved,, 186 | 195,195,1032.00,1021.90,2024-12-06,08:08:39,false,Enhanced,AI Model,Flagged,2024-11-14,Generated comment for transaction 195 187 | 196,196,1023.34,1010.83,2024-12-19,19:12:16,false,High,System,Flagged,2024-11-06,Generated comment for transaction 196 188 | 197,197,1014.67,1003.03,2024-12-03,23:17:54,false,Enhanced,AI Model,Flagged,2024-11-19,Generated comment for transaction 197 189 | 198,198,1006.01,995.23,2024-11-15,02:21:32,true,High,AI Model,Under Review,2024-10-03,Generated comment for transaction 198 190 | 199,199,1030.12,1016.93,2024-12-27,05:33:09,false,High,System,Under Review,2024-10-15,Generated comment for transaction 199 191 | 200,200,1021.46,1009.14,2024-12-12,16:37:47,false,Enhanced,AI Model,Approved,, 192 | 201,201,1028.73,1015.68,2024-12-25,05:23:18,false,Enhanced,System,Flagged,2024-11-13,Generated comment for transaction 201 193 | 202,202,1020.07,1007.89,2024-12-10,16:35:56,false,Enhanced,AI Model,Approved,, 194 | 203,203,1027.34,1014.43,2024-12-23,13:21:28,false,High,System,Under Review,2024-11-11,Generated comment for transaction 203 195 | 204,204,1018.68,1006.64,2024-12-08,16:25:05,false,High,AI Model,Flagged,2024-11-23,Generated comment for transaction 204 196 | 205,205,1010.02,998.84,2024-11-20,20:37:43,false,Enhanced,System,Under Review,2024-11-07,Generated comment for transaction 205 197 | 206,206,1001.36,991.05,2024-11-04,23:42:20,true,High,System,Under Review,2024-10-20,Generated comment for transaction 206 198 | 207,207,1025.46,1012.74,2024-12-16,10:46:58,true,High,AI Model,Approved,, 199 | 208,208,1032.73,1022.56,2024-12-02,23:40:30,false,Enhanced,System,Flagged,2024-10-18,Generated comment for transaction 208 200 | 209,209,1024.07,1011.49,2024-12-14,10:44:07,false,Enhanced,AI Model,Approved,, 201 | 210,210,1031.34,1021.31,2024-12-28,23:29:31,false,High,System,Under Review,2024-11-15,Generated comment for transaction 210 202 | 211,211,1022.68,1010.23,2024-12-12,10:34:09,false,High,AI Model,Approved,, 203 | 212,212,1029.95,1016.78,2024-12-26,23:27:40,false,High,System,Flagged,2024-11-13,Generated comment for transaction 212 204 | 213,213,1021.29,1008.98,2024-12-10,10:32:18,false,Enhanced,AI Model,Flagged,2024-11-26,Generated comment for transaction 213 205 | 214,214,1012.63,1001.19,2024-12-22,14:36:55,false,High,System,Under Review,2024-11-10,Generated comment for transaction 214 206 | 215,215,1003.97,993.40,2024-11-06,17:48:33,true,High,System,Flagged,2024-10-22,Generated comment for transaction 215 207 | 216,216,1028.07,1015.09,2024-11-25,10:03:16,true,High,AI Model,Approved,, 208 | 217,217,1019.41,1007.29,2024-12-03,07:57:48,false,High,System,Approved,, 209 | 218,218,1026.68,1013.83,2024-12-17,04:50:20,false,Enhanced,AI Model,Flagged,2024-11-04,Generated comment for transaction 218 210 | 219,219,1018.02,1006.04,2024-12-01,07:55:57,false,High,System,Approved,, 211 | 220,220,1025.29,1012.58,2024-12-15,04:40:29,false,High,AI Model,Approved,, 212 | 221,221,1032.56,1022.40,2024-12-28,17:34:01,false,High,System,Flagged,2024-11-08,Generated comment for transaction 221 213 | 222,222,1023.90,1011.33,2024-12-12,04:38:38,false,Enhanced,AI Model,Approved,, 214 | 223,223,1031.17,1021.15,2024-12-18,17:32:10,false,Enhanced,System,Flagged,2024-11-06,Generated comment for transaction 223 215 | 224,224,1022.50,1010.07,2024-12-10,04:36:48,false,High,AI Model,Under Review,2024-11-18,Generated comment for transaction 224 216 | 225,225,1013.84,1002.28,2024-12-23,08:40:25,false,High,System,Flagged,2024-11-10,Generated comment for transaction 225 217 | 226,226,1005.18,994.48,2024-11-07,11:44:55,false,High,System,Under Review,2024-10-22,Generated comment for transaction 226 218 | 227,227,1029.29,1016.18,2024-12-19,14:49:32,false,High,AI Model,Flagged,2024-11-07,Generated comment for transaction 227 219 | 228,228,1020.63,1008.39,2024-12-03,01:01:10,false,High,System,Approved,, 220 | 229,229,1027.90,1014.93,2024-12-17,22:47:42,false,Enhanced,AI Model,Flagged,2024-11-05,Generated comment for transaction 229 221 | 230,230,1019.24,1007.14,2024-12-01,01:51:19,false,High,System,Under Review,2024-11-17,Generated comment for transaction 230 222 | 231,231,1010.58,999.35,2024-11-14,05:03:57,false,High,AI Model,Flagged,2024-11-01,Generated comment for transaction 231 223 | 232,232,1001.92,991.55,2024-11-26,08:07:34,false,Enhanced,AI Model,Flagged,2024-10-13,Generated comment for transaction 232 224 | 233,233,1026.02,1013.24,2024-12-10,19:12:12,true,High,System,Approved,, 225 | 234,234,1000.52,990.29,2024-12-24,08:05:44,true,High,AI Model,Flagged,2024-10-11,Generated comment for transaction 234 226 | 235,235,1024.63,1011.99,2024-12-08,19:10:21,false,High,System,Approved,, 227 | 236,236,1031.90,1021.81,2024-12-22,08:55:53,false,High,AI Model,Flagged,2024-10-09,Generated comment for transaction 236 228 | 237,237,1023.24,1010.74,2024-12-06,19:07:30,false,Enhanced,System,Approved,, 229 | 238,238,1030.51,1017.28,2024-12-20,08:53:02,false,Enhanced,AI Model,Under Review,2024-11-07,Generated comment for transaction 238 230 | 239,239,1021.85,1009.49,2024-12-04,19:57:40,false,High,System,Approved,, 231 | 240,240,1029.12,1016.03,2024-12-17,08:51:12,false,High,AI Model,Under Review,2024-11-25,Generated comment for transaction 240 232 | 241,241,1020.46,1008.24,2024-12-02,19:55:41,false,High,System,Flagged,2024-11-17,Generated comment for transaction 241 233 | 242,242,1011.80,1000.44,2024-11-14,23:00:19,false,High,AI Model,Under Review,2024-11-02,Generated comment for transaction 242 234 | 243,243,1003.13,992.64,2024-11-26,02:04:56,true,High,AI Model,Flagged,2024-10-14,Generated comment for transaction 243 235 | 244,244,1027.24,1014.34,2024-12-10,13:16:34,false,High,System,Flagged,2024-11-26,Generated comment for transaction 244 236 | 245,245,1018.58,1006.54,2024-12-23,16:20:11,false,Enhanced,AI Model,Approved,, 237 | 246,246,1025.85,1013.09,2024-12-08,13:06:43,false,High,System,Approved,, 238 | 247,247,1000.35,990.14,2024-12-22,02:00:15,false,High,AI Model,Under Review,2024-11-10,Generated comment for transaction 247 239 | 248,248,1024.46,1011.84,2024-12-06,13:04:52,false,High,System,Approved,, 240 | 249,249,1031.73,1021.66,2024-12-12,02:57:24,false,High,AI Model,Flagged,2024-11-28,Generated comment for transaction 249 241 | 250,250,1023.07,1010.59,2024-12-04,13:02:02,false,Enhanced,System,Flagged,2024-11-12,Generated comment for transaction 250 242 | -------------------------------------------------------------------------------- /lib/assets/data/transactions/transactions.csv: -------------------------------------------------------------------------------- 1 | transaction_id,account_id,transaction_type,amount,transaction_date,merchant_id,city,state,currency,transaction_status,fraud_flag,flagged_by,fraud_reason11,8,Purchase,11.86,2024-10-19,6,Phoenix, AZ,USD,Completed,false,, 2 | 2,6,Withdrawal,11.79,2024-10-26,6,Houston, TX,USD,Completed,false,, 3 | 1,1,Withdrawal,10.50,2024-12-10,2,Los Angeles, CA,USD,Completed,true,System,Exceeds daily limit 4 | 4,4,Withdrawal,11.39,2024-10-08,4,Houston, TX,USD,Completed,false,, 5 | 5,3,Withdrawal,12.96,2024-11-05,8,Philadelphia, PA,USD,Completed,false,, 6 | 6,3,Purchase,10.95,2024-10-14,9,Dallas, TX,USD,Completed,false,, 7 | 7,1,Withdrawal,11.91,2024-12-28,8,Philadelphia, PA,USD,Completed,false,, 8 | 8,5,Purchase,13.11,2024-12-08,1,New York, NY,USD,Completed,false,, 9 | 10,6,Purchase,12.47,2024-11-16,9,San Diego, CA,USD,Completed,false,, 10 | 3,10,Withdrawal,13.16,2024-11-02,6,San Antonio, TX,USD,Completed,false,, 11 | 9,3,Withdrawal,12.33,2024-12-12,3,Los Angeles, CA,USD,Completed,true,System,Multiple password attempts 12 | 20,3,Withdrawal,10.57,2024-12-23,3,Houston, TX,USD,Completed,true,System,Unusual location 13 | 12,6,Withdrawal,11.79,2024-10-26,6,Houston, TX,USD,Completed,false,, 14 | 13,1,Withdrawal,10.50,2024-12-10,2,Los Angeles, CA,USD,Completed,true,System,Exceeds daily limit 15 | 14,4,Withdrawal,11.39,2024-10-08,4,Houston, TX,USD,Completed,false,, 16 | 15,3,Withdrawal,12.96,2024-11-05,8,Philadelphia, PA,USD,Completed,false,, 17 | 16,3,Purchase,10.95,2024-10-14,9,Dallas, TX,USD,Completed,false,, 18 | 17,1,Withdrawal,11.91,2024-12-28,8,Philadelphia, PA,USD,Completed,false,, 19 | 18,5,Purchase,13.11,2024-12-08,1,New York, NY,USD,Completed,false,, 20 | 19,3,Withdrawal,12.33,2024-12-12,3,Los Angeles, CA,USD,Completed,true,System,Multiple password attempts 21 | 20,3,Withdrawal,10.57,2024-12-23,3,Houston, TX,USD,Completed,true,System,Unusual location 22 | 21,10,Withdrawal,13.10,2024-11-16,5,Philadelphia, PA,USD,Completed,false,, 23 | 22,9,Withdrawal,11.54,2024-12-09,3,Los Angeles, CA,USD,Completed,true,System,Multiple password attempts 24 | 23,10,Withdrawal,13.16,2024-11-02,6,San Antonio, TX,USD,Completed,false,, 25 | 24,2,Purchase,10.76,2024-11-08,5,Phoenix, AZ,USD,Completed,false,, 26 | 25,6,Purchase,10.42,2024-10-28,3,Chicago, IL,USD,Completed,true,System,Unusual location 27 | 26,1,Purchase,12.22,2024-11-13,7,Phoenix, AZ,USD,Completed,false,, 28 | 27,10,Purchase,10.81,2024-12-02,1,New York, NY,USD,Completed,false,, 29 | 28,1,Purchase,12.39,2024-10-07,9,San Antonio, TX,USD,Completed,false,, 30 | 29,4,Purchase,11.48,2024-10-14,3,Houston, TX,USD,Completed,false,, 31 | 30,6,Purchase,12.47,2024-11-16,9,San Diego, CA,USD,Completed,false,, 32 | 31,7,Purchase,11.73,2024-12-28,2,New York, NY,USD,Completed,true,System,Large transaction 33 | 32,6,Withdrawal,11.81,2024-10-24,6,Houston, TX,USD,Completed,false,, 34 | 33,6,Purchase,12.74,2024-10-15,6,Phoenix, AZ,USD,Completed,false,, 35 | 34,2,Withdrawal,11.69,2024-12-12,10,San Diego, CA,USD,Completed,false,, 36 | 35,10,Withdrawal,11.35,2024-12-24,3,Houston, TX,USD,Completed,true,System,Unusual location 37 | 36,3,Withdrawal,10.86,2024-10-10,9,San Francisco, CA,USD,Completed,false,, 38 | 37,4,Withdrawal,10.59,2024-11-03,10,San Francisco, CA,USD,Completed,false,, 39 | 38,2,Withdrawal,12.84,2024-10-26,6,Houston, TX,USD,Completed,false,, 40 | 39,3,Purchase,12.70,2024-12-27,5,Chicago, IL,USD,Completed,false,, 41 | 40,7,Purchase,10.71,2024-12-24,3,Houston, TX,USD,Completed,true,System,Unusual location 42 | 41,3,Withdrawal,12.34,2024-11-23,2,San Francisco, CA,USD,Completed,true,System,Large transaction 43 | 42,7,Purchase,11.13,2024-11-02,1,New York, NY,USD,Completed,false,, 44 | 43,5,Purchase,12.52,2024-12-24,9,San Antonio, TX,USD,Completed,false,, 45 | 44,6,Purchase,10,2024-11-06,9,Dallas, TX,USD,Completed,false,, 46 | 45,3,Withdrawal,10.61,2024-10-12,6,Philadelphia, PA,USD,Completed,false,, 47 | 46,7,Purchase,11.53,2024-11-18,2,Los Angeles, CA,USD,Completed,false,, 48 | 47,8,Purchase,11.74,2024-10-24,10,Dallas, TX,USD,Completed,false,, 49 | 48,2,Withdrawal,10.26,2024-11-12,4,Houston, TX,USD,Completed,false,, 50 | 49,3,Purchase,12.40,2024-10-25,1,San Francisco, CA,USD,Completed,false,, 51 | 50,5,Purchase,10.36,2024-10-02,9,Dallas, TX,USD,Completed,false,, 52 | 51,10,Purchase,10.56,2024-10-23,7,San Antonio, TX,USD,Completed,false,, 53 | 52,4,Withdrawal,13.02,2024-10-25,8,Philadelphia, PA,USD,Completed,false,, 54 | 53,1,Purchase,10.82,2024-10-27,3,Chicago, IL,USD,Completed,true,System,Unusual location 55 | 54,2,Withdrawal,13.27,2024-11-11,7,San Diego, CA,USD,Completed,false,, 56 | 55,3,Withdrawal,12.32,2024-11-15,8,Philadelphia, PA,USD,Completed,false,, 57 | 56,9,Purchase,12.69,2024-10-03,3,New York, NY,USD,Completed,true,System,Multiple password attempts 58 | 57,9,Purchase,12.37,2024-11-21,7,Phoenix, AZ,USD,Completed,false,, 59 | 58,10,Purchase,10.63,2024-11-17,5,Philadelphia, PA,USD,Completed,false,, 60 | 59,6,Purchase,11.92,2024-12-17,4,Chicago, IL,USD,Completed,false,, 61 | 60,10,Withdrawal,11.04,2024-12-08,6,Philadelphia, PA,USD,Completed,false,, 62 | 61,9,Purchase,11.71,2024-10-03,8,San Antonio, TX,USD,Completed,false,, 63 | 62,5,Purchase,12.48,2024-11-03,3,New York, NY,USD,Completed,true,System,Multiple password attempts 64 | 63,7,Withdrawal,12.32,2024-12-18,10,San Diego, CA,USD,Completed,false,, 65 | 64,1,Withdrawal,10.16,2024-12-20,2,Los Angeles, CA,USD,Completed,true,System,Exceeds daily limit 66 | 65,10,Purchase,10.45,2024-10-10,1,Los Angeles, CA,USD,Completed,false,, 67 | 66,6,Withdrawal,12.60,2024-10-06,10,Dallas, TX,USD,Completed,false,, 68 | 67,10,Withdrawal,11.40,2024-11-13,4,Houston, TX,USD,Completed,false,, 69 | 68,1,Purchase,11.88,2024-11-18,7,Phoenix, AZ,USD,Completed,false,, 70 | 69,7,Withdrawal,11.22,2024-10-26,6,Philadelphia, PA,USD,Completed,false,, 71 | 70,4,Withdrawal,11.40,2024-10-22,10,San Francisco, CA,USD,Completed,false,, 72 | 71,5,Purchase,10.63,2024-12-05,3,Chicago, IL,USD,Completed,true,System,Unusual location 73 | 72,3,Withdrawal,11.57,2024-12-09,2,San Francisco, CA,USD,Completed,false,, 74 | 73,7,Purchase,12.25,2024-11-24,2,New York, NY,USD,Completed,true,System,Large transaction 75 | 74,5,Purchase,11.31,2024-10-07,1,New York, NY,USD,Completed,false,, 76 | 75,10,Purchase,11.55,2024-10-27,1,Dallas, TX,USD,Completed,false,, 77 | 76,5,Withdrawal,13.20,2024-12-22,2,Los Angeles, CA,USD,Completed,true,System,Exceeds daily limit 78 | 77,2,Purchase,11.00,2024-11-07,5,Phoenix, AZ,USD,Completed,false,, 79 | 78,4,Purchase,12.75,2024-10-05,6,Phoenix, AZ,USD,Completed,false,, 80 | 79,10,Withdrawal,11.05,2024-11-22,6,Houston, TX,USD,Completed,false,, 81 | 80,5,Withdrawal,12.26,2024-12-28,6,Houston, TX,USD,Completed,false,, 82 | 81,2,Withdrawal,11.29,2024-11-22,9,San Francisco, CA,USD,Completed,false,, 83 | 82,3,Withdrawal,10.18,2024-10-21,6,Philadelphia, PA,USD,Completed,false,, 84 | 83,5,Purchase,10.29,2024-11-11,7,San Antonio, TX,USD,Completed,false,, 85 | 84,1,Purchase,12.68,2024-10-10,2,New York, NY,USD,Completed,true,System,Large transaction 86 | 85,1,Purchase,10.22,2024-10-08,9,San Antonio, TX,USD,Completed,false,, 87 | 86,5,Withdrawal,12.29,2024-12-27,6,Houston, TX,USD,Completed,false,, 88 | 87,8,Withdrawal,10.04,2024-12-28,6,Philadelphia, PA,USD,Completed,false,, 89 | 88,6,Withdrawal,10.36,2024-11-11,2,Los Angeles, CA,USD,Completed,true,System,Exceeds daily limit 90 | 89,8,Purchase,12.91,2024-10-21,2,New York, NY,USD,Completed,true,System,Large transaction 91 | 90,5,Withdrawal,10.07,2024-12-14,9,San Francisco, CA,USD,Completed,false,, 92 | 91,9,Withdrawal,11.17,2024-10-05,8,San Diego, CA,USD,Completed,false,, 93 | 92,2,Withdrawal,13.01,2024-10-06,8,Philadelphia, PA,USD,Completed,false,, 94 | 93,8,Withdrawal,11.11,2024-11-04,10,San Francisco, CA,USD,Completed,false,, 95 | 94,7,Withdrawal,10.64,2024-12-03,8,San Diego, CA,USD,Completed,false,, 96 | 95,10,Purchase,12.77,2024-11-04,5,Houston, TX,USD,Completed,false,, 97 | 96,3,Withdrawal,11.77,2024-11-22,2,San Francisco, CA,USD,Completed,true,System,Large transaction 98 | 97,5,Purchase,12.36,2024-12-18,7,Phoenix, AZ,USD,Completed,false,, 99 | 98,9,Withdrawal,12.31,2024-12-03,6,Houston, TX,USD,Completed,false,, 100 | 99,3,Purchase,13.04,2024-12-06,1,Dallas, TX,USD,Completed,false,, 101 | 100,3,Purchase,11.25,2024-11-11,3,Chicago, IL,USD,Completed,true,System,Unusual location 102 | 101,2,Purchase,10.18,2024-10-19,1,New York, NY,USD,Completed,false,, 103 | 102,7,Withdrawal,10,2024-12-17,8,San Diego, CA,USD,Completed,false,, 104 | 103,10,Withdrawal,12.35,2024-10-18,4,Los Angeles, CA,USD,Completed,true,System,Exceeds daily limit 105 | 104,10,Withdrawal,13.02,2024-12-13,10,Dallas, TX,USD,Completed,false,, 106 | 105,4,Purchase,11.76,2024-10-22,2,New York, NY,USD,Completed,true,System,Large transaction 107 | 106,1,Purchase,12.56,2024-11-27,10,Dallas, TX,USD,Completed,false,, 108 | 107,6,Withdrawal,12.03,2024-10-12,10,San Diego, CA,USD,Completed,false,, 109 | 108,3,Purchase,11.85,2024-10-04,1,Dallas, TX,USD,Completed,false,, 110 | 109,9,Withdrawal,12.74,2024-10-28,10,Dallas, TX,USD,Completed,false,, 111 | 110,6,Withdrawal,11.79,2024-11-02,4,Los Angeles, CA,USD,Completed,true,System,Exceeds daily limit 112 | 111,5,Purchase,11.23,2024-10-12,1,New York, NY,USD,Completed,false,, 113 | 112,8,Withdrawal,13.18,2024-10-16,4,Houston, TX,USD,Completed,false,, 114 | 113,7,Purchase,11.76,2024-12-24,1,Dallas, TX,USD,Completed,false,, 115 | 114,9,Purchase,12.31,2024-12-07,2,New York, NY,USD,Completed,true,System,Large transaction 116 | 115,8,Purchase,11.32,2024-12-18,9,San Francisco, CA,USD,Completed,false,, 117 | 116,2,Withdrawal,13.13,2024-11-12,2,Chicago, IL,USD,Completed,true,System,Exceeds daily limit 118 | 117,10,Purchase,12.12,2024-11-21,8,San Antonio, TX,USD,Completed,false,, 119 | 118,3,Withdrawal,12.59,2024-10-18,10,San Diego, CA,USD,Completed,false,, 120 | 119,10,Purchase,12.57,2024-12-21,7,Phoenix, AZ,USD,Completed,false,, 121 | 120,4,Purchase,11.08,2024-10-17,9,Dallas, TX,USD,Completed,false,, 122 | 121,3,Withdrawal,11.22,2024-10-19,10,San Francisco, CA,USD,Completed,false,, 123 | 122,10,Withdrawal,10.31,2024-12-13,4,Los Angeles, CA,USD,Completed,true,System,Exceeds daily limit 124 | 123,8,Purchase,12.18,2024-11-02,4,Chicago, IL,USD,Completed,false,, 125 | 124,6,Withdrawal,12.79,2024-11-15,6,Houston, TX,USD,Completed,false,, 126 | 125,5,Purchase,12.69,2024-10-11,5,Houston, TX,USD,Completed,false,, 127 | 126,9,Withdrawal,12.41,2024-10-01,6,Houston, TX,USD,Completed,false,, 128 | 127,5,Withdrawal,11.66,2024-12-28,8,Philadelphia, PA,USD,Completed,false,, 129 | 128,2,Withdrawal,11.42,2024-10-20,4,Houston, TX,USD,Completed,false,, 130 | 129,7,Purchase,13.00,2024-10-06,3,Los Angeles, CA,USD,Completed,true,System,Unusual location 131 | 130,2,Purchase,12.03,2024-12-21,7,Phoenix, AZ,USD,Completed,false,, 132 | 131,1,Withdrawal,10.27,2024-12-19,2,Los Angeles, CA,USD,Completed,true,System,Exceeds daily limit 133 | 132,3,Withdrawal,11.96,2024-12-22,8,Philadelphia, PA,USD,Completed,false,, 134 | 133,4,Withdrawal,10.34,2024-12-11,3,Houston, TX,USD,Completed,true,System,Unusual location 135 | 134,7,Purchase,11.65,2024-11-11,1,Dallas, TX,USD,Completed,false,, 136 | 135,1,Withdrawal,12.73,2024-11-11,5,Houston, TX,USD,Completed,false,, 137 | 136,1,Withdrawal,11.19,2024-11-22,10,San Francisco, CA,USD,Completed,false,, 138 | 137,3,Purchase,12.99,2024-11-18,3,New York, NY,USD,Completed,true,System,Multiple password attempts 139 | 138,1,Purchase,13.03,2024-10-10,5,Chicago, IL,USD,Completed,false,, 140 | 139,10,Purchase,10.36,2024-11-09,9,Dallas, TX,USD,Completed,false,, 141 | 140,9,Purchase,13.09,2024-12-21,7,Phoenix, AZ,USD,Completed,false,, 142 | 141,5,Purchase,12.99,2024-10-18,5,Houston, TX,USD,Completed,false,, 143 | 142,8,Purchase,10.10,2024-10-20,1,New York, NY,USD,Completed,false,, 144 | 143,1,Withdrawal,12.47,2024-12-09,8,Philadelphia, PA,USD,Completed,false,, 145 | 144,3,Purchase,13.07,2024-10-17,1,Dallas, TX,USD,Completed,false,, 146 | 145,1,Withdrawal,12.99,2024-10-19,6,Houston, TX,USD,Completed,false,, 147 | 146,4,Purchase,12.93,2024-11-19,5,Houston, TX,USD,Completed,false,, 148 | 147,8,Purchase,11.70,2024-10-20,9,San Antonio, TX,USD,Completed,false,, 149 | 148,7,Withdrawal,11.83,2024-12-14,1,San Francisco, CA,USD,Completed,false,, 150 | 149,5,Purchase,11.71,2024-11-07,5,Chicago, IL,USD,Completed,false,, 151 | 150,5,Purchase,13.05,2024-10-25,7,Phoenix, AZ,USD,Completed,false,, 152 | 151,3,Withdrawal,11.66,2024-11-03,6,Phoenix, AZ,USD,Completed,false,, 153 | 152,9,Purchase,11.42,2024-12-19,5,Phoenix, AZ,USD,Completed,false,, 154 | 153,7,Purchase,11.00,2024-10-18,1,New York, NY,USD,Completed,false,, 155 | 154,8,Purchase,11.46,2024-12-28,4,Los Angeles, CA,USD,Completed,true,System,Multiple password attempts 156 | 155,5,Withdrawal,12.58,2024-10-25,4,Los Angeles, CA,USD,Completed,true,System,Multiple password attempts 157 | 156,4,Purchase,10.78,2024-11-25,3,Houston, TX,USD,Completed,true,System,Unusual location 158 | 157,1,Purchase,12.72,2024-11-15,1,Dallas, TX,USD,Completed,false,, 159 | 158,3,Purchase,10.37,2024-12-22,1,New York, NY,USD,Completed,false,, 160 | 159,1,Withdrawal,12.95,2024-11-18,4,Los Angeles, CA,USD,Completed,true,System,Exceeds daily limit 161 | 160,9,Withdrawal,13.02,2024-11-15,10,San Diego, CA,USD,Completed,false,, 162 | 161,1,Withdrawal,11.62,2024-12-08,9,San Diego, CA,USD,Completed,false,, 163 | 162,6,Purchase,11.34,2024-12-28,5,Phoenix, AZ,USD,Completed,false,, 164 | 163,9,Withdrawal,10.66,2024-11-25,4,Houston, TX,USD,Completed,false,, 165 | 164,4,Purchase,12.82,2024-11-20,1,Los Angeles, CA,USD,Completed,false,, 166 | 165,10,Withdrawal,11.13,2024-12-22,4,Houston, TX,USD,Completed,false,, 167 | 166,8,Purchase,12.86,2024-11-15,3,Chicago, IL,USD,Completed,true,System,Unusual location 168 | 167,4,Purchase,12.10,2024-12-04,1,Dallas, TX,USD,Completed,false,, 169 | 168,7,Withdrawal,11.43,2024-12-21,4,Houston, TX,USD,Completed,false,, 170 | 169,7,Purchase,11.32,2024-11-07,1,New York, NY,USD,Completed,false,, 171 | 170,9,Purchase,12.74,2024-11-16,4,Chicago, IL,USD,Completed,false,, 172 | 171,8,Purchase,10.13,2024-10-13,5,Phoenix, AZ,USD,Completed,false,, 173 | 172,5,Purchase,11.98,2024-11-05,9,San Antonio, TX,USD,Completed,false,, 174 | 173,4,Purchase,11.80,2024-10-24,10,Dallas, TX,USD,Completed,false,, 175 | 174,2,Purchase,12.46,2024-11-08,9,San Antonio, TX,USD,Completed,false,, 176 | 175,7,Withdrawal,12.45,2024-12-23,4,Los Angeles, CA,USD,Completed,false,, 177 | 176,8,Withdrawal,12.97,2024-11-07,2,San Francisco, CA,USD,Completed,true,System,Large transaction 178 | 177,3,Withdrawal,12.34,2024-12-11,2,San Francisco, CA,USD,Completed,false,, 179 | 178,7,Purchase,10.07,2024-10-22,6,San Antonio, TX,USD,Completed,false,, 180 | 179,9,Withdrawal,10.42,2024-11-21,10,New York, NY,USD,Completed,false,, 181 | 180,9,Purchase,10.80,2024-12-05,5,Phoenix, AZ,USD,Completed,false,, 182 | 181,10,Withdrawal,10.94,2024-11-27,4,Phoenix, AZ,USD,Completed,false,, 183 | 182,5,Withdrawal,11.37,2024-11-26,6,Philadelphia, PA,USD,Completed,false,, 184 | 183,4,Withdrawal,13.03,2024-10-02,10,San Diego, CA,USD,Completed,false,, 185 | 184,3,Purchase,12.16,2024-12-02,9,San Diego, CA,USD,Completed,false,, 186 | 185,8,Purchase,10.58,2024-11-16,10,New York, NY,USD,Completed,false,, 187 | 186,6,Withdrawal,11.75,2024-12-19,4,Los Angeles, CA,USD,Completed,true,System,Exceeds daily limit 188 | 187,3,Purchase,11.82,2024-10-03,9,San Antonio, TX,USD,Completed,false,, 189 | 188,4,Withdrawal,12.74,2024-12-20,2,San Francisco, CA,USD,Completed,false,, 190 | 189,5,Withdrawal,11.39,2024-10-01,8,San Diego, CA,USD,Completed,false,, 191 | 190,8,Withdrawal,11.29,2024-10-03,8,San Diego, CA,USD,Completed,false,, 192 | 191,4,Withdrawal,12.27,2024-10-13,4,Los Angeles, CA,USD,Completed,true,System,Exceeds daily limit 193 | 192,5,Purchase,10.82,2024-12-16,9,Dallas, TX,USD,Completed,false,, 194 | 193,7,Purchase,11.21,2024-10-09,8,Dallas, TX,USD,Completed,false,, 195 | 194,3,Purchase,10.95,2024-12-09,1,New York, NY,USD,Completed,false,, 196 | 195,1,Purchase,11.84,2024-12-27,7,Phoenix, AZ,USD,Completed,false,, 197 | 196,2,Withdrawal,13.20,2024-10-16,4,Houston, TX,USD,Completed,true,System,Amount pattern 198 | 197,7,Purchase,12.61,2024-10-27,7,Phoenix, AZ,USD,Completed,false,, 199 | 198,4,Withdrawal,11.51,2024-10-27,8,Philadelphia, PA,USD,Completed,false,, 200 | 199,1,Purchase,10.56,2024-12-15,9,San Francisco, CA,USD,Completed,false,, 201 | 200,9,Purchase,10.97,2024-10-18,3,Chicago, IL,USD,Completed,true,System,Unusual location 202 | 201,10,Withdrawal,10.83,2024-12-07,3,Houston, TX,USD,Completed,true,System,Unusual location 203 | 202,8,Withdrawal,11.15,2024-12-04,10,San Francisco, CA,USD,Completed,false,, 204 | 203,1,Purchase,13.14,2024-10-15,5,Philadelphia, PA,USD,Completed,false,, 205 | 204,2,Purchase,12.04,2024-10-22,7,Phoenix, AZ,USD,Completed,false,, 206 | 205,9,Withdrawal,11.59,2024-11-22,4,Los Angeles, CA,USD,Completed,true,System,Exceeds daily limit 207 | 206,1,Withdrawal,11.69,2024-10-08,9,San Diego, CA,USD,Completed,false,, 208 | 207,3,Withdrawal,11.88,2024-11-04,8,Philadelphia, PA,USD,Completed,false,, 209 | 208,7,Withdrawal,12.49,2024-12-03,10,San Diego, CA,USD,Completed,false,, 210 | 209,6,Withdrawal,10.91,2024-10-10,6,Philadelphia, PA,USD,Completed,false,, 211 | 210,10,Purchase,12.45,2024-11-21,3,New York, NY,USD,Completed,true,System,Large transaction 212 | 211,1,Purchase,10.87,2024-10-27,7,Phoenix, AZ,USD,Completed,false,, 213 | 212,2,Purchase,12.01,2024-10-16,7,San Diego, CA,USD,Completed,false,, 214 | 213,10,Purchase,10.34,2024-10-13,7,San Antonio, TX,USD,Completed,false,, 215 | 214,5,Withdrawal,12.50,2024-10-14,1,San Francisco, CA,USD,Completed,false,, 216 | 215,6,Withdrawal,12.05,2024-11-21,2,New York, NY,USD,Completed,true,System,Large transaction 217 | 216,2,Purchase,12.90,2024-11-27,7,Phoenix, AZ,USD,Completed,false,, 218 | 217,4,Purchase,10.87,2024-12-18,9,Dallas, TX,USD,Completed,false,, 219 | 218,3,Withdrawal,10.82,2024-12-13,2,Los Angeles, CA,USD,Completed,false,, 220 | 219,1,Withdrawal,13.09,2024-10-04,3,Chicago, IL,USD,Completed,true,System,Unusual location 221 | 220,9,Withdrawal,10.94,2024-11-07,4,Phoenix, AZ,USD,Completed,false,, 222 | 221,8,Purchase,10.87,2024-11-19,5,Philadelphia, PA,USD,Completed,false,, 223 | 222,6,Purchase,11.16,2024-12-17,1,Los Angeles, CA,USD,Completed,false,, 224 | 223,7,Purchase,12.95,2024-11-21,3,New York, NY,USD,Completed,true,System,Large transaction 225 | 224,3,Withdrawal,12.21,2024-10-24,4,Los Angeles, CA,USD,Completed,false,, 226 | 225,2,Withdrawal,11.95,2024-12-16,8,Philadelphia, PA,USD,Completed,false,, 227 | 226,1,Purchase,12.29,2024-10-11,3,Los Angeles, CA,USD,Completed,true,System,Multiple password attempts 228 | 227,2,Withdrawal,12.60,2024-12-04,10,San Diego, CA,USD,Completed,false,, 229 | 228,5,Purchase,10.62,2024-12-14,5,Phoenix, AZ,USD,Completed,false,, 230 | 229,8,Purchase,10.26,2024-11-05,3,Chicago, IL,USD,Completed,true,System,Unusual location 231 | 230,1,Purchase,12.59,2024-10-14,1,Dallas, TX,USD,Completed,false,, 232 | 231,6,Withdrawal,11.37,2024-12-26,7,San Diego, CA,USD,Completed,false,, 233 | 232,9,Withdrawal,12.27,2024-12-17,8,San Antonio, TX,USD,Completed,false,, 234 | 233,5,Purchase,12.91,2024-12-26,9,San Antonio, TX,USD,Completed,false,, 235 | 234,1,Purchase,10.03,2024-11-03,9,San Francisco, CA,USD,Completed,false,, 236 | 235,9,Withdrawal,12.45,2024-11-08,6,Houston, TX,USD,Completed,false,, 237 | 236,10,Withdrawal,11.74,2024-12-05,10,San Diego, CA,USD,Completed,false,, 238 | 237,10,Purchase,11.75,2024-11-04,8,San Antonio, TX,USD,Completed,false,, 239 | 238,4,Purchase,10.95,2024-12-28,7,San Antonio, TX,USD,Completed,false,, 240 | 239,9,Withdrawal,12.42,2024-10-23,10,San Diego, CA,USD,Completed,false,, 241 | 240,7,Withdrawal,12.61,2024-12-08,4,Los Angeles, CA,USD,Completed,true,System,Exceeds daily limit 242 | 241,9,Purchase,11.85,2024-12-14,10,Dallas, TX,USD,Completed,false,, 243 | 242,10,Purchase,11.60,2024-11-09,1,Dallas, TX,USD,Completed,false,, 244 | 243,8,Withdrawal,12.63,2024-10-08,2,San Francisco, CA,USD,Completed,false,, 245 | 244,4,Purchase,10.59,2024-11-03,6,San Antonio, TX,USD,Completed,false,, 246 | 245,6,Purchase,10.47,2024-10-26,3,Chicago, IL,USD,Completed,true,System,Unusual location 247 | 246,8,Purchase,10.37,2024-12-22,5,Philadelphia, PA,USD,Completed,false,, 248 | 247,7,Withdrawal,11.50,2024-10-28,4,Los Angeles, CA,USD,Completed,true,System,Exceeds daily limit 249 | 248,1,Withdrawal,12.38,2024-12-19,8,Philadelphia, PA,USD,Completed,false,, 250 | 249,2,Withdrawal,10.68,2024-10-23,6,Philadelphia, PA,USD,Completed,false,, 251 | 250,7,Withdrawal,13.15,2024-10-11,8,Dallas, TX,USD,Completed,false,, 252 | -------------------------------------------------------------------------------- /lib/assets/tables.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "customers", 4 | "columns": [ 5 | { 6 | "name": "customer_id", 7 | "type": "int", 8 | "comment": "A unique identifier for each customer. Serves as the primary key for this table." 9 | }, 10 | { 11 | "name": "first_name", 12 | "type": "string", 13 | "comment": "The first name of the customer." 14 | }, 15 | { 16 | "name": "last_name", 17 | "type": "string", 18 | "comment": "The last name of the customer." 19 | }, 20 | { 21 | "name": "email", 22 | "type": "string", 23 | "comment": "The email address of the customer." 24 | }, 25 | { 26 | "name": "phone", 27 | "type": "string", 28 | "comment": "The phone number of the customer." 29 | }, 30 | { 31 | "name": "date_of_birth", 32 | "type": "string", 33 | "comment": "The date of birth of the customer." 34 | }, 35 | { 36 | "name": "address", 37 | "type": "string", 38 | "comment": "The street address of the customer." 39 | }, 40 | { 41 | "name": "city", 42 | "type": "string", 43 | "comment": "The city where the customer resides." 44 | }, 45 | { 46 | "name": "state", 47 | "type": "string", 48 | "comment": "The state where the customer resides." 49 | }, 50 | { 51 | "name": "zipcode", 52 | "type": "string", 53 | "comment": "The postal code for the customer's address." 54 | } 55 | ] 56 | }, 57 | { 58 | "name": "accounts", 59 | "columns": [ 60 | { 61 | "name": "account_id", 62 | "type": "int", 63 | "comment": "A unique identifier for each bank account. Serves as the primary key for this table." 64 | }, 65 | { 66 | "name": "customer_id", 67 | "type": "int", 68 | "comment": "The customer who owns the bank account. Acts as a foreign key referencing the 'Customers' table." 69 | }, 70 | { 71 | "name": "account_type", 72 | "type": "string", 73 | "comment": "The type of the bank account (e.g., savings, checking)." 74 | }, 75 | { 76 | "name": "account_status", 77 | "type": "string", 78 | "comment": "The current status of the account (e.g., active, closed)." 79 | }, 80 | { 81 | "name": "created_date", 82 | "type": "string", 83 | "comment": "The date when the bank account was created." 84 | }, 85 | { 86 | "name": "closed_date", 87 | "type": "string", 88 | "comment": "The date when the bank account was closed, if applicable (nullable)." 89 | }, 90 | { 91 | "name": "current_balance", 92 | "type": "float", 93 | "comment": "The current balance in the bank account." 94 | }, 95 | { 96 | "name": "branch_id", 97 | "type": "int", 98 | "comment": "The bank branch where the account is managed. Acts as a foreign key referencing the 'Bank_Branches' table." 99 | } 100 | ] 101 | }, 102 | { 103 | "name": "transactions", 104 | "columns": [ 105 | { 106 | "name": "transaction_id", 107 | "type": "int", 108 | "comment": "A unique identifier for each transaction. Serves as the primary key for this table." 109 | }, 110 | { 111 | "name": "account_id", 112 | "type": "int", 113 | "comment": "The bank account associated with this transaction. Acts as a foreign key referencing the 'Accounts' table." 114 | }, 115 | { 116 | "name": "transaction_type", 117 | "type": "string", 118 | "comment": "The type of transaction (e.g., withdrawal, deposit)." 119 | }, 120 | { 121 | "name": "amount", 122 | "type": "float", 123 | "comment": "The amount of money involved in the transaction." 124 | }, 125 | { 126 | "name": "transaction_date", 127 | "type": "string", 128 | "comment": "The date when the transaction occurred." 129 | }, 130 | { 131 | "name": "merchant_id", 132 | "type": "int", 133 | "comment": "The merchant involved in the transaction. Acts as a foreign key referencing the 'Merchants' table." 134 | }, 135 | { 136 | "name": "city", 137 | "type": "string", 138 | "comment": "The city where the transaction took place." 139 | }, 140 | { 141 | "name": "state", 142 | "type": "string", 143 | "comment": "The state where the transaction took place." 144 | }, 145 | { 146 | "name": "currency", 147 | "type": "string", 148 | "comment": "The currency used in the transaction." 149 | }, 150 | { 151 | "name": "transaction_status", 152 | "type": "string", 153 | "comment": "The current status of the transaction (e.g., completed, pending)." 154 | }, 155 | { 156 | "name": "fraud_flag", 157 | "type": "boolean", 158 | "comment": "A flag indicating if the transaction is suspected to be fraudulent." 159 | }, 160 | { 161 | "name": "flagged_by", 162 | "type": "string", 163 | "comment": "The entity that flagged the transaction as potentially fraudulent." 164 | }, 165 | { 166 | "name": "fraud_reason", 167 | "type": "string", 168 | "comment": "The reason for flagging the transaction as potentially fraudulent." 169 | } 170 | ] 171 | }, 172 | { 173 | "name": "merchants", 174 | "columns": [ 175 | { 176 | "name": "merchant_id", 177 | "type": "int", 178 | "comment": "A unique identifier for each merchant. Serves as the primary key for this table." 179 | }, 180 | { 181 | "name": "merchant_name", 182 | "type": "string", 183 | "comment": "The name of the merchant." 184 | }, 185 | { 186 | "name": "category", 187 | "type": "string", 188 | "comment": "The category or type of goods or services the merchant provides." 189 | }, 190 | { 191 | "name": "address", 192 | "type": "string", 193 | "comment": "The street address of the merchant's location." 194 | }, 195 | { 196 | "name": "city", 197 | "type": "string", 198 | "comment": "The city where the merchant is located." 199 | }, 200 | { 201 | "name": "state", 202 | "type": "string", 203 | "comment": "The state where the merchant is located." 204 | }, 205 | { 206 | "name": "zipcode", 207 | "type": "string", 208 | "comment": "The postal code for the merchant's location." 209 | }, 210 | { 211 | "name": "country", 212 | "type": "string", 213 | "comment": "The country where the merchant is located." 214 | } 215 | ] 216 | }, 217 | { 218 | "name": "fraud_alerts", 219 | "columns": [ 220 | { 221 | "name": "alert_id", 222 | "type": "int", 223 | "comment": "A unique identifier for each fraud alert. Serves as the primary key for this table." 224 | }, 225 | { 226 | "name": "transaction_id", 227 | "type": "int", 228 | "comment": "The transaction associated with the fraud alert. Acts as a foreign key referencing the 'Transactions' table." 229 | }, 230 | { 231 | "name": "alert_type", 232 | "type": "string", 233 | "comment": "The type of fraud alert (e.g., unusual transaction, high transaction amount)." 234 | }, 235 | { 236 | "name": "generated_by", 237 | "type": "string", 238 | "comment": "The entity that generated the fraud alert." 239 | }, 240 | { 241 | "name": "alert_date", 242 | "type": "string", 243 | "comment": "The date when the fraud alert was generated." 244 | }, 245 | { 246 | "name": "alert_status", 247 | "type": "string", 248 | "comment": "The current status of the fraud alert (e.g., open, resolved)." 249 | }, 250 | { 251 | "name": "severity_level", 252 | "type": "string", 253 | "comment": "The severity level of the fraud alert (e.g., low, high)." 254 | }, 255 | { 256 | "name": "notes", 257 | "type": "string", 258 | "comment": "Additional notes or details about the fraud alert." 259 | } 260 | ] 261 | }, 262 | { 263 | "name": "rules_engine", 264 | "columns": [ 265 | { 266 | "name": "rule_id", 267 | "type": "int", 268 | "comment": "A unique identifier for each fraud detection rule. Serves as the primary key for this table." 269 | }, 270 | { 271 | "name": "rule_name", 272 | "type": "string", 273 | "comment": "The name of the fraud detection rule." 274 | }, 275 | { 276 | "name": "rule_description", 277 | "type": "string", 278 | "comment": "A detailed description of the fraud detection rule." 279 | }, 280 | { 281 | "name": "severity_level", 282 | "type": "string", 283 | "comment": "The severity level assigned to the fraud detection rule." 284 | }, 285 | { 286 | "name": "created_date", 287 | "type": "string", 288 | "comment": "The date when the fraud detection rule was created." 289 | }, 290 | { 291 | "name": "modified_date", 292 | "type": "string", 293 | "comment": "The date when the fraud detection rule was last modified." 294 | }, 295 | { 296 | "name": "is_active", 297 | "type": "boolean", 298 | "comment": "Indicates whether the fraud detection rule is currently active." 299 | }, 300 | { 301 | "name": "hit_count", 302 | "type": "int", 303 | "comment": "The number of times the rule has triggered on transactions." 304 | }, 305 | { 306 | "name": "false_positive_rate", 307 | "type": "float", 308 | "comment": "The rate of false positives for this rule." 309 | }, 310 | { 311 | "name": "last_reviewed", 312 | "type": "string", 313 | "comment": "The date when the rule was last reviewed." 314 | } 315 | ] 316 | }, 317 | { 318 | "name": "devices", 319 | "columns": [ 320 | { 321 | "name": "device_id", 322 | "type": "int", 323 | "comment": "A unique identifier for each device. Serves as the primary key for this table." 324 | }, 325 | { 326 | "name": "customer_id", 327 | "type": "int", 328 | "comment": "The customer who owns the device. Acts as a foreign key referencing the 'Customers' table." 329 | }, 330 | { 331 | "name": "device_type", 332 | "type": "string", 333 | "comment": "The type of device (e.g., smartphone, laptop)." 334 | }, 335 | { 336 | "name": "device_os", 337 | "type": "string", 338 | "comment": "The operating system of the device." 339 | }, 340 | { 341 | "name": "device_model", 342 | "type": "string", 343 | "comment": "The model of the device." 344 | }, 345 | { 346 | "name": "last_login_date", 347 | "type": "string", 348 | "comment": "The last login date of the device." 349 | }, 350 | { 351 | "name": "is_blacklisted", 352 | "type": "boolean", 353 | "comment": "A flag indicating if the device is blacklisted." 354 | }, 355 | { 356 | "name": "fraud_score", 357 | "type": "float", 358 | "comment": "The fraud score associated with the device." 359 | } 360 | ] 361 | }, 362 | { 363 | "name": "locations", 364 | "columns": [ 365 | { 366 | "name": "location_id", 367 | "type": "int", 368 | "comment": "A unique identifier for each location. Serves as the primary key for this table." 369 | }, 370 | { 371 | "name": "transaction_id", 372 | "type": "int", 373 | "comment": "The transaction associated with the location. Acts as a foreign key referencing the 'Transactions' table." 374 | }, 375 | { 376 | "name": "country", 377 | "type": "string", 378 | "comment": "The country where the transaction occurred." 379 | }, 380 | { 381 | "name": "city", 382 | "type": "string", 383 | "comment": "The city where the transaction occurred." 384 | }, 385 | { 386 | "name": "state", 387 | "type": "string", 388 | "comment": "The state where the transaction occurred." 389 | }, 390 | { 391 | "name": "zipcode", 392 | "type": "string", 393 | "comment": "The postal code for the transaction location." 394 | } 395 | ] 396 | }, 397 | { 398 | "name": "transaction_history", 399 | "columns": [ 400 | { 401 | "name": "history_id", 402 | "type": "int", 403 | "comment": "A unique identifier for each transaction history record. Serves as the primary key for this table." 404 | }, 405 | { 406 | "name": "transaction_id", 407 | "type": "int", 408 | "comment": "The transaction associated with the history. Acts as a foreign key referencing the 'Transactions' table." 409 | }, 410 | { 411 | "name": "previous_balance", 412 | "type": "float", 413 | "comment": "The balance before the transaction occurred." 414 | }, 415 | { 416 | "name": "new_balance", 417 | "type": "float", 418 | "comment": "The balance after the transaction occurred." 419 | }, 420 | { 421 | "name": "transaction_date", 422 | "type": "string", 423 | "comment": "The date when the transaction occurred." 424 | }, 425 | { 426 | "name": "transaction_time", 427 | "type": "string", 428 | "comment": "The time when the transaction occurred." 429 | }, 430 | { 431 | "name": "is_fraud", 432 | "type": "boolean", 433 | "comment": "A flag indicating if the transaction is suspected to be fraudulent." 434 | }, 435 | { 436 | "name": "fraud_check_level", 437 | "type": "string", 438 | "comment": "The level of fraud check conducted on the transaction." 439 | }, 440 | { 441 | "name": "processed_by", 442 | "type": "string", 443 | "comment": "The entity that processed the transaction." 444 | }, 445 | { 446 | "name": "review_status", 447 | "type": "string", 448 | "comment": "The status of the review process for the transaction." 449 | }, 450 | { 451 | "name": "review_date", 452 | "type": "string", 453 | "comment": "The date when the transaction was reviewed, if applicable (nullable)." 454 | }, 455 | { 456 | "name": "reviewer_comments", 457 | "type": "string", 458 | "comment": "Any comments provided during the review process, if applicable (nullable)." 459 | } 460 | ] 461 | }, 462 | { 463 | "name": "suspicious_patterns", 464 | "columns": [ 465 | { 466 | "name": "pattern_id", 467 | "type": "int", 468 | "comment": "A unique identifier for each suspicious pattern. Serves as the primary key for this table." 469 | }, 470 | { 471 | "name": "transaction_id", 472 | "type": "int", 473 | "comment": "The transaction associated with the suspicious pattern. Acts as a foreign key referencing the 'Transactions' table." 474 | }, 475 | { 476 | "name": "pattern_type", 477 | "type": "string", 478 | "comment": "The type of suspicious pattern detected." 479 | }, 480 | { 481 | "name": "pattern_description", 482 | "type": "string", 483 | "comment": "A detailed description of the suspicious pattern." 484 | }, 485 | { 486 | "name": "severity_level", 487 | "type": "string", 488 | "comment": "The severity level of the suspicious pattern." 489 | }, 490 | { 491 | "name": "date_detected", 492 | "type": "string", 493 | "comment": "The date when the suspicious pattern was detected." 494 | }, 495 | { 496 | "name": "is_resolved", 497 | "type": "boolean", 498 | "comment": "A flag indicating if the suspicious pattern is resolved." 499 | }, 500 | { 501 | "name": "resolved_date", 502 | "type": "string", 503 | "comment": "The date when the suspicious pattern was resolved, if applicable (nullable)." 504 | }, 505 | { 506 | "name": "resolved_by", 507 | "type": "string", 508 | "comment": "The entity that resolved the suspicious pattern, if applicable." 509 | }, 510 | { 511 | "name": "comments", 512 | "type": "string", 513 | "comment": "Any comments provided regarding the suspicious pattern, if applicable (nullable)." 514 | } 515 | ] 516 | }, 517 | { 518 | "name": "bank_branches", 519 | "columns": [ 520 | { 521 | "name": "branch_id", 522 | "type": "int", 523 | "comment": "A unique identifier for each bank branch. Serves as the primary key for this table." 524 | }, 525 | { 526 | "name": "branch_name", 527 | "type": "string", 528 | "comment": "The name of the bank branch." 529 | }, 530 | { 531 | "name": "address", 532 | "type": "string", 533 | "comment": "The street address of the bank branch." 534 | }, 535 | { 536 | "name": "city", 537 | "type": "string", 538 | "comment": "The city where the bank branch is located." 539 | }, 540 | { 541 | "name": "state", 542 | "type": "string", 543 | "comment": "The state where the bank branch is located." 544 | } 545 | ] 546 | }, 547 | { 548 | "name": "cards", 549 | "columns": [ 550 | { 551 | "name": "card_id", 552 | "type": "int", 553 | "comment": "A unique identifier for each card. Serves as the primary key for this table." 554 | }, 555 | { 556 | "name": "customer_id", 557 | "type": "int", 558 | "comment": "The customer who owns the card. Acts as a foreign key referencing the 'Customers' table." 559 | }, 560 | { 561 | "name": "card_number", 562 | "type": "string", 563 | "comment": "The masked or tokenized card number for security." 564 | }, 565 | { 566 | "name": "card_type", 567 | "type": "string", 568 | "comment": "The type of card (e.g., debit, credit)." 569 | }, 570 | { 571 | "name": "expiration_date", 572 | "type": "string", 573 | "comment": "The expiration date of the card." 574 | }, 575 | { 576 | "name": "cvv", 577 | "type": "string", 578 | "comment": "The CVV code for the card." 579 | }, 580 | { 581 | "name": "issue_date", 582 | "type": "string", 583 | "comment": "The issue date of the card." 584 | }, 585 | { 586 | "name": "status", 587 | "type": "string", 588 | "comment": "The status of the card (e.g., active, blocked)." 589 | }, 590 | { 591 | "name": "last_used_date", 592 | "type": "string", 593 | "comment": "The last date the card was used." 594 | } 595 | ] 596 | }, 597 | { 598 | "name": "card_transactions", 599 | "columns": [ 600 | { 601 | "name": "card_transaction_id", 602 | "type": "int", 603 | "comment": "A unique identifier for each card transaction. Serves as the primary key for this table." 604 | }, 605 | { 606 | "name": "card_id", 607 | "type": "int", 608 | "comment": "The card associated with the transaction. Acts as a foreign key referencing the 'Cards' table." 609 | }, 610 | { 611 | "name": "transaction_id", 612 | "type": "int", 613 | "comment": "The transaction associated with the card transaction. Acts as a foreign key referencing the 'Transactions' table." 614 | }, 615 | { 616 | "name": "transaction_type", 617 | "type": "string", 618 | "comment": "The type of card transaction (e.g., purchase, cash withdrawal)." 619 | }, 620 | { 621 | "name": "amount", 622 | "type": "float", 623 | "comment": "The amount of money involved in the card transaction." 624 | }, 625 | { 626 | "name": "transaction_date", 627 | "type": "string", 628 | "comment": "The date when the card transaction occurred." 629 | }, 630 | { 631 | "name": "merchant_id", 632 | "type": "int", 633 | "comment": "The merchant involved in the card transaction. Acts as a foreign key referencing the 'Merchants' table." 634 | }, 635 | { 636 | "name": "location", 637 | "type": "string", 638 | "comment": "The location where the card transaction occurred." 639 | }, 640 | { 641 | "name": "currency", 642 | "type": "string", 643 | "comment": "The currency used in the card transaction." 644 | }, 645 | { 646 | "name": "transaction_status", 647 | "type": "string", 648 | "comment": "The status of the card transaction (e.g., completed, pending)." 649 | }, 650 | { 651 | "name": "fraud_flag", 652 | "type": "boolean", 653 | "comment": "A flag indicating if the card transaction is suspected to be fraudulent." 654 | }, 655 | { 656 | "name": "flagged_by", 657 | "type": "string", 658 | "comment": "The entity that flagged the card transaction as potentially fraudulent." 659 | }, 660 | { 661 | "name": "fraud_reason", 662 | "type": "string", 663 | "comment": "The reason for flagging the card transaction as potentially fraudulent." 664 | } 665 | ] 666 | } 667 | ] 668 | -------------------------------------------------------------------------------- /lib/db-stack.ts: -------------------------------------------------------------------------------- 1 | import * as path from "path"; 2 | import * as fs from 'fs'; 3 | import { Stack, StackProps, RemovalPolicy, CfnOutput } from "aws-cdk-lib"; 4 | import * as glue from "aws-cdk-lib/aws-glue"; 5 | import * as s3 from "aws-cdk-lib/aws-s3"; 6 | import * as s3deploy from "aws-cdk-lib/aws-s3-deployment"; 7 | import { Construct } from "constructs"; 8 | 9 | 10 | export class AthenaStack extends Stack { 11 | public readonly ATHENA_OUTPUT_BUCKET: s3.Bucket; 12 | public readonly ATHENA_DATA_BUCKET: s3.Bucket; 13 | public readonly ATHENA_DATABASE: glue.CfnDatabase; 14 | 15 | constructor(scope: Construct, id: string, props: StackProps) { 16 | super(scope, id, props); 17 | 18 | // Create S3 buckets for Athena 19 | this.ATHENA_DATA_BUCKET = new s3.Bucket(this, "AthenaDataBucket", { 20 | bucketName: `fraud-data-store-${this.account}-${this.region}`, 21 | enforceSSL: true, 22 | versioned: true, 23 | encryption: s3.BucketEncryption.S3_MANAGED, 24 | removalPolicy: RemovalPolicy.DESTROY, 25 | autoDeleteObjects: true, 26 | blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL, 27 | serverAccessLogsPrefix: "athena-data-bucket-logs/", 28 | }); 29 | 30 | this.ATHENA_OUTPUT_BUCKET = new s3.Bucket(this, "AthenaOutputBucket", { 31 | bucketName: `fraud-athena-output-${this.account}-${this.region}`, 32 | enforceSSL: true, 33 | versioned: true, 34 | encryption: s3.BucketEncryption.S3_MANAGED, 35 | removalPolicy: RemovalPolicy.DESTROY, 36 | autoDeleteObjects: true, 37 | blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL, 38 | serverAccessLogsPrefix: "athena-output-bucket-logs/", 39 | }); 40 | 41 | // Upload a sample csv file 42 | const dataDir = path.join(__dirname, "assets/data"); 43 | const subDirs = fs.readdirSync(dataDir).filter((file) => fs.statSync(path.join(dataDir, file)).isDirectory()); 44 | 45 | subDirs.forEach((subDir) => { 46 | new s3deploy.BucketDeployment(this, `Deploy${subDir.replace(/[^a-zA-Z0-9]/g, '')}SampleTable`, { 47 | sources: [s3deploy.Source.asset(path.join(dataDir, subDir))], 48 | destinationBucket: this.ATHENA_DATA_BUCKET, 49 | destinationKeyPrefix: `${subDir}`, 50 | }); 51 | }); 52 | 53 | 54 | // Create Athena Database 55 | this.ATHENA_DATABASE = new glue.CfnDatabase(this, "AthenaDatabase", { 56 | catalogId: this.account, 57 | databaseInput: { 58 | name: "fraud_data", 59 | }, 60 | }); 61 | 62 | // Create Glue Tables 63 | const tableConfig = JSON.parse(fs.readFileSync('lib/assets/tables.json', 'utf-8')); 64 | tableConfig.forEach((table: any) => { 65 | new glue.CfnTable(this, table.name, { 66 | catalogId: this.account, 67 | databaseName: this.ATHENA_DATABASE.ref!, 68 | tableInput: { 69 | name: table.name, 70 | tableType: "EXTERNAL_TABLE", 71 | parameters: { 72 | "skip.header.line.count": "1", 73 | }, 74 | storageDescriptor: { 75 | location: `s3://${this.ATHENA_DATA_BUCKET.bucketName}/${table.name}`, 76 | inputFormat: "org.apache.hadoop.mapred.TextInputFormat", 77 | outputFormat: "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat", 78 | serdeInfo: { 79 | serializationLibrary: "org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe", 80 | parameters: { 81 | "field.delim": ",", 82 | "line.delim": "\n", 83 | }}, 84 | columns: table.columns, 85 | }, 86 | 87 | }, 88 | }); 89 | }); 90 | 91 | // Outputs 92 | new CfnOutput(this, "AthenaDataBucketName", { 93 | value: this.ATHENA_DATA_BUCKET.bucketName, 94 | description: "Athena Data Bucket Name", 95 | }); 96 | 97 | new CfnOutput(this, "AthenaOutputBucketName", { 98 | value: this.ATHENA_OUTPUT_BUCKET.bucketName, 99 | description: "Athena Output Bucket Name", 100 | }); 101 | 102 | new CfnOutput(this, "AthenaDatabaseName", { 103 | value: this.ATHENA_DATABASE.ref, 104 | description: "Athena Database Name", 105 | }); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "agentic-text2sql", 3 | "version": "0.1.0", 4 | "bin": { 5 | "agentic-text2sql": "bin/agentic-text2sql.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest", 11 | "cdk": "cdk" 12 | }, 13 | "devDependencies": { 14 | "@aws-cdk/aws-lambda-python-alpha": "^2.179.0-alpha.0", 15 | "@cdklabs/generative-ai-cdk-constructs": "^0.1.293", 16 | "@types/jest": "^29.5.14", 17 | "@types/node": "22.7.9", 18 | "aws-cdk": "latest", 19 | "aws-cdk-lib": "^2.189.1", 20 | "cdk-nag": "^2.35.2", 21 | "constructs": "^10.4.2", 22 | "jest": "^29.7.0", 23 | "ts-jest": "^29.2.5", 24 | "ts-node": "^10.9.2", 25 | "typescript": "~5.6.3" 26 | }, 27 | "dependencies": { 28 | "aws-cdk-lib": "^2.189.1", 29 | "constructs": "^10.0.0", 30 | "source-map-support": "^0.5.21" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /prompt/instruction.txt: -------------------------------------------------------------------------------- 1 | 1. Query Analysis: 2 | - Understand the user's main objective 3 | - Break down into sub-queries if necessary 4 | - Identify potential variations in user input (e.g., 'Korea', 'South Korea', 'Republic of Korea') 5 | 6 | 2. Schema Discovery: 7 | - Use /list_tables endpoint to identify available tables in the database 8 | - Use /describe_table endpoint to get detailed schema information for specific tables 9 | - Always use the most recent and relevant table schemas, as the database structure may change frequently 10 | - Before constructing queries, ensure you have up-to-date schema information 11 | 12 | 3. Database and Table Usage: 13 | - IMPORTANT: Always use the 'fraud_data' database for all queries. Do not use any other database. 14 | Correct: SELECT * FROM fraud_data.accounts 15 | Incorrect: SELECT * FROM default.accounts 16 | Incorrect: SELECT * FROM accounts 17 | - Always use fully qualified table names with the 'fraud_data' database prefix 18 | Correct: SELECT column1, column2 FROM fraud_data.table_name 19 | Incorrect: SELECT column1, column2 FROM table_name 20 | - The following tables are available in the fraud_data database: 21 | accounts, bank_branches, card_transactions, cards, customers, devices, 22 | fraud_alerts, locations, merchants, rules_engine, suspicious_patterns, 23 | transaction_history, transaction 24 | - Any attempt to query tables not in this list or in other databases will fail 25 | 26 | 4. Query Optimization Techniques: 27 | - Implement flexible matching: 28 | - Anticipate and account for synonyms or alternative phrasings in user requests 29 | - LOWER() for case-insensitive matching 30 | - '%' wildcards for variations 31 | Example: WHERE LOWER(country) LIKE LOWER('%korea%') 32 | - Use proper TIMESTAMP format 33 | Example: WHERE datetime BETWEEN TIMESTAMP '2024-01-01 00:00:00' AND '2024-01-31 23:59:59' 34 | - For efficient results, use aggregate functions: 35 | - COUNT() - for counting records 36 | - SUM() - for totaling values 37 | - AVG() - for averaging values 38 | - Use subqueries/CASE statements when needed 39 | 40 | 5. Amazon Athena SQL Considerations: 41 | - Amazon Athena's SQL dialect is based on Presto and complies with ANSI SQL 42 | - Use standard SQL functions and operators supported by Athena 43 | - Be aware that Athena does not support stored procedures or user-defined functions 44 | - Remember that Athena is case-insensitive for SQL statements but case-sensitive for string comparisons 45 | - Utilize Athena's support for complex data types like arrays and structs when appropriate 46 | - Consider using Athena's geospatial functions if dealing with geographic data 47 | - Be mindful of Athena's limitations on certain operations, such as UPDATE or DELETE statements 48 | - Optimize queries for performance, considering Athena's distributed query execution model 49 | 50 | 6. Execution and Error Handling: 51 | - Execute the query via the /athena_query endpoint 52 | - If the execution fails, carefully analyze the error message and hint provided by the Lambda function 53 | - Based on the error type received from the Lambda function, take appropriate action: 54 | * MISSING_PROPERTIES: Review the API request and ensure all required parameters are included 55 | * MISSING_QUERY: Verify that you've generated and included a SQL query in the request 56 | * MISSING_DATABASE_NAME: Add the database name to your query or in the request parameters 57 | * MISSING_TABLE_NAME: Include the specific table name in your query or request parameters 58 | * QUERY_EXECUTION_FAILED: Check and correct the use of fully qualified table names (e.g., fraud_data.customers) 59 | * QUERY_RESULT_ERROR: Review and correct table and column names, considering potential permission issues 60 | * INVALID_API_PATH_SCHEMA: Ensure you're using the correct API endpoint for schema-related operations 61 | * INVALID_API_PATH_QUERY: Confirm you're using the /athena_query endpoint for query execution 62 | * INTERNAL_ERROR: Prepare to retry the query or suggest the user contact support if the issue persists 63 | - After identifying the issue based on the error message and hint: 64 | 1. Modify your query or API request to address the specific problem 65 | 2. If needed, use schema discovery tools (/list_tables, /describe_table) to gather updated information 66 | 3. Reconstruct the query with the necessary corrections 67 | 4. Retry the execution with the modified query or request 68 | - If errors persist after multiple attempts: 69 | 1. Explain the issue to the user in clear, non-technical language 70 | 2. Provide details on what has been tried and why it might be failing 71 | 3. If appropriate, suggest alternative approaches or ask for more information from the user 72 | 73 | Always include the generated SQL query, execution results, and a clear explanation of the logic and findings in your response. 74 | If an error occurs, provide the specific error message and hint from the predefined error types. If multiple queries are needed to fulfill a request, explain the process and results of each step. 75 | 76 | Remember: 77 | - Use schema discovery tools (/list_tables, /describe_table) before constructing queries 78 | - Use fully qualified table names (e.g., fraud_data.customers) 79 | - Available API endpoints: /athena_query, /describe_table, /list_tables 80 | - The database structure may change frequently, always use the most up-to-date schema information 81 | - Always consider data security and access permissions when executing queries 82 | 83 | Sample Questions and Queries: 84 | 85 | Question: "Retrieve all transactions for a specific customer within a date range, including fraud flags and merchant details" 86 | Query: SELECT t.transaction_id, t.transaction_type, t.amount, t.transaction_date, t.fraud_flag, m.merchant_name, m.category 87 | FROM transactions t 88 | JOIN accounts a ON t.account_id = a.account_id 89 | JOIN customers c ON a.customer_id = c.customer_id 90 | JOIN merchants m ON t.merchant_id = m.merchant_id 91 | WHERE c.first_name = 'John' 92 | AND c.last_name = 'Doe' 93 | AND t.transaction_date BETWEEN '2023-01-01' AND '2023-12-31'; 94 | 95 | Question: "Identify all customers who have had more than 3 fraud alerts in the last 6 months" 96 | Query: SELECT c.customer_id, c.first_name, c.last_name, COUNT(fa.alert_id) AS fraud_alert_count 97 | FROM customers c 98 | JOIN accounts a ON c.customer_id = a.customer_id 99 | JOIN transactions t ON a.account_id = t.account_id 100 | JOIN fraud_alerts fa ON t.transaction_id = fa.transaction_id 101 | WHERE fa.alert_date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) AND CURRENT_DATE 102 | GROUP BY c.customer_id, c.first_name, c.last_name 103 | HAVING COUNT(fa.alert_id) > 3; 104 | 105 | Question: "Find all transactions that occurred in a specific country and were flagged as fraudulent, along with the device information used for those transactions" 106 | Query: SELECT t.transaction_id, t.transaction_type, t.amount, t.transaction_date, 107 | d.device_id, d.device_type, d.device_os, d.device_model 108 | FROM transactions t 109 | JOIN locations l ON t.transaction_id = l.transaction_id 110 | JOIN devices d ON t.account_id = d.customer_id 111 | WHERE l.country = 'United States' 112 | AND t.fraud_flag = 'true'; -------------------------------------------------------------------------------- /src/athena_query/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/sample-Dynamic-Text-to-SQL-with-Amazon-Bedrock-Agent/22e4713ac5c7d08923704190d062abcddea506b9/src/athena_query/__init__.py -------------------------------------------------------------------------------- /src/athena_query/athena_query.py: -------------------------------------------------------------------------------- 1 | import re 2 | from aws_lambda_powertools import Logger 3 | from aws_lambda_powertools.event_handler import BedrockAgentResolver 4 | from athena_utils import execute_and_get_results, initialize_s3_output 5 | from error_utils import get_error_response 6 | from request_utils import get_property_value 7 | from response_utils import create_api_response 8 | 9 | app = BedrockAgentResolver() 10 | logger = Logger() 11 | 12 | s3_output = initialize_s3_output() 13 | 14 | @logger.inject_lambda_context 15 | def lambda_handler(event, context): 16 | logger.info(f"Received event: {event}") 17 | 18 | try: 19 | properties = event['requestBody']['content']['application/json']['properties'] 20 | query = get_property_value( 21 | properties, 22 | 'query', 23 | 'MISSING_QUERY', 24 | 'QUERY', 25 | event 26 | ) 27 | if isinstance(query, dict): 28 | query = preprocess_query(query) 29 | return query 30 | 31 | logger.info(f"Executing query: {query}") 32 | result = execute_and_get_results(query, s3_output) 33 | if isinstance(result, str): # If it's an error message 34 | return create_api_response( 35 | event, 36 | 400, 37 | get_error_response('QUERY_EXECUTION_FAILED') 38 | ) 39 | 40 | return create_api_response(event, 200, result) 41 | 42 | except Exception as e: 43 | logger.exception(f"Error in lambda_handler: {str(e)}") 44 | return create_api_response( 45 | event, 46 | 500, 47 | { 48 | 'error': 'INTERNAL_ERROR', 49 | 'message': str(e), 50 | 'hint': 'This is an unexpected error. Please make sure your query follows the correct format and try again' 51 | } 52 | ) 53 | 54 | 55 | def preprocess_query(query): 56 | # Check if the query contains a date comparison 57 | date_pattern = r"(datetime|date)\s+BETWEEN\s+'(\d{4}-\d{2}-\d{2})'\s+AND\s+'(\d{4}-\d{2}-\d{2})'" 58 | match = re.search(date_pattern, query, re.IGNORECASE) 59 | 60 | if match: 61 | # If it does, replace the string dates with TIMESTAMP 62 | column, start_date, end_date = match.groups() 63 | modified_query = query.replace( 64 | f"{column} BETWEEN '{start_date}' AND '{end_date}'", 65 | f"{column} BETWEEN TIMESTAMP '{start_date}' AND TIMESTAMP '{end_date}'" 66 | ) 67 | return modified_query 68 | 69 | # If no date comparison is found, return the original query 70 | return query -------------------------------------------------------------------------------- /src/athena_query/openapi.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.1", 3 | "info": { 4 | "title": "AthenaQuery API", 5 | "description": "API for querying data from an Athena database", 6 | "version": "1.0.0" 7 | }, 8 | "paths": { 9 | "/athena_query": { 10 | "post": { 11 | "operationId": "athena_query", 12 | "description": "Execute a query on an Athena database", 13 | "requestBody": { 14 | "description": "Athena query details", 15 | "required": true, 16 | "content": { 17 | "application/json": { 18 | "schema": { 19 | "type": "object", 20 | "properties": { 21 | "query": { 22 | "type": "string", 23 | "description": "SQL Query" 24 | } 25 | } 26 | } 27 | } 28 | } 29 | }, 30 | "responses": { 31 | "200": { 32 | "description": "Successful response with query results", 33 | "content": { 34 | "application/json": { 35 | "schema": { 36 | "type": "object", 37 | "properties": { 38 | "ResultSet": { 39 | "type": "array", 40 | "items": { 41 | "type": "object", 42 | "description": "A single row of query results" 43 | }, 44 | "description": "Results returned by the query" 45 | } 46 | } 47 | } 48 | } 49 | } 50 | }, 51 | "default": { 52 | "description": "Error response", 53 | "content": { 54 | "application/json": { 55 | "schema": { 56 | "type": "object", 57 | "properties": { 58 | "message": { 59 | "type": "string" 60 | } 61 | } 62 | } 63 | } 64 | } 65 | } 66 | } 67 | } 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /src/athena_schema_reader/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/sample-Dynamic-Text-to-SQL-with-Amazon-Bedrock-Agent/22e4713ac5c7d08923704190d062abcddea506b9/src/athena_schema_reader/__init__.py -------------------------------------------------------------------------------- /src/athena_schema_reader/athena_schema_reader.py: -------------------------------------------------------------------------------- 1 | from aws_lambda_powertools import Logger 2 | from aws_lambda_powertools.event_handler import BedrockAgentResolver 3 | from athena_utils import execute_and_get_results, initialize_s3_output 4 | from error_utils import get_error_response 5 | from request_utils import get_property_value 6 | from response_utils import create_api_response 7 | 8 | app = BedrockAgentResolver() 9 | logger = Logger() 10 | 11 | s3_output = initialize_s3_output() 12 | 13 | @logger.inject_lambda_context 14 | def lambda_handler(event, context): 15 | logger.info(f"Received event: {event}") 16 | 17 | try: 18 | properties = event['requestBody']['content']['application/json']['properties'] 19 | except KeyError: 20 | return create_api_response( 21 | event, 22 | 404, 23 | get_error_response('MISSING_PROPERTIES') 24 | ) 25 | 26 | try: 27 | api_path = event.get('apiPath') 28 | 29 | database_name = get_property_value( 30 | properties, 31 | 'database', 32 | 'MISSING_DATABASE_NAME', 33 | 'LIST_TABLES', 34 | event 35 | ) 36 | if isinstance(database_name, dict): 37 | return database_name 38 | 39 | if api_path == '/list_tables': 40 | return list_tables(event, database_name) 41 | 42 | elif api_path == '/describe_table': 43 | table_name = get_property_value( 44 | properties, 45 | 'table', 46 | 'MISSING_TABLE_NAME', 47 | 'TABLE_SCHEMA', 48 | event 49 | ) 50 | if isinstance(table_name, dict): 51 | return table_name 52 | 53 | return describe_table(event, database_name, table_name) 54 | 55 | else: 56 | return create_api_response( 57 | event, 58 | 404, 59 | get_error_response('INVALID_API_PATH_SCHEMA') 60 | ) 61 | 62 | except Exception as e: 63 | logger.exception(f"Error in lambda_handler: {str(e)}") 64 | return create_api_response( 65 | event, 66 | 500, 67 | get_error_response('INTERNAL_ERROR') 68 | ) 69 | 70 | 71 | @app.post("/list_tables", description="Retrieve a list of all tables in the specified database") 72 | def list_tables(event, database_name): 73 | 74 | query = f"SHOW TABLES IN {database_name}" 75 | logger.info(f"Executing query: {query}") 76 | 77 | result = execute_and_get_results(query, s3_output) 78 | 79 | if isinstance(result, dict) and 'error' in result: 80 | logger.warning(f"Error listing tables: {result['error']}") 81 | return create_api_response( 82 | event, 83 | 400, 84 | get_error_response('QUERY_RESULT_ERROR') 85 | ) 86 | 87 | return create_api_response(event, 200, result) 88 | 89 | 90 | @app.post("/describe_table", description="Retrieve the schema information of a specific table") 91 | def describe_table(event, database_name, table_name): 92 | logger.info(f"Reading {table_name} schema in {database_name} database...") 93 | 94 | query = f"DESCRIBE {database_name}.{table_name}" 95 | logger.info(f"Executing query: {query}") 96 | 97 | result = execute_and_get_results(query, s3_output) 98 | 99 | if not isinstance(result, dict) or 'error' not in result: 100 | formatted_result = { 101 | "table_name": table_name, 102 | "database": database_name, 103 | "columns": result 104 | } 105 | result = formatted_result 106 | 107 | http_status_code = 400 if isinstance(result, dict) and 'error' in result else 200 108 | final_response = create_api_response(event, http_status_code, result) 109 | logger.info(f"Final response: {final_response}") 110 | 111 | return create_api_response(event, 200, result) -------------------------------------------------------------------------------- /src/athena_schema_reader/openapi.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.1", 3 | "info": { 4 | "title": "AthenaSchemaReader API", 5 | "description": "API for reading schemas from an Athena database", 6 | "version": "1.0.0" 7 | }, 8 | "paths": { 9 | "/list_tables": { 10 | "post": { 11 | "operationId": "list_tables", 12 | "description": "Retrieve a list of all tables in the specified database", 13 | "requestBody": { 14 | "description": "Database information to list tables", 15 | "required": true, 16 | "content": { 17 | "application/json": { 18 | "schema": { 19 | "type": "object", 20 | "properties": { 21 | "database": { 22 | "type": "string", 23 | "description": "Name of the database to list its tables" 24 | } 25 | } 26 | } 27 | } 28 | } 29 | }, 30 | "responses": { 31 | "200": { 32 | "description": "Successful response with show tables results", 33 | "content": { 34 | "application/json": { 35 | "schema": { 36 | "type": "object", 37 | "properties": { 38 | "ResultSet": { 39 | "type": "array", 40 | "items": { 41 | "type": "object", 42 | "description": "A single row of query results" 43 | }, 44 | "description": "Results returned by the query" 45 | } 46 | } 47 | } 48 | } 49 | } 50 | }, 51 | "default": { 52 | "description": "Error response", 53 | "content": { 54 | "application/json": { 55 | "schema": { 56 | "type": "object", 57 | "properties": { 58 | "message": { 59 | "type": "string" 60 | } 61 | } 62 | } 63 | } 64 | } 65 | } 66 | } 67 | } 68 | }, 69 | "/describe_table": { 70 | "post": { 71 | "operationId": "describe_table", 72 | "description": "Retrieve detailed column information (name, type, comment) for a specific table", 73 | "requestBody": { 74 | "description": "Database and table information to get schema details", 75 | "required": true, 76 | "content": { 77 | "application/json": { 78 | "schema": { 79 | "type": "object", 80 | "properties": { 81 | "database": { 82 | "type": "string", 83 | "description": "Name of the database containing the target table" 84 | }, 85 | "table": { 86 | "type": "string", 87 | "description": "Name of the table to retrieve schema information" 88 | } 89 | } 90 | } 91 | } 92 | } 93 | }, 94 | "responses": { 95 | "200": { 96 | "description": "Successful response with show create table results", 97 | "content": { 98 | "application/json": { 99 | "schema": { 100 | "type": "object", 101 | "properties": { 102 | "ResultSet": { 103 | "type": "array", 104 | "items": { 105 | "type": "object", 106 | "description": "A single row of query results" 107 | }, 108 | "description": "Results returned by the query" 109 | } 110 | } 111 | } 112 | } 113 | } 114 | }, 115 | "default": { 116 | "description": "Error response", 117 | "content": { 118 | "application/json": { 119 | "schema": { 120 | "type": "object", 121 | "properties": { 122 | "message": { 123 | "type": "string" 124 | } 125 | } 126 | } 127 | } 128 | } 129 | } 130 | } 131 | } 132 | } 133 | } 134 | } -------------------------------------------------------------------------------- /src/common/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/sample-Dynamic-Text-to-SQL-with-Amazon-Bedrock-Agent/22e4713ac5c7d08923704190d062abcddea506b9/src/common/__init__.py -------------------------------------------------------------------------------- /src/common/python/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/sample-Dynamic-Text-to-SQL-with-Amazon-Bedrock-Agent/22e4713ac5c7d08923704190d062abcddea506b9/src/common/python/__init__.py -------------------------------------------------------------------------------- /src/common/python/athena_utils.py: -------------------------------------------------------------------------------- 1 | import boto3 2 | import time 3 | import random 4 | from os import environ 5 | from aws_lambda_powertools import Logger 6 | 7 | logger = Logger() 8 | athena_client = boto3.client('athena') 9 | 10 | def initialize_s3_output(env_var_name='S3_OUTPUT'): 11 | """Initialize S3 output location from environment variable""" 12 | s3_output = environ.get(env_var_name) 13 | if not s3_output: 14 | raise Exception(f"{env_var_name} environment variable is not set") 15 | return f"s3://{s3_output}/query-results/" 16 | 17 | 18 | def execute_athena_query(query, s3_output): 19 | try: 20 | logger.info(f"Executing query: {query}") 21 | response = athena_client.start_query_execution( 22 | QueryString=query, 23 | ResultConfiguration={'OutputLocation': s3_output} 24 | ) 25 | execution_id = response['QueryExecutionId'] 26 | logger.info(f"Athena query execution started with ID: {execution_id}") 27 | return execution_id 28 | except Exception as e: 29 | logger.error(f"Failed to start query execution: {str(e)}") 30 | raise 31 | 32 | 33 | def get_query_execution_details(execution_id): 34 | try: 35 | response = athena_client.get_query_execution(QueryExecutionId=execution_id) 36 | execution_details = response['QueryExecution'] 37 | state = execution_details['Status']['State'] 38 | reason = execution_details['Status'].get('StateChangeReason', 'No reason provided') 39 | 40 | logger.info(f"Query execution state: {state}") 41 | logger.info(f"Query execution details: {execution_details}") 42 | 43 | return state, reason, execution_details 44 | except Exception as e: 45 | logger.error(f"Failed to get query execution details: {str(e)}") 46 | raise 47 | 48 | def get_query_results(execution_id, max_attempts=10, base_delay=1): 49 | attempt = 0 50 | while attempt < max_attempts: 51 | try: 52 | state, reason, execution_details = get_query_execution_details(execution_id) 53 | 54 | if state in ['SUCCEEDED', 'FAILED', 'CANCELLED']: 55 | break 56 | 57 | # Exponential backoff with jitter 58 | delay = min(base_delay * (2 ** attempt), 120) # Cap at 120 seconds 59 | logger.info(f"Query is not ready. Attempt {attempt + 1}. Retrying in {delay} seconds.") 60 | jitter = random.uniform(0, 0.1 * delay) 61 | time.sleep(delay + jitter) 62 | 63 | attempt += 1 64 | 65 | except Exception as e: 66 | logger.error(f"Error in attempt {attempt + 1}: {str(e)}") 67 | attempt += 1 68 | time.sleep(base_delay) 69 | 70 | if state == 'SUCCEEDED': 71 | response = athena_client.get_query_results(QueryExecutionId=execution_id) 72 | logger.info(f"The SUCCEEDED Query result: {response}") 73 | 74 | # Process and format the results 75 | columns = [col['Label'] for col in response['ResultSet']['ResultSetMetadata']['ColumnInfo']] 76 | 77 | rows = response['ResultSet']['Rows'] 78 | formatted_results = [] 79 | for row in rows: 80 | formatted_row = {} 81 | for i, value in enumerate(row['Data']): 82 | formatted_row[columns[i]] = value.get('VarCharValue', '') 83 | formatted_results.append(formatted_row) 84 | return formatted_results 85 | 86 | else: 87 | error_message = f"Query failed with status '{state}'. Reason: {reason}" 88 | logger.error(error_message) 89 | logger.error(f"Full execution details: {execution_details}") 90 | return {'error': error_message} 91 | 92 | 93 | def execute_and_get_results(query, s3_output): 94 | """Execute query and return results""" 95 | execution_id = execute_athena_query(query, s3_output) 96 | return get_query_results(execution_id) -------------------------------------------------------------------------------- /src/common/python/error_utils.py: -------------------------------------------------------------------------------- 1 | ERROR_MESSAGES = { 2 | 'MISSING_PROPERTIES': { 3 | 'message': 'No properties provided in the request', 4 | 'hint': 'Please provide the required parameters based on the API endpoint' 5 | }, 6 | 'MISSING_QUERY': { 7 | 'message': 'Query is required', 8 | 'hint': 'No query was provided. Please provide a SQL query to execute' 9 | }, 10 | 'MISSING_DATABASE_NAME': { 11 | 'message': 'Database name is required', 12 | 'hint': 'Please provide the database name using the "database" parameter' 13 | }, 14 | 'MISSING_TABLE_NAME': { 15 | 'message': 'Table name is required', 16 | 'hint': 'Please provide the table name using the "table" parameter. Examples include "customers", "transactions", or "fraud_alerts".' 17 | }, 18 | 'QUERY_EXECUTION_FAILED': { 19 | 'message': 'Failed to execute query', 20 | 'hint': 'Please use fully qualified table names. Example: SELECT * FROM fraud_data.customers LIMIT 1' 21 | }, 22 | 'QUERY_RESULT_ERROR': { 23 | 'message': 'Error occurred while getting query results', 24 | 'hint': 'Check if the tables and columns in your query exist and you have proper permissions. Examples: "customers", "transactions", or "devices".' 25 | }, 26 | 'INVALID_API_PATH_SCHEMA': { 27 | 'message': 'Unknown API path', 28 | 'hint': 'Available endpoints are: /describe_table, /list_tables. Use these to explore tables like "products", "accounts", or "merchants".' 29 | }, 30 | 'INVALID_API_PATH_QUERY': { 31 | 'message': 'Unknown API path', 32 | 'hint': 'Available endpoint is: /athena_query' 33 | }, 34 | 'INTERNAL_ERROR': { 35 | 'message': 'An unexpected error occurred', 36 | 'hint': 'Please try again or contact support' 37 | }, 38 | } 39 | 40 | EXAMPLES = { 41 | 'TABLE_SCHEMA': { 42 | 'database': 'fraud_data', 43 | 'table': 'customers' 44 | }, 45 | 'QUERY': { 46 | 'simple': 'SELECT * FROM fraud_data.transactions LIMIT 1', 47 | 'with_condition': 'SELECT * FROM fraud_data.fraud_alerts WHERE alert_date >= TIMESTAMP \'2024-01-01\'', 48 | 'join_example': ( 49 | 'SELECT c.first_name, c.last_name, t.transaction_date, t.amount ' 50 | 'FROM fraud_data.customers c ' 51 | 'JOIN fraud_data.transactions t ON c.customer_id = t.customer_id ' 52 | 'WHERE t.transaction_date BETWEEN TIMESTAMP \'2024-01-01\' AND TIMESTAMP \'2024-03-31\'' 53 | ) 54 | }, 55 | 'LIST_TABLES': { 56 | 'database': 'fraud_data' 57 | } 58 | } 59 | 60 | def get_error_response(error_code, example_type=None, **kwargs): 61 | """ 62 | Get formatted error response with optional dynamic content and specific example 63 | """ 64 | error_info = ERROR_MESSAGES.get(error_code, ERROR_MESSAGES['INTERNAL_ERROR']).copy() 65 | 66 | if 'message' in kwargs: 67 | error_info['message'] = error_info['message'] + f": {kwargs['message']}" 68 | 69 | response = { 70 | 'error': error_code, 71 | **error_info 72 | } 73 | 74 | if example_type and example_type in EXAMPLES: 75 | response['example'] = EXAMPLES[example_type] 76 | 77 | return response 78 | -------------------------------------------------------------------------------- /src/common/python/request_utils.py: -------------------------------------------------------------------------------- 1 | from response_utils import create_api_response 2 | from error_utils import get_error_response 3 | 4 | def get_property_value(properties, prop_name, error_code, example_type, event): 5 | """ 6 | Helper function to extract property value from request properties with error handling 7 | 8 | Args: 9 | properties (list): List of property dictionaries from the request 10 | prop_name (str): Name of the property to extract 11 | error_code (str): Error code to use if property is missing 12 | example_type (str): Type of example to include in error response 13 | event (dict): Original event object for creating response 14 | 15 | Returns: 16 | str: Property value if found 17 | dict: Error response if property is missing or invalid 18 | """ 19 | prop = next((p for p in properties if p.get('name') == prop_name), None) 20 | if prop is None or 'value' not in prop: 21 | return create_api_response( 22 | event, 23 | 400, 24 | get_error_response(error_code, example_type=example_type) 25 | ) 26 | return prop['value'] -------------------------------------------------------------------------------- /src/common/python/response_utils.py: -------------------------------------------------------------------------------- 1 | def create_api_response(event, http_status_code, result): 2 | """Create a standardized API response""" 3 | response_body = { 4 | 'application/json': { 5 | 'body': result if http_status_code == 200 else { 6 | 'error': result.get('error', 'UNKNOWN_ERROR'), 7 | 'message': result.get('message', 'Query execution failed'), 8 | 'hint': result.get('hint', 'Please review and modify your query') 9 | } 10 | } 11 | } 12 | 13 | action_response = { 14 | 'actionGroup': event['actionGroup'], 15 | 'apiPath': event['apiPath'], 16 | 'httpMethod': event['httpMethod'], 17 | 'httpStatusCode': http_status_code, 18 | 'responseBody': response_body 19 | } 20 | 21 | return {'messageVersion': '1.0', 'response': action_response} -------------------------------------------------------------------------------- /src/layers/aws_lambda_powertools/requirements.txt: -------------------------------------------------------------------------------- 1 | aws-lambda-powertools -------------------------------------------------------------------------------- /src/layers/pydantic/requirements.txt: -------------------------------------------------------------------------------- 1 | pydantic -------------------------------------------------------------------------------- /test/agentic-text2sql.test.ts: -------------------------------------------------------------------------------- 1 | // import * as cdk from 'aws-cdk-lib'; 2 | // import { Template } from 'aws-cdk-lib/assertions'; 3 | // import * as AgenticText2Sql from '../lib/agentic-text2sql-stack'; 4 | 5 | // example test. To run these tests, uncomment this file along with the 6 | // example resource in lib/agentic-text2sql-stack.ts 7 | test('SQS Queue Created', () => { 8 | // const app = new cdk.App(); 9 | // // WHEN 10 | // const stack = new AgenticText2Sql.AgenticText2SqlStack(app, 'MyTestStack'); 11 | // // THEN 12 | // const template = Template.fromStack(stack); 13 | 14 | // template.hasResourceProperties('AWS::SQS::Queue', { 15 | // VisibilityTimeout: 300 16 | // }); 17 | }); 18 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2020", 7 | "dom" 8 | ], 9 | "declaration": true, 10 | "strict": true, 11 | "noImplicitAny": true, 12 | "strictNullChecks": true, 13 | "noImplicitThis": true, 14 | "alwaysStrict": true, 15 | "noUnusedLocals": false, 16 | "noUnusedParameters": false, 17 | "noImplicitReturns": true, 18 | "noFallthroughCasesInSwitch": false, 19 | "inlineSourceMap": true, 20 | "inlineSources": true, 21 | "experimentalDecorators": true, 22 | "strictPropertyInitialization": false, 23 | "typeRoots": [ 24 | "./node_modules/@types" 25 | ] 26 | }, 27 | "exclude": [ 28 | "node_modules", 29 | "cdk.out" 30 | ] 31 | } 32 | --------------------------------------------------------------------------------