Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,14 @@ export default function App() {
```
---

## 🗄️ Email Classification Database (Flask)
## 🗄️ Email Classification Database (FastAPI)

A MySQL-based system to store and manage classified email records.
A MySQL-based system to store and manage classified email records (located in `fastapi_backend/`).

### Database Setup

```bash
mysql -u root -p < backend/schema.sql
mysql -u root -p < fastapi_backend/schema.sql
```

### API Endpoints
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion backend/emails.py → fastapi_backend/emails.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from fastapi import APIRouter, HTTPException
from pydantic import BaseModel
from backend.database import (
from fastapi_backend.database import (
insert_email,
mark_email,
get_spam_emails,
Expand Down
2 changes: 1 addition & 1 deletion backend/export.py → fastapi_backend/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from fpdf import FPDF
from fastapi import APIRouter, HTTPException, Query
from fastapi.responses import StreamingResponse
from backend.database import get_connection
from fastapi_backend.database import get_connection

router = APIRouter(prefix="/api/emails", tags=["export"])

Expand Down
12 changes: 6 additions & 6 deletions backend/main.py → fastapi_backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("spam_detection_logger")

xai_service = XAIService()

# ── Resolve model paths relative to this file ────────────────────────────────
# FIX: Use pathlib.Path so the app works regardless of the working directory.
# Previously, hardcoded relative strings like "linear_svm_model.pkl" would
Expand All @@ -31,6 +29,8 @@
vectorizer = joblib.load(BASE_DIR / "backend" / "tfidf_vectorizer.pkl")
label_encoder = joblib.load(BASE_DIR / "label_encoder.pkl")

xai_service = XAIService(model=model, vectorizer=vectorizer, label_encoder=label_encoder)

app = FastAPI(title="Spam Detection System")

# ── CORS setup ────────────────────────────────────────────────────────────────
Expand Down Expand Up @@ -121,16 +121,16 @@ def health():

# ── Routers ───────────────────────────────────────────────────────────────────
# EMAIL DATABASE ROUTES (Issue #13)
from backend.emails import router as emails_router
# from backend.database import init_db # Uncomment once DB is configured
from fastapi_backend.emails import router as emails_router
# from fastapi_backend.database import init_db # Uncomment once DB is configured
# init_db()
app.include_router(emails_router)

# EXPORT ROUTES (Issue #23)
from backend.export import router as export_router
from fastapi_backend.export import router as export_router
app.include_router(export_router)

# ── Run directly ──────────────────────────────────────────────────────────────
if __name__ == "__main__":
import uvicorn
uvicorn.run("backend.main:app", host="0.0.0.0", port=PORT, reload=True)
uvicorn.run("fastapi_backend.main:app", host="0.0.0.0", port=PORT, reload=True)
8 changes: 8 additions & 0 deletions fastapi_backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fastapi
uvicorn
mysql-connector-python
fpdf2
scikit-learn==1.6.1
joblib==1.5.1
python-dotenv==1.1.1
numpy
File renamed without changes.
Loading