The Fraud Detection API is designed to process financial transaction data for fraud analysis, specifically handling CSV files. The workflow comprises a series of steps that facilitate asynchronous processing and analysis.
-
Upload Transactions:
- Users can upload a CSV file containing transaction data via the
/upload
endpoint. Uploaded files are temporarily stored in theTransactionFiles
directory. (To-Do: Will be migrated to an AWS storage bucket).
- Users can upload a CSV file containing transaction data via the
-
Analyze Transactions:
- The user then initiates the analysis by calling the
/analyze/:fileID
endpoint, passing thefile_id
obtained from the upload step. The analysis process is started asynchronously. This endpoint accepts a set of fraud detection rules in the request body.
{ "rules": [ "Rule 1 description", "Rule 2 description", // additional rules... ] }
- The user then initiates the analysis by calling the
-
Poll Analysis Status:
- While the analysis is ongoing, the user can check its status through the
/analyze/:analysisId/status
endpoint. The status provides insights into whether the analysis isProcessing
,Complete
, or hasFailed
.
- While the analysis is ongoing, the user can check its status through the
-
Retrieve Analysis Results:
- Once the analysis is complete, the results can be fetched from the
/results/:analysisId
endpoint using the providedanalysisId
. Additional Results may be returned as JSON files, which are stored in theResultFiles
directory. (To-Do: Will be migrated to an AWS storage bucket) If present, the files will be referenced in the API Response.
- Once the analysis is complete, the results can be fetched from the
-
Health Check:
- The API also includes a
/health
endpoint, allowing users to verify if the API service is operational.
- The API also includes a
Build the Image:
docker build -t frauddetection .
Run the Container
docker run -p 8080:8080 frauddetection
Access the application at http://localhost:8080
The Fraud Detection API comes with an integrated Swagger UI.
- To access the Swagger UI, first ensure the API service is running.
- Navigate to
http://localhost:8080/swagger/index.html
in your web browser. - The Swagger UI page will display a list of all available API endpoints with their expected parameters and responses.
- You can interact with the API directly from this page by expanding individual endpoint details, entering required parameters, and executing requests to see the responses in real-time.
- The application is built in Golang, selected for its robust support for concurrent and asynchronous processing using goroutines. This feature is crucial for efficiently handling the asynchronous tasks and large-scale data processing inherent in fraud detection.
- For fraud analysis, the project utilizes the OpenAI Assistants API. This Assistants API aids in analyzing transaction data to detect potential fraud patterns.