parthraninga commited on
Commit
7c77e9a
Β·
verified Β·
1 Parent(s): 4a50742

Delete README.md

Browse files
Files changed (1) hide show
  1. README.md +0 -101
README.md DELETED
@@ -1,101 +0,0 @@
1
- # SafeSpace FastAPI Backend
2
-
3
- ## Overview
4
- FastAPI backend service for threat intelligence and safety recommendations with ML-enhanced categorization.
5
-
6
- ## Current Status
7
- βœ… **WORKING** - Server running successfully on http://localhost:8000
8
-
9
- ### Features
10
- - βœ… **Threat Detection API** - `/api/threats` endpoint working
11
- - βœ… **ML Model Integration** - NB-SVM threat classifier loaded and working
12
- - βœ… **News API Integration** - Fetching real news data
13
- - βœ… **Health Check** - `/health` endpoint available
14
- - βœ… **API Documentation** - Available at `/docs`
15
- - ⚠️ **AI Advice Generation** - Working with fallback (OpenRouter API key needed)
16
- - ⚠️ **ONNX Model** - Optional, not currently available
17
-
18
- ### API Endpoints
19
- - `GET /` - Root endpoint
20
- - `GET /health` - Health check
21
- - `GET /api/test` - Test endpoint
22
- - `GET /api/threats?city={city}` - Get threats for specific city
23
- - `GET /api/threats/{id}` - Get threat details
24
- - `GET /api/models/status` - ML model status
25
- - `POST /api/models/download` - Download ML models
26
-
27
- ## Quick Start
28
-
29
- ### 1. Install Dependencies
30
- ```bash
31
- cd backend/fastapi
32
- pip install -r requirements.txt
33
- ```
34
-
35
- ### 2. Start Server
36
- ```bash
37
- # Option 1: Direct Python
38
- python run.py
39
-
40
- # Option 2: Windows Batch File
41
- start_fastapi.bat
42
-
43
- # Option 3: Manual uvicorn
44
- uvicorn server.main:app --host 0.0.0.0 --port 8000
45
- ```
46
-
47
- ### 3. Test API
48
- - Health Check: http://localhost:8000/health
49
- - API Docs: http://localhost:8000/docs
50
- - Test Threats: http://localhost:8000/api/threats?city=Delhi
51
-
52
- ## Directory Structure
53
- ```
54
- fastapi/
55
- β”œβ”€β”€ run.py # Main startup script
56
- β”œβ”€β”€ start_fastapi.bat # Windows startup script
57
- β”œβ”€β”€ requirements.txt # Python dependencies
58
- β”œβ”€β”€ models/ # ML models directory
59
- β”‚ β”œβ”€β”€ threat.pkl # βœ… NB-SVM threat classifier
60
- β”‚ β”œβ”€β”€ sentiment.pkl # Additional model
61
- β”‚ └── model_info.txt # Model documentation
62
- β”œβ”€β”€ server/ # Main application code
63
- β”‚ β”œβ”€β”€ main.py # FastAPI app configuration
64
- β”‚ β”œβ”€β”€ routes/
65
- β”‚ β”‚ └── api.py # βœ… API endpoints
66
- β”‚ └── utils/
67
- β”‚ β”œβ”€β”€ model_loader.py # βœ… ML model management
68
- β”‚ └── solution.py # AI advice generation
69
- └── venv/ # Virtual environment
70
- ```
71
-
72
- ## Recent Fixes Applied
73
- 1. βœ… **Fixed Model Loading Paths** - Corrected relative paths for model files
74
- 2. βœ… **Robust Error Handling** - Server continues running even if optional models fail
75
- 3. βœ… **Optional Dependencies** - ONNX and transformers are now optional
76
- 4. βœ… **CORS Configuration** - Added support for both React (3000) and Node.js (3001)
77
- 5. βœ… **Proper Startup Script** - Fixed directory and import issues
78
-
79
- ## Integration Status
80
- - βœ… **Frontend Integration** - API endpoints accessible from React frontend
81
- - βœ… **Node.js Backend** - CORS configured for authentication backend
82
- - βœ… **ML Pipeline** - Threat classification working with existing model
83
- - βœ… **News API** - Real-time news fetching operational
84
-
85
- ## Performance
86
- - **Startup Time**: ~2-3 seconds
87
- - **Response Time**: ~2-5 seconds per threat query
88
- - **Memory Usage**: ~50-100MB
89
- - **Timeout Protection**: 5-8 seconds with fallback data
90
-
91
- ## Next Steps
92
- 1. **Optional**: Add OpenRouter API key for enhanced AI advice
93
- 2. **Optional**: Add ONNX model for improved threat detection
94
- 3. **Optional**: Implement caching for better performance
95
- 4. **Optional**: Add more sophisticated threat categorization
96
-
97
- ## Troubleshooting
98
- - If server fails to start, check `pip install -r requirements.txt`
99
- - If models fail to load, they will use fallback threat detection
100
- - API will return mock data if external services are unavailable
101
- - Check logs for detailed error information