File size: 5,209 Bytes
09ffb4b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
---
title: Fraud-Detection-System
sdk: streamlit
emoji: πŸš€
colorFrom: indigo
colorTo: purple
---
# πŸ’³ Credit Card & Transaction Fraud Detection System

## Overview
A sophisticated real-time fraud detection system using ensemble machine learning models and advanced analytics to protect financial transactions.

### 🌟 Key Features
- **Real-time Fraud Detection**: Instant transaction monitoring and analysis
- **Multi-Model Ensemble**: XGBoost, LightGBM, Random Forest, and Gradient Boosting
- **Advanced Analytics Dashboard**: Interactive visualizations and insights
- **Role-Based Access Control**: User, Analyst, Manager, and Admin roles
- **Email Alert System**: Automated notifications for suspicious activities
- **Batch Processing**: Handle multiple transactions simultaneously

## πŸš€ Technical Stack
- **Frontend**: Streamlit
- **Backend**: Python
- **ML Models**: 
  - XGBoost
  - LightGBM
  - Random Forest
  - Gradient Boosting
- **Data Processing**: Pandas, NumPy
- **Visualization**: Plotly, Matplotlib
- **Security**: SHA-256 encryption

## πŸ“Š Features In Detail

### 1. Fraud Detection
- Real-time transaction scoring
- Risk level assessment (LOW, MEDIUM, HIGH, CRITICAL)
- Behavioral analysis
- Location-based risk assessment
- Velocity checks

### 2. User Interface
- Interactive dashboards
- Real-time monitoring
- Advanced visualization
- Risk score breakdown
- Transaction patterns analysis

### 3. Security Features
- Role-based access control
- Password encryption
- Session management
- Activity logging
- Audit trails

### 4. Alert System
- Email notifications
- Risk-based alerting
- Customizable thresholds
- Batch alert processing

## πŸš€ Dataset
The dataset used for this project is the [Credit Card Fraud Detection](https://www.kaggle.com/datasets/priyamchoksi/credit-card-transactions-dataset?resource=download&select=credit_card_transactions.csv)
dataset from Kaggle.

## πŸ“ Project Structure
```
Credit-Card-Fraud-Detection/
β”œβ”€β”€ πŸ“ data/                      # Data directory
β”‚   β”œβ”€β”€ users.csv                 # User credentials and roles
β”‚   β”œβ”€β”€ transactions.csv          # Dataset of credit card transactions
β”‚   └── models/                   # ML model implementations
β”‚       β”œβ”€β”€ xgb_model.json        # XGBoost model file
β”‚       └── features.pkl         # Saved feature configurations
β”‚
β”œβ”€β”€ πŸ“ .streamlit/               # Streamlit configurations
β”‚   β”œβ”€β”€ config.toml             # Streamlit settings
β”‚   └── secrets.toml            # Secure credentials
β”‚
β”œβ”€β”€ πŸ“„ app.py                    # Main Streamlit application
β”œβ”€β”€ πŸ“„ requirements.txt          # Project dependencies
β”œβ”€β”€ πŸ“„ .env                      # Environment variables
β”œβ”€β”€ πŸ“„ .gitignore               # Git ignore patterns
β”œβ”€β”€ πŸ“„ LICENSE                   # License information
└── πŸ“„ README.md                # Project documentation
```

## πŸ› οΈ Installation

1. Clone the repository:
```bash
git clone https://github.com/D3V-S4NJ4Y/Credit-Card-Fraud-Detection-System
```

2. Install required packages:
```bash
pip install -r requirements.txt
```
4. Run the application:
```bash
streamlit run app.py
```

## πŸ‘₯ User Roles

   **Default--> Usersname: Password**
   - admin: admin
   - manager: 123456
   - Register New User with Correct Email id for Email Alerts

1. **User**
   - View basic transaction details
   - Submit transactions
   - Receive alerts

3. **Manager**
   - Advanced analysis
   - Team management
   - Performance monitoring

4. **Admin**
   - Full system access
   - User management
   - System configuration

## πŸ“ˆ Analytics Features

### Transaction Analysis
- Risk scoring
- Behavioral patterns
- Anomaly detection
- Historical analysis

### Visualization
- 3D risk analysis
- Decision flow diagrams
- Risk component breakdown
- Performance metrics

### Reporting
- Real-time dashboards
- Batch analysis reports
- Custom filters
- Export capabilities

## βš™οΈ Configuration

### Email Setup
```python
EMAIL_CONFIG = {
    "smtp_user": "your-email@gmail.com",
    "smtp_password": "your-app-password",
    "smtp_server": "smtp.gmail.com",
    "smtp_port": 587
}
```

### Risk Thresholds
```python
RISK_THRESHOLDS = {
    'CRITICAL': 0.9,
    'HIGH': 0.7,
    'MEDIUM': 0.5,
    'LOW': 0.2
}
```

## πŸ”’ Security Best Practices

1. Use environment variables for sensitive data
2. Regular password updates
3. Session timeout implementation
4. Activity logging
5. Data encryption

## πŸ“ Logs and Monitoring

- System health monitoring
- User activity logs
- Model performance tracking
- Error logging

## πŸ“„ License
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.

## πŸ‘¨β€πŸ’» Author
**Sanjay Kumar**
- Email: sanjay.dev925@gmail.com
- GitHub: [Your GitHub Profile](https://github.com/D3V-S4NJ4Y)

## πŸ™ Acknowledgments
- Machine Learning libraries contributors
- Streamlit community
- Security framework developers

## πŸ“ž Support
For support and queries:
- Create an issue in the repository
- Contact: sanjay.dev925@gmail.com

---
⭐ Star this repository if you find it helpful!