How felix-ayi/togocyber-ia works
TogoCyber AI is a research prototype for network-threat and phishing/smishing detection, with explanations, an optional AI prevention assistant, and a Streamlit dashboard backed by a FastAPI service. The user workflow is to submit network features or a message in the dashboard, call the API, run the relevant detector, and display its prediction and explanation; prediction metadata can be viewed in history. Training and evaluation are meaningful supporting capabilities in the ML modules. Arrows reflect README statements and shown imports/calls; unsampled route internals and several subsystem links are left unspecified.
Main entry points: router.py V1 routes · history_repository.py History repository · utils.py Model artifacts and registry · app.py Streamlit app
Components 29
Dashboard
- Streamlit app
frontend/app.py - Analysis views
frontend/views - History view
frontend/views/history.py - Trust and legal pages
frontend/views - HTTP client
frontend/services/api_client.py - Result display
frontend/components/result_card.py
API and history
- FastAPI app
backend/app/main.py - V1 routes
backend/app/api/v1/router.py - Network endpoint
backend/app/api/v1/routes/network.py - Phishing endpoint
backend/app/api/v1/routes/phishing.py - Assistant endpoint
backend/app/api/v1/routes/assistant.py - History endpoint
backend/app/api/v1/routes/history.py - History service
backend/app/services/history_service.py - History repository
backend/app/repositories/history_repository.py - SQLite history
backend/app/models/database_models.py
Threat detection
- Network analysis
backend/app/services/network_service.py - Phishing analysis
backend/app/services/phishing_service.py - Network prediction and XAI
ml/network - Text prediction and XAI
ml/phishing - Network feature contract
ml/common/preprocessing.py
Prevention assistant
- Assistant service
backend/app/services/assistant_service.py - Prompt context
ml/assistant/context.py - OpenAI client
ml/assistant/llm_client.py
ML development
- Network training
ml/network/train.py - Phishing training
ml/phishing/train.py - Model metrics
ml/common/metrics.py - Model artifacts and registry
ml/common/utils.py
Other components
- Dashboard user
- OpenAI API
Connections 32
- Dashboard user → Streamlit app: uses
- Streamlit app → Analysis views: dispatches views
frontend/app.py - Streamlit app → Trust and legal pages: dispatches views
frontend/app.py - Analysis views → HTTP client: requests analyses
frontend/views/home.py - Analysis views → Result display: renders results
frontend/views/home.py - History view → HTTP client: requests history
- HTTP client → FastAPI app: HTTP requests
frontend/services/api_client.py - FastAPI app → V1 routes: mounts routes
backend/app/main.py - V1 routes → Network endpoint: routes to
backend/app/api/v1/router.py - V1 routes → Phishing endpoint: routes to
backend/app/api/v1/router.py - V1 routes → Assistant endpoint: routes to
backend/app/api/v1/router.py - V1 routes → History endpoint: routes to
backend/app/api/v1/router.py - Network endpoint → Network analysis: delegates to
backend/app/services/network_service.py - Phishing endpoint → Phishing analysis: delegates to
backend/app/services/phishing_service.py - Network analysis → Network prediction and XAI: predicts and explains
backend/app/services/network_service.py - Phishing analysis → Text prediction and XAI: predicts and explains
backend/app/services/phishing_service.py - Network prediction and XAI → Network feature contract: uses schema
ml/network/predict.py - Network analysis → History repository: records metadata
backend/app/services/network_service.py - Phishing analysis → History repository: records metadata
backend/app/services/phishing_service.py - History endpoint → History service: delegates to
backend/app/api/v1/routes/history.py - History service → History repository: reads history
- History repository → SQLite history: reads and writes
backend/app/repositories/history_repository.py - Assistant endpoint → Assistant service: delegates to
backend/app/api/v1/routes/assistant.py - Assistant service → Prompt context: builds messages
backend/app/services/assistant_service.py - Assistant service → OpenAI client: requests completion
backend/app/services/assistant_service.py - OpenAI client → OpenAI API: HTTPS completion
ml/assistant/llm_client.py - Network training → Model metrics: computes metrics
ml/network/train.py - Phishing training → Model metrics: computes metrics
ml/phishing/train.py - Network training → Model artifacts and registry: saves model
ml/network/train.py - Phishing training → Model artifacts and registry: saves model
ml/phishing/train.py - Network prediction and XAI → Model artifacts and registry: loads model
ml/network/predict.py - Text prediction and XAI → Model artifacts and registry: loads model
ml/phishing/predict.py