ECWoC '26 Featured Project
π Documentation β’ π Technical Report β’ π§ͺ Research Lab β’ π Changelog
π Report Bug β’ β¨ Request Feature β’ π¬ Join WhatsApp Group
πA huge thank you to all the talented developers who have contributed to AstraGuard AI
Want to see your avatar here? Make your first contribution today!
- π About the Project
- ποΈ System Architecture
- β¨ Key Features
- π― Project Goals (ECWoC '26)
- π€ Project Admin Commitment
- π§ Mentorship & Support
- π οΈ Tech Stack
- π Project Structure
- π Getting Started
- π API Documentation
- π₯ Contributing
- π οΈ Troubleshooting
- π Documentation
- π Community
- π License
AstraGuard AI is an open-source, mission-critical security system designed specifically for CubeSat and satellite operations. It seamlessly combines AI-assisted threat detection with practical offensive security tooling to create a comprehensive defense platform for space systems.
At its core, AstraGuard AI is:
- π‘οΈ A Security Platform: Built to test applications against simulated threats in controlled environments
- π§ An AI Learning System: Uses local LLMs (Llama 3/Mistral) to analyze attack surfaces and generate smart payloads
- π A Monitoring Dashboard: Provides real-time visualization of security posture and system health
- π A Training Ground: Designed to help learners bridge the gap between theoretical knowledge and real-world security workflows
Traditional security tools often fall into two categories:
- Theoretical frameworks that are great for learning but disconnected from reality
- Production tools that are powerful but have steep learning curves
AstraGuard AI bridges this gap by providing:
β
Real-World Context: Security operations modeled after actual CubeSat mission phases
β
Hands-On Learning: Practical tools with educational guidance built-in
β
Privacy-First AI: 100% local processingβno data leaves your machine
β
Production-Ready Code: Clean, well-documented codebase suitable for real deployments
β
Adaptive Intelligence: Context-aware decisions based on mission phase and historical patterns
AstraGuard AI is designed for:
| Audience | What They'll Learn | How They'll Benefit |
|---|---|---|
| π Students | Security workflows, API design, ML integration | Hands-on experience with real security tools |
| π¨βπ» Developers | Offensive security, payload generation, threat modeling | Understanding of attack surfaces and defense strategies |
| π‘οΈ Security Practitioners | Automated threat detection, incident response | Practical tools for vulnerability assessment |
| π Space Enthusiasts | CubeSat operations, telemetry analysis | Understanding of satellite security challenges |
AstraGuard AI uses a dual-engine architecture that separates execution from intelligence:
AstraGuard AI implements a sophisticated, event-driven architecture for real-time satellite telemetry monitoring and autonomous anomaly recovery. The system leverages vector embeddings, adaptive memory, and AI-powered reasoning to provide intelligent, self-healing capabilities.
graph TB
subgraph Input["π°οΈ Data Ingestion Layer"]
A[Telemetry Stream<br/>Pathway Real-time Processing]
end
subgraph Processing["βοΈ Processing Layer"]
B[Embedding Encoder<br/>Vector Transformation]
C[Adaptive Memory Store<br/>Context-Aware Storage]
end
subgraph Intelligence["π§ Intelligence Layer"]
D[Anomaly Reasoning Agent<br/>AI-Powered Analysis]
end
subgraph Action["β‘ Action Layer"]
E[Response Orchestrator<br/>Action Coordinator]
F[System Recovery<br/>Self-Healing Mechanisms]
end
subgraph Monitoring["π Observability"]
G[Dashboard<br/>Real-time Visualization]
end
A -->|Live Data Feed| B
B -->|Vector Embeddings| C
C -->|Historical Context| D
B -->|Current Event Data| D
D -->|Recovery Decision| E
E -->|Automated Actions| F
F -->|Performance Feedback| C
D -.->|Reasoning Trace| G
C -.->|Memory State| G
E -.->|Action Status| G
style A fill:#10b981,stroke:#059669,stroke-width:4px,color:#fff
style B fill:#3b82f6,stroke:#2563eb,stroke-width:3px,color:#fff
style C fill:#8b5cf6,stroke:#7c3aed,stroke-width:3px,color:#fff
style D fill:#f59e0b,stroke:#d97706,stroke-width:4px,color:#fff
style E fill:#ef4444,stroke:#dc2626,stroke-width:3px,color:#fff
style F fill:#06b6d4,stroke:#0891b2,stroke-width:3px,color:#fff
style G fill:#ec4899,stroke:#db2777,stroke-width:3px,color:#fff
classDef inputClass fill:#d1fae5,stroke:#6ee7b7,stroke-width:3px,color:#065f46
classDef processClass fill:#dbeafe,stroke:#93c5fd,stroke-width:3px,color:#1e40af
classDef intelligenceClass fill:#fef3c7,stroke:#fcd34d,stroke-width:3px,color:#92400e
classDef actionClass fill:#fee2e2,stroke:#fca5a5,stroke-width:3px,color:#991b1b
classDef monitorClass fill:#fce7f3,stroke:#f9a8d4,stroke-width:3px,color:#9f1239
class Input inputClass
class Processing processClass
class Intelligence intelligenceClass
class Action actionClass
class Monitoring monitorClass
|
Purpose: Real-time data ingestion and stream processing Key Features:
Technologies:
|
# Example: Telemetry ingestion
stream = pathway.io.kafka.read(
topic="satellite-telemetry",
schema=TelemetrySchema,
autocommit_duration_ms=1000
) |
|
Purpose: Transform raw telemetry into semantic vector representations Key Features:
Technologies:
|
# Vector transformation
embeddings = encoder.encode(
telemetry_data,
normalize=True,
batch_size=32
)
# Index for similarity search
index.add(embeddings) |
|
Purpose: Context-aware storage with semantic search capabilities Key Features:
Storage Strategy:
|
# Semantic search
similar_events = memory.search(
query_vector=current_embedding,
top_k=10,
filters={"timeframe": "24h"}
)
# Pattern retrieval
patterns = memory.get_patterns(
anomaly_type="temperature_spike"
) |
|
Purpose: AI-powered analysis and decision-making engine Key Features:
Detection Capabilities:
|
# Anomaly detection
result = agent.analyze(
current_state=telemetry,
historical_context=memory_context,
explain=True
)
# Response
{
"anomaly_detected": True,
"confidence": 0.94,
"type": "thermal_anomaly",
"reasoning": "...",
"recommended_action": "..."
} |
|
Purpose: Coordinate and execute recovery workflows Key Features:
Recovery Strategies:
|
# Workflow execution
workflow = Workflow([
Step("isolate_subsystem"),
Step("run_diagnostics"),
Step("apply_fix",
rollback="restore_backup"),
Step("verify_recovery")
])
orchestrator.execute(
workflow,
timeout=300,
retry_policy="exponential"
) |
|
Purpose: Self-healing mechanisms and feedback loops Key Features:
Recovery Metrics:
|
# Recovery execution
recovery.execute_action(
action=recommended_action,
validate=True,
collect_metrics=True
)
# Feedback
recovery.report_outcome(
success=True,
recovery_time=180,
side_effects=None
) |
|
Purpose: Real-time visualization and system transparency Key Features:
Metrics Tracked:
|
// Dashboard real-time updates
dashboard.subscribe([
'telemetry.live',
'anomalies.detected',
'actions.executed',
'memory.state'
])
// Visualization
dashboard.render({
charts: ['timeseries', 'heatmap'],
refresh_rate: '1s'
}) |
%%{init: {'theme':'base', 'themeVariables': { 'primaryColor':'#10b981','primaryTextColor':'#fff','primaryBorderColor':'#059669','lineColor':'#3b82f6','secondaryColor':'#8b5cf6','tertiaryColor':'#f59e0b','noteBkgColor':'#1e293b','noteTextColor':'#fff','noteBorderColor':'#3b82f6'}}}%%
sequenceDiagram
autonumber
participant T as π°οΈ<br/>Telemetry<br/>Stream
participant E as π<br/>Embedding<br/>Encoder
participant M as πΎ<br/>Adaptive<br/>Memory
participant A as π§ <br/>AI Reasoning<br/>Agent
participant O as β‘<br/>Response<br/>Orchestrator
participant R as π§<br/>System<br/>Recovery
participant D as π<br/>Real-time<br/>Dashboard
rect rgba(16, 185, 129, 0.15)
Note over T,E: π PHASE 1: Data Ingestion & Transformation
T->>+E: Stream raw telemetry data<br/>(1000+ events/sec)
E->>E: Validate & normalize data
E->>E: Generate 768-dim embeddings
E-->>-T: ACK: Processing complete
end
rect rgba(59, 130, 246, 0.15)
Note over E,M: πΎ PHASE 2: Storage & Context Retrieval
E->>+M: Store vector embeddings<br/>with metadata
M->>M: Index in FAISS<br/>(O(log n) search)
M-->>-E: Confirm: Indexed successfully
E->>+A: Forward current event<br/>+ embeddings
M->>+A: Retrieve historical context<br/>(top-k=10 similar events)
end
rect rgba(245, 158, 11, 0.15)
Note over A: π PHASE 3: Anomaly Detection & Analysis
A->>A: Compute anomaly score<br/>(ensemble models)
A->>A: Generate confidence metrics<br/>(0.0 - 1.0)
alt Anomaly Detected (confidence > 0.85)
A->>A: Execute chain-of-thought<br/>reasoning process
A->>A: Identify root cause
A->>+D: Stream reasoning trace<br/>for transparency
D-->>-A: Logged to dashboard
else Normal Operation
A->>D: Update healthy status
Note over A: Continue monitoring
end
end
rect rgba(239, 68, 68, 0.15)
Note over A,O: π― PHASE 4: Decision Making & Planning
A->>+O: Send recovery recommendation<br/>with action priority
O->>O: Validate action feasibility
O->>O: Build execution workflow<br/>(DAG-based)
O->>O: Allocate resources
O-->>-A: Confirm: Workflow ready
end
rect rgba(6, 182, 212, 0.15)
Note over O,R: π§ PHASE 5: Automated Recovery
O->>+R: Execute recovery workflow
par Parallel Recovery Actions
R->>R: Action 1: Isolate subsystem
R->>R: Action 2: Run diagnostics
R->>R: Action 3: Apply configuration fix
and Health Monitoring
R->>D: Stream recovery status<br/>(real-time updates)
end
R->>R: Verify system health
alt Recovery Successful β
R->>+M: Report success + metrics<br/>(recovery_time, steps_taken)
M->>M: Update success patterns
M-->>-R: Pattern learned
R->>D: β
Recovery completed
else Recovery Failed β
R->>O: Trigger rollback procedure
R->>D: β οΈ Alert: Manual intervention needed
end
R-->>-O: Recovery outcome reported
end
rect rgba(139, 92, 246, 0.15)
Note over M,A: π PHASE 6: Continuous Learning
M->>+A: Push updated context<br/>with new patterns
A->>A: Retrain anomaly detection<br/>(incremental learning)
A->>A: Adjust confidence thresholds
A-->>-M: Model updated successfully
Note over T,D: π System continues monitoring...<br/>Ready for next event
end
rect rgba(236, 72, 153, 0.15)
Note over D: π OBSERVABILITY: Continuous Monitoring
D->>D: Aggregate metrics across all phases
D->>D: Generate real-time visualizations
D->>D: Track KPIs: MTTD, MTTR, Success Rate
end
| Phase | Components | Actions | Duration |
|---|---|---|---|
| π Phase 1 Ingestion |
Telemetry β Encoder |
β’ Stream validation β’ Data normalization β’ Vector embedding generation |
<50ms |
| πΎ Phase 2 Storage |
Encoder β Memory |
β’ Vector indexing (FAISS) β’ Context retrieval (k-NN) β’ Metadata tagging |
<100ms |
| π Phase 3 Analysis |
Memory + Agent |
β’ Anomaly scoring β’ Confidence computation β’ Root cause analysis β’ Reasoning trace generation |
1-5s |
| π― Phase 4 Planning |
Agent β Orchestrator |
β’ Action validation β’ Workflow creation (DAG) β’ Resource allocation β’ Priority assignment |
500ms-2s |
| π§ Phase 5 Recovery |
Orchestrator β Recovery |
β’ Parallel action execution β’ Health verification β’ Rollback on failure β’ Metrics collection |
2-5min |
| π Phase 6 Learning |
Recovery β Memory β Agent |
β’ Pattern storage β’ Model retraining β’ Threshold adjustment β’ Knowledge consolidation |
Background |
graph LR
A{Anomaly<br/>Detected?} -->|Yes<br/>conf > 0.85| B[Generate<br/>Recovery Plan]
A -->|No| C[Continue<br/>Monitoring]
B --> D{Recovery<br/>Successful?}
D -->|Yes β
| E[Update<br/>Patterns]
D -->|No β| F[Trigger<br/>Rollback]
E --> G[Learn &<br/>Improve]
F --> H[Manual<br/>Intervention]
style A fill:#f59e0b,stroke:#d97706,stroke-width:3px,color:#fff
style B fill:#3b82f6,stroke:#2563eb,stroke-width:2px,color:#fff
style C fill:#10b981,stroke:#059669,stroke-width:2px,color:#fff
style D fill:#f59e0b,stroke:#d97706,stroke-width:3px,color:#fff
style E fill:#10b981,stroke:#059669,stroke-width:2px,color:#fff
style F fill:#ef4444,stroke:#dc2626,stroke-width:2px,color:#fff
style G fill:#8b5cf6,stroke:#7c3aed,stroke-width:2px,color:#fff
style H fill:#f97316,stroke:#ea580c,stroke-width:2px,color:#fff
| Metric | Target | Actual | Status |
|---|---|---|---|
| End-to-End Latency | <30s | 18.4s | β |
| Phase 1-2 (Ingestion) | <150ms | 127ms | β |
| Phase 3 (Analysis) | <5s | 3.2s | β |
| Phase 4 (Planning) | <2s | 1.4s | β |
| Phase 5 (Recovery) | <5min | 4m 32s | β |
| Throughput | 1000 events/s | 1247 events/s | β |
| Success Rate | >95% | 94.7% |
graph TD
A[π₯ New Telemetry Event] --> B{Processing}
B --> C[π§ AI Analysis]
C --> D{Anomaly?}
D -->|Yes| E[β‘ Execute Recovery]
D -->|No| F[β
Normal State]
E --> G{Success?}
G -->|Yes| H[πΎ Learn Pattern]
G -->|No| I[π Retry/Escalate]
H --> J[π― Improve Models]
F --> K[π Update Baseline]
I --> L[π¨βπ» Human Review]
J --> M[π Next Event]
K --> M
L --> M
M --> A
style A fill:#10b981,stroke:#059669,stroke-width:2px,color:#fff
style C fill:#f59e0b,stroke:#d97706,stroke-width:2px,color:#fff
style E fill:#ef4444,stroke:#dc2626,stroke-width:2px,color:#fff
style H fill:#8b5cf6,stroke:#7c3aed,stroke-width:2px,color:#fff
style J fill:#06b6d4,stroke:#0891b2,stroke-width:2px,color:#fff
style M fill:#ec4899,stroke:#db2777,stroke-width:2px,color:#fff
| Metric | Target | Actual |
|---|---|---|
| Ingestion Throughput | 1000 events/sec | 1,247 events/sec β |
| Detection Latency (p99) | <30s | 18.4s β |
| Recovery Time (MTTR) | <5 min | 4m 32s β |
| False Positive Rate | <3% | 1.8% β |
| System Availability | 99.9% | 99.94% β |
| Vector Search Latency | <50ms | 32ms β |
|
|
graph TB
subgraph Cloud["βοΈ Cloud Infrastructure (AWS/GCP)"]
subgraph K8s["Kubernetes Cluster"]
subgraph DataPlane["Data Plane"]
Stream[Streaming Service<br/>3 replicas]
Encoder[Encoder Service<br/>5 replicas]
Agent[AI Agent Service<br/>3 replicas]
end
subgraph ControlPlane["Control Plane"]
Orch[Orchestrator<br/>2 replicas]
API[API Gateway<br/>3 replicas]
end
end
subgraph Storage["πΎ Storage Layer"]
Redis[(Redis Cluster<br/>6 nodes)]
Postgres[(PostgreSQL<br/>Primary + 2 Replicas)]
Vector[(Vector DB<br/>FAISS Cluster)]
end
subgraph Monitoring["π Monitoring"]
Grafana[Grafana]
Prom[Prometheus]
Logs[Loki]
end
end
Ground[π Ground Station] -->|Telemetry| Stream
Satellite[π°οΈ Satellites] -->|Data| Stream
Stream --> Encoder
Encoder --> Agent
Agent --> Orch
Orch --> Redis
Orch --> Postgres
Encoder --> Vector
DataPlane -.-> Prom
ControlPlane -.-> Prom
Prom --> Grafana
DataPlane -.-> Logs
style Cloud fill:#0f172a,stroke:#3b82f6,stroke-width:3px,color:#fff
style K8s fill:#1e293b,stroke:#06b6d4,stroke-width:3px,color:#fff
style DataPlane fill:#334155,stroke:#10b981,stroke-width:2px,color:#fff
style ControlPlane fill:#334155,stroke:#f59e0b,stroke-width:2px,color:#fff
style Storage fill:#1e293b,stroke:#8b5cf6,stroke-width:3px,color:#fff
style Monitoring fill:#1e293b,stroke:#ec4899,stroke-width:3px,color:#fff
style Stream fill:#10b981,stroke:#059669,stroke-width:2px,color:#fff
style Encoder fill:#3b82f6,stroke:#2563eb,stroke-width:2px,color:#fff
style Agent fill:#f59e0b,stroke:#d97706,stroke-width:2px,color:#fff
style Orch fill:#ef4444,stroke:#dc2626,stroke-width:2px,color:#fff
style API fill:#06b6d4,stroke:#0891b2,stroke-width:2px,color:#fff
style Redis fill:#dc2626,stroke:#991b1b,stroke-width:2px,color:#fff
style Postgres fill:#2563eb,stroke:#1e40af,stroke-width:2px,color:#fff
style Vector fill:#7c3aed,stroke:#6d28d9,stroke-width:2px,color:#fff
style Grafana fill:#f97316,stroke:#ea580c,stroke-width:2px,color:#fff
style Prom fill:#ef4444,stroke:#dc2626,stroke-width:2px,color:#fff
style Logs fill:#8b5cf6,stroke:#7c3aed,stroke-width:2px,color:#fff
style Ground fill:#14b8a6,stroke:#0d9488,stroke-width:2px,color:#fff
style Satellite fill:#06b6d4,stroke:#0891b2,stroke-width:2px,color:#fff
Technology: Python 3.9+
Purpose: Executes concrete security operations
Capabilities:
- Packet Manipulation: Uses Scapy for deep packet inspection and crafting
- Network Scanning: Integrates with Nmap for port scanning and service detection
- Payload Delivery: Automated injection and testing of security payloads
- Traffic Interception: Proxy integration with Burp Suite for man-in-the-middle analysis
- Protocol Analysis: Deep inspection of network protocols and data streams
Design Philosophy:
- Stateless and robust
- Fail-safe by default
- Does exactly what it's toldβno surprises
- Comprehensive logging for audit trails
Example Use Case:
# Security Engine performing network scan
from src.security_engine import NetworkScanner
scanner = NetworkScanner(target="192.168.1.0/24")
results = scanner.scan_ports([80, 443, 8080])
vulnerable_services = scanner.identify_vulnerabilities(results)Technology: Python (LangChain/Ollama) + Node.js
Purpose: Analyzes context and makes intelligent decisions
Capabilities:
A. Attack Surface Analysis
- Reads scan data from the Security Engine
- Identifies "interesting" targets based on:
- Service versions with known CVEs
- Unusual port configurations
- Legacy protocols still in use
- Misconfigured services
- Prioritizes targets by exploitability
B. Smart Payload Generation
- Crafts payloads specific to the target technology stack
- Example: "This looks like an older MongoDB instanceβtry these NoSQL injection vectors"
- Adapts to application framework (Django, Flask, Express, etc.)
- Considers defense mechanisms detected during reconnaissance
C. Risk Assessment
- Scores vulnerabilities based on real-world exploitability
- Goes beyond CVSS scores by considering:
- Attack complexity
- Available exploit code
- Patch availability
- Impact on mission objectives
- Current mission phase constraints
D. Contextual Decision Making
- Uses historical anomaly patterns from Adaptive Memory Store
- Adjusts responses based on mission phase
- Learns from previous incidents to improve detection
Privacy Guarantee:
- 100% Local Processing: All AI models run via Ollama on your machine
- No Cloud Calls: Sensitive scan data never leaves your infrastructure
- Offline Capable: Works without internet connection
- Audit Trail: All AI decisions are logged with reasoning traces
Example Use Case:
# AI Layer analyzing attack surface
from src.ai_agent import ThreatAnalyzer
analyzer = ThreatAnalyzer(model="llama3")
scan_results = load_scan_data("network_scan.json")
analysis = analyzer.analyze_attack_surface(scan_results)
# Output: {
# "high_priority_targets": [...],
# "recommended_payloads": [...],
# "risk_scores": {...},
# "reasoning": "Detected outdated Apache version 2.4.29..."
# }- Telemetry Ingestion: Satellite telemetry streams into the system via Pathway
- Encoding: Data is embedded into vector representations for semantic analysis
- Memory Storage: Historical context is stored in the Adaptive Memory Store
- Anomaly Detection: AI agent analyzes current data against historical patterns
- Policy Evaluation: Mission phase policies determine appropriate response
- Action Orchestration: Response orchestrator executes recovery actions
- Feedback Loop: Action results feed back into memory for continuous learning
- Dashboard Update: Real-time updates pushed to monitoring interface
| Feature | Description | Technology |
|---|---|---|
| π€ AI Threat Assistant | Local LLM-powered vulnerability analysis using Llama 3 or Mistral models | LangChain + Ollama |
| π‘οΈ Offensive Tooling Suite | Comprehensive payload generation, injection testing, and security scanning | Python + Scapy + Nmap |
| π Smart Dashboard | Real-time visualization of threats, system health, and security metrics | Streamlit + React |
| π¬ Research Lab | Integrated environment for testing security hypotheses and verifying findings | Python + Jupyter |
| β‘ Real-Time Streaming | High-performance telemetry processing with sub-second latency | Pathway |
| π§ Adaptive Memory | Context-aware decision making based on historical anomaly patterns | Vector embeddings |
| π― Smart Prioritization | Intelligent target selection based on exploitability and mission impact | AI reasoning |
| οΏ½ Explainable Anomaly Insights | Per-anomaly explanations including feature importances, SHAP values, and confidence scores to increase operator trust and transparency | React + visualization components |
| οΏ½π Health Monitoring | Component-level degradation tracking with automated failover | Centralized error handling |
AstraGuard AI understands that CubeSat operations have different constraints at different stages. The same anomaly might trigger different responses depending on the current mission phase.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MISSION PHASES β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β LAUNCH β
β ββ Duration: T-0 to orbit insertion β
β ββ Priority: System survival β
β ββ Constraint: Minimal actions to avoid destabilization β
β ββ Response: LOG_ONLY (no active interventions) β
β β
β DEPLOYMENT β
β ββ Duration: Orbit insertion to systems checkout β
β ββ Priority: Safe deployment of components β
β ββ Constraint: Limited responses, avoid disruption β
β ββ Response: STABILIZE (conservative recovery) β
β β
β NOMINAL_OPS β
β ββ Duration: Normal operational phase β
β ββ Priority: Performance optimization β
β ββ Constraint: None (full autonomy) β
β ββ Response: FULL_RECOVERY (all actions available) β
β β
β PAYLOAD_OPS β
β ββ Duration: Active science/mission operations β
β ββ Priority: Science data collection β
β ββ Constraint: Careful with power/attitude changes β
β ββ Response: PAYLOAD_SAFE (mission-aware recovery) β
β β
β SAFE_MODE β
β ββ Duration: Critical failure or emergency β
β ββ Priority: System survival only β
β ββ Constraint: Minimal subsystem activation β
β ββ Response: SURVIVAL_ONLY (log + essential recovery) β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Scenario: Battery voltage drops to 6.8V (nominal: 7.4V)
| Phase | Detection | Response | Reasoning |
|---|---|---|---|
| LAUNCH | β Detected | π Log only | System under max stress; active response could cause instability |
| DEPLOYMENT | β Detected | β‘ Reduce power draw by 20% | Safe recovery without disrupting deployment sequence |
| NOMINAL_OPS | β Detected | π Full diagnostic + power optimization + alert ground station | Full autonomy to resolve issue |
| PAYLOAD_OPS | β Detected | π― Pause non-critical payload, maintain attitude | Protect science mission while addressing power issue |
| SAFE_MODE | β Detected | π‘οΈ Log + enter deep power-saving mode | Survival takes absolute priority |
Mission phase policies are fully configurable:
# config/mission_phases.yaml
phases:
LAUNCH:
max_actions: 0
allowed_actions: [LOG_ONLY]
power_change_limit: 0%
NOMINAL_OPS:
max_actions: unlimited
allowed_actions: [LOG, ALERT, RECOVER, OPTIMIZE]
power_change_limit: 50%π Complete Documentation: Mission-Phase Policies Guide
AstraGuard AI is designed to never crash. The system includes a comprehensive error handling layer that ensures resilience under all failure conditions.
- Fail Gracefully: Component failures trigger fallback behavior instead of system crashes
- Centralized Handling: All errors flow through a single error handling pipeline
- Structured Logging: Errors include full context (component, phase, telemetry state)
- Health Tracking: Real-time component health exposed to monitoring dashboard
- Smart Fallbacks: Each component has a defined degraded operating mode
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Component Failure Scenarios β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β π§ AI Model Loading Fails β
β βββΊ Fallback: Heuristic anomaly detection β
β β
β π Memory Store Unavailable β
β βββΊ Fallback: Stateless operation (no history) β
β β
β π― Policy Evaluation Fails β
β βββΊ Fallback: Safe default (LOG_ONLY mode) β
β β
β β‘ Action Execution Fails β
β βββΊ Fallback: Log error + retry with backoff β
β β
β ποΈ Database Connection Lost β
β βββΊ Fallback: In-memory buffer + reconnect attempt β
β β
β π API Endpoint Unreachable β
β βββΊ Fallback: Queue request + circuit breaker β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββEach component reports one of three health states:
- π’ HEALTHY: Operating normally with full functionality
- π‘ DEGRADED: Partially operational, using fallback behavior
- π΄ FAILED: Component unavailable, critical functions impaired
from src.ai_agent import AnomalyDetector
from src.core.error_handler import handle_component_failure
try:
detector = AnomalyDetector(model="llama3")
result = detector.analyze(telemetry)
except ModelLoadError as e:
# Graceful fallback to heuristic detection
handle_component_failure("ai_model", e)
detector = HeuristicDetector() # Simple threshold-based detection
result = detector.analyze(telemetry)
result["mode"] = "degraded"βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SYSTEM HEALTH β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π§ AI Model π’ HEALTHY β
β π Memory Store π’ HEALTHY β
β π― Policy Engine π’ HEALTHY β
β β‘ Action Orchestrator π‘ DEGRADED (retry mode) β
β ποΈ Database π’ HEALTHY β
β π API Server π’ HEALTHY β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Overall Status: OPERATIONAL (1 component degraded) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Implementation Guide: Error Handling Best Practices
AstraGuard AI provides a production-ready FastAPI server for programmatic access and integration with external systems.
β
Input Validation: Pydantic models with comprehensive data validation
β
OpenAPI Documentation: Interactive Swagger UI at /docs
β
CORS Support: Ready for web frontend integration
β
Batch Processing: Submit 1-1000 telemetry points in a single request
β
Rate Limiting: Configurable limits to prevent abuse
β
Authentication: API key support for production deployments
β
Versioning: /api/v1/ prefix for future compatibility
β
100% Test Coverage: 23/23 tests passing
| Endpoint | Method | Description | Rate Limit |
|---|---|---|---|
/api/v1/telemetry |
POST | Submit single telemetry point | 1000/hour |
/api/v1/telemetry/batch |
POST | Submit 1-1000 telemetry points | 100/hour |
/api/v1/status |
GET | System health & component status | Unlimited |
/api/v1/phase |
GET | Get current mission phase | Unlimited |
/api/v1/phase |
POST | Update mission phase | 50/hour |
/api/v1/memory/stats |
GET | Memory store statistics | 500/hour |
/api/v1/history/anomalies |
GET | Query anomaly history (with filters) | 200/hour |
/api/v1/history/export |
GET | Export historical data to JSON/CSV | 10/hour |
import requests
# Submit a single telemetry point
response = requests.post('http://localhost:8000/api/v1/telemetry', json={
"timestamp": "2026-01-04T12:00:00Z",
"voltage": 7.2,
"temperature": 35.5,
"gyro": 0.08,
"mission_phase": "NOMINAL_OPS"
})
result = response.json()
if result['is_anomaly']:
print(f"β οΈ ANOMALY DETECTED!")
print(f" Type: {result['anomaly_type']}")
print(f" Confidence: {result['confidence']:.2%}")
print(f" Recommended Action: {result['recommended_action']}")
print(f" Reasoning: {result['reasoning']}")
else:
print("β
All systems nominal")# Submit historical data for analysis
telemetry_batch = [
{"timestamp": "2026-01-04T12:00:00Z", "voltage": 7.4, "temperature": 32.0, "gyro": 0.02},
{"timestamp": "2026-01-04T12:01:00Z", "voltage": 7.3, "temperature": 32.5, "gyro": 0.03},
# ... up to 1000 items
]
response = requests.post('http://localhost:8000/api/v1/telemetry/batch', json={
"items": telemetry_batch
})
result = response.json()
print(f"Processed: {result['processed_count']}/{result['total_count']}")
print(f"Anomalies detected: {result['anomaly_count']}")# Check current mission phase
response = requests.get('http://localhost:8000/api/v1/phase')
phase_info = response.json()
print(f"Current Phase: {phase_info['phase']}")
print(f"Constraints: {phase_info['constraints']}")
# Update mission phase
response = requests.post('http://localhost:8000/api/v1/phase', json={
"phase": "PAYLOAD_OPS",
"reason": "Starting science data collection"
})# Get anomalies from the last 24 hours
response = requests.get('http://localhost:8000/api/v1/history/anomalies', params={
"start_time": "2026-01-03T12:00:00Z",
"end_time": "2026-01-04T12:00:00Z",
"anomaly_type": "VOLTAGE_DROP",
"min_confidence": 0.8
})
anomalies = response.json()
for anomaly in anomalies['items']:
print(f"[{anomaly['timestamp']}] {anomaly['type']} - {anomaly['action_taken']}")# Check system health
response = requests.get('http://localhost:8000/api/v1/status')
status = response.json()
print(f"Overall Status: {status['overall_status']}")
for component, health in status['components'].items():
icon = "π’" if health['status'] == "HEALTHY" else "π‘" if health['status'] == "DEGRADED" else "π΄"
print(f" {icon} {component}: {health['status']}")π Complete Examples: API Usage Guide
π API Reference: Access interactive docs at http://localhost:8000/docs after starting the server
Purpose: Type-safe data contract for human-in-the-loop learning loop. Enables operators to validate AI-recommended recovery actions and provide feedback for continuous improvement.
Schema - FeedbackEvent:
from models.feedback import FeedbackEvent, FeedbackLabel
event = FeedbackEvent(
fault_id="power_f001",
anomaly_type="power_subsystem",
recovery_action="emergency_power_cycle",
label=FeedbackLabel.CORRECT,
mission_phase="NOMINAL_OPS",
operator_notes="Recovered 2.3s - optimal response",
confidence_score=0.95
)Features:
- β Pydantic v2 validation with strict type checking
- β Mission phase enum validation (LAUNCH, DEPLOYMENT, NOMINAL_OPS, PAYLOAD_OPS, SAFE_MODE)
- β Feedback labels for multi-class classification (CORRECT, INSUFFICIENT, WRONG)
- β Confidence scoring (0.0-1.0) for operator certainty
- β Optional operator notes (max 500 chars) for context
- β Automatic timestamp generation with ISO format serialization
- β 100% test coverage with 12 comprehensive test cases
- β Compact JSON serialization (<300B/event) for efficient storage
Usage Example:
# Validate operator feedback
from models.feedback import FeedbackEvent, FeedbackLabel
feedback = FeedbackEvent(
fault_id="thermal_001",
anomaly_type="thermal_spike",
recovery_action="heater_cooldown",
label=FeedbackLabel.CORRECT,
mission_phase="PAYLOAD_OPS",
operator_notes="Action worked within 45 seconds"
)
# Serialize to JSON for storage/transmission
json_data = feedback.model_dump_json()
print(f"Event size: {len(json_data)} bytes")
# All validations enforced:
# - fault_id: 1-64 chars
# - anomaly_type: 1-64 chars
# - recovery_action: 1-128 chars
# - mission_phase: must match regex pattern
# - confidence_score: 0.0 β€ score β€ 1.0
# - operator_notes: max 500 chars (optional)Validation Examples:
# β
Valid - all constraints satisfied
event = FeedbackEvent(
fault_id="f123", anomaly_type="power",
recovery_action="reset", label=FeedbackLabel.INSUFFICIENT,
mission_phase="NOMINAL_OPS"
)
# β Invalid - mission_phase must be uppercase
FeedbackEvent(..., mission_phase="nominal_ops")
# β Invalid - confidence_score must be 0.0-1.0
FeedbackEvent(..., confidence_score=1.5)
# β Invalid - operator_notes exceeds max_length
FeedbackEvent(..., operator_notes="x" * 501)Blocking Issues:
- #51:
@log_feedbackdecorator integration - #52: Database storage layer
- #53: Feedback aggregation analysis
- #54: ML model retraining pipeline
- #55: Dashboard feedback visualization
- #56: Feedback export/reporting
Purpose: Automatically capture recovery action results without modifying existing code. Provides non-blocking feedback event logging to pending store.
How It Works:
from security_engine.decorators import log_feedback
# Decorate any recovery function - no changes to logic needed
@log_feedback(fault_id="power_loss_001", anomaly_type="power_subsystem")
def emergency_power_cycle(system_state) -> bool:
"""Recovery action with automatic feedback logging."""
# ... existing recovery logic ...
return success # True/FalseAutomatic Behavior:
- Execution: Function runs with original logic unchanged
- Capture: Result (True/False) β confidence score (1.0/0.5)
- Store: FeedbackEvent appended to
feedback_pending.json - Non-blocking: Errors in logging don't affect recovery
Features:
- β
Thread-safe atomic appends to
feedback_pending.json - β
Auto-extracts
mission_phasefrom system_state - β Confidence scoring: success=1.0, failure=0.5
- β Preserves all return values (True, False, None, etc.)
- β Non-blocking error handling (logging errors don't break recovery)
- β 20+ comprehensive tests including concurrency chaos
- β 100% code coverage
Example - Recovery Action Sequence:
@log_feedback("thermal_spike", "thermal")
def activate_passive_cooling(state):
return True # Auto-logged: confidence_score=1.0
@log_feedback("thermal_spike_fail", "thermal")
def thermal_shutdown(state):
return False # Auto-logged: confidence_score=0.5
# Usage - both auto-log to feedback_pending.json
state = SystemState(mission_phase="PAYLOAD_OPS")
activate_passive_cooling(state) # β
Logged
thermal_shutdown(state) # β
Logged (even on failure)Pending Store Format (feedback_pending.json):
[
{
"fault_id": "power_loss_001",
"anomaly_type": "power_subsystem",
"recovery_action": "emergency_power_cycle",
"mission_phase": "NOMINAL_OPS",
"confidence_score": 1.0,
"timestamp": "2026-01-04T14:30:22.123456"
}
]Integration with Policy Engine:
# Any recovery function can be decorated
from security_engine.decorators import log_feedback
# In backend/recovery_orchestrator.py or policy_engine.py:
@log_feedback("circuit_break_001", "circuit_breaker")
async def circuit_recovery(state):
return await _perform_circuit_reset(state)
@log_feedback("cache_purge_001", "cache")
def cache_recovery(state):
return _clear_cache(state)Blocking Issues:
- #52: Consume
feedback_pending.jsonvia CLI - #53-56: Feedback analytics and retraining pipeline
As part of Elite Coders Winter of Code 2026, AstraGuard AI has clear deliverables and learning objectives:
-
β Stable AI Security Module: Build a production-ready AI assistant for intelligent vulnerability detection
- Target: 95%+ accuracy on test dataset
- Support for 3+ LLM backends (Llama 3, Mistral, GPT-4)
- Response time < 500ms per analysis
-
β Contributor-Friendly Issues: Create 20+ well-scoped issues with learning notes
- 10 beginner issues (documentation, testing, UI)
- 7 intermediate issues (feature implementation, API design)
- 3 advanced issues (ML integration, performance optimization)
-
β Comprehensive Documentation: Improve onboarding and technical docs
- Getting Started guide (< 10 minutes to first run)
- Architecture deep-dive
- API reference with examples
- Contributing guidelines
-
β Automated Testing: Implement CI/CD pipelines
- Unit tests (target: 80%+ coverage)
- Integration tests for API endpoints
- Payload validation tests
- Attack surface analysis tests
-
β Production-Ready MVP: Ship a fully working system
- All core features implemented
- Dashboard with real-time updates
- API with OpenAPI documentation
- Deployment-ready Docker containers
| Metric | Target | Current Status |
|---|---|---|
| Test Coverage | 80%+ | 23/23 API tests passing β |
| API Response Time | < 200ms | Achieved β |
| Documentation Pages | 10+ | 12 pages β |
| Contributor Issues | 20+ | 15 open, 8 needed |
| PR Review Time | < 72 hours | 48-hour average β |
| Active Contributors | 6-10 | 4 active, recruiting |
By the end of ECWoC '26, contributors will have hands-on experience with:
- π‘οΈ Security: Vulnerability assessment, payload generation, threat modeling
- π§ AI/ML: LLM integration, prompt engineering, embedding models
- βοΈ Backend: FastAPI, async programming, database design
- π¨ Frontend: React, real-time dashboards, data visualization
- π§ DevOps: Docker, CI/CD, automated testing
- π Best Practices: Code review, documentation, open-source collaboration
As maintainers participating in ECWoC '26, we commit to creating a welcoming, educational, and productive environment for all contributors.
- Daily Monitoring: Check issues and PRs at least once per day
- Weekly Updates: Post progress updates every Friday
- Responsive Communication: Reply to questions within 24 hours
- Regular Releases: Ship new features every 2 weeks
- Initial Review: First review within 48 hours of PR submission
- Final Review: Final decision within 72 hours
- Constructive Feedback: Detailed comments with improvement suggestions
- Pair Programming: Available for complex features via screen share
- Issue Templates: Pre-filled templates with all necessary context
- Learning Notes: Educational comments explaining why things work
- Code Examples: Reference implementations for common patterns
- Video Walkthroughs: Screen recordings for complex setup procedures
- Onboarding Session: 30-minute video call for new contributors
- Office Hours: Weekly 1-hour Q&A session on Discord
- Mentorship: Direct support from maintainers on assigned issues
- Recognition: Shout-outs for quality contributions in release notes
- Zero Tolerance: Harassment, discrimination, or toxicity results in immediate removal
- Inclusive Language: Maintain welcoming, respectful communication
- Credit Attribution: Proper recognition for all contributions
- Transparent Decisions: Explain reasoning for accepted/rejected PRs
- Primary Maintainer: @sr-857
- Response Time: < 24 hours for GitHub mentions
- Office Hours: Fridays 6-7 PM IST
- Emergency Contact: Via WhatsApp group (see Community section)
π ECWoC Code of Conduct: https://elitecoders.xyz/coc
We want AstraGuard AI to feel like a real training ground, not just a code repository. Our goal is to make your contribution experience meaningful and educational.
Week 1: Getting Started
- π Read CONTRIBUTING.md and project documentation
- π οΈ Complete local setup (we'll help debug any issues)
- π― Choose your first issue from the "good first issue" label
- π¬ Introduction in WhatsApp group
Week 2: First Contribution
- π Work on assigned issue with maintainer guidance
- π‘ Learn project conventions and coding standards
- π Submit first PR with detailed description
- π Receive thorough code review with learning notes
Week 3+: Regular Contributions
- π Take on more complex issues
- π Participate in architectural discussions
- π€ Help review other contributors' PRs
- π Build portfolio-worthy features
Every issue includes:
## π Issue Template
### Description
[Clear explanation of what needs to be built/fixed]
### Learning Objectives
[What you'll learn by working on this]
### Technical Context
[Relevant architecture, files, and concepts]
### Implementation Hints
[Guidance on approach, not complete solution]
### Resources
[Links to docs, tutorials, similar implementations]
### Definition of Done
[Specific criteria for completion]
### Estimated Time
[Realistic time estimate]Our review process:
- Automated Checks (< 5 minutes): Linting, tests, build verification
- Initial Review (< 48 hours): High-level feedback on approach
- Detailed Review (< 72 hours): Line-by-line comments with explanations
- Final Approval (< 96 hours): Merge or request final changes
Review Quality Promise:
- β Constructive feedback, never dismissive
- β Explain why changes are needed, not just what
- β Provide code examples for complex suggestions
- β Celebrate good code and creative solutions
| Channel | Purpose | Response Time |
|---|---|---|
| GitHub Issues | Bug reports, feature requests | < 24 hours |
| GitHub Discussions | Technical questions, design discussions | < 48 hours |
| WhatsApp Group | Quick questions, coordination | < 6 hours |
| Discord Office Hours | Deep-dive troubleshooting, pair programming | Fridays 6-7 PM IST |
| Private concerns, admin questions | < 48 hours |
We've organized issues by skill level:
π’ Beginner (Good First Issue)
- Documentation improvements
- Test case additions
- UI enhancements
- Configuration updates
π‘ Intermediate
- API endpoint implementation
- Dashboard feature additions
- Error handling improvements
- Performance optimizations
π΄ Advanced
- ML model integration
- Distributed system features
- Security protocol implementation
- Architecture redesigns
- π― Commitment: Finish what you start (or communicate blockers early)
- π¬ Communication: Ask questions when stuck, don't suffer in silence
- π Learning: Read docs before asking, but do ask if docs are unclear
- π€ Collaboration: Be respectful, help others, give credit
- β¨ Quality: Submit clean code with tests and documentation
- π Getting Started Guide
- π₯ Video Tutorials
- π Troubleshooting Guide
- π‘ Code Style Guide
- π§ Development Setup
| Technology | Version | Purpose | Documentation |
|---|---|---|---|
| React | 18.2+ | UI framework | React Docs |
| TailwindCSS | 3.4+ | Styling | Tailwind Docs |
| Vite | 5.0+ | Build tool | Vite Docs |
| Recharts | 2.10+ | Data visualization | Recharts Docs |
| React Query | 5.0+ | Data fetching | TanStack Query |
| Technology | Version | Purpose | Documentation |
|---|---|---|---|
| Node.js | 16+ | JavaScript runtime | Node Docs |
| FastAPI | 0.104+ | Python API framework | FastAPI Docs |
| MongoDB | 6.0+ | Database | MongoDB Docs |
| Pathway | 0.7+ | Stream processing | Pathway Docs |
| Pydantic | 2.5+ | Data validation | Pydantic Docs |
| Technology | Version | Purpose | Documentation |
|---|---|---|---|
| Python | 3.9+ | Core language | Python Docs |
| Scapy | 2.5+ | Packet manipulation | Scapy Docs |
| Nmap | 7.94+ | Network scanning | Nmap Docs |
| ffuf | 2.1+ | Web fuzzing | ffuf GitHub |
| Requests | 2.31+ | HTTP client | Requests Docs |
| Technology | Version | Purpose | Documentation |
|---|---|---|---|
| LangChain | 0.1+ | LLM orchestration | LangChain Docs |
| Ollama | 0.1+ | Local LLM runtime | Ollama Docs |
| Sentence Transformers | 2.2+ | Embeddings | SBERT Docs |
| NumPy | 1.24+ | Numerical computing | NumPy Docs |
| scikit-learn | 1.3+ | ML utilities | sklearn Docs |
| Technology | Version | Purpose | Documentation |
|---|---|---|---|
| Docker | 24.0+ | Containerization | Docker Docs |
| GitHub Actions | N/A | CI/CD | Actions Docs |
| pytest | 7.4+ | Testing framework | pytest Docs |
| Black | 23.0+ | Code formatting | Black Docs |
| Burp Suite | Latest | Traffic analysis | Burp Docs |
AstraGuard AI features an advanced, adaptive rate limiting system that protects against abuse while ensuring optimal user experience:
- π§ Adaptive Rate Limiting: Automatically adjusts limits based on real-time system health metrics
- π System Health Integration: Monitors CPU, memory, active connections, and anomaly scores
- π― Intelligent Queuing: Prioritizes critical requests during high load periods
- π€ User Feedback: Provides clear notifications and graceful degradation
- π Auto-Retry Logic: Smart retry mechanisms with exponential backoff
- β‘ Real-time Monitoring: Live system health indicators and request queue status
- Health Monitoring: Continuously monitors backend system health via
/health/stateendpoint - Dynamic Adjustment: Reduces rate limits when system health degrades (healthy β degraded β critical)
- Request Queuing: Queues requests intelligently when limits are reached
- User Notifications: Shows real-time feedback about rate limiting and system status
- Graceful Degradation: Maintains functionality while protecting system stability
# Environment Variables
LOG_LEVEL=INFO # Backend logging level
NEXT_PUBLIC_LOG_LEVEL=INFO # Frontend logging levelTry the interactive API rate limiting demo in the frontend to see the system in action!
AstraGuard-AI/
β
βββ .github/ # GitHub configuration
β βββ ISSUE_TEMPLATE/ # Issue templates
β β βββ bug_report.yml # Bug report template
β β βββ feature_request.yml # Feature request template
β βββ workflows/ # GitHub Actions workflows
β βββ ci.yml # Continuous integration
β βββ deploy.yml # Deployment pipeline
β
βββ dashboard/ # React frontend application
β βββ public/ # Static assets
β βββ src/ # Source code
β β βββ components/ # React components
β β β βββ Dashboard.jsx # Main dashboard
β β β βββ TelemetryChart.jsx # Real-time charts
β β β βββ HealthMonitor.jsx # System health display
β β βββ hooks/ # Custom React hooks
β β βββ utils/ # Utility functions
β β βββ App.jsx # Root component
β βββ package.json # Node dependencies
β βββ vite.config.js # Vite configuration
β
βββ research/ # π§ͺ Research Lab & Documentation
β βββ docs/ # Technical specifications
β β βββ architecture.md # System architecture
β β βββ ai_integration.md # AI/ML design docs
β β βββ security_model.md # Security model
β βββ reports/ # Lab reports and findings
β β βββ vulnerability_analysis.md
β β βββ performance_benchmarks.md
β βββ notebooks/ # Jupyter notebooks for experiments
β βββ anomaly_detection_experiments.ipynb
β
βββ src/ # Core source code
β βββ security_engine/ # Python-based security tools
β β βββ __init__.py
β β βββ scanner.py # Network scanning
β β βββ payload_generator.py # Smart payload creation
β β βββ proxy_handler.py # Traffic interception
β β βββ vulnerability_db.py # CVE database interface
β β
β βββ ai_agent/ # LLM integration logic
β β βββ __init__.py
β β βββ threat_analyzer.py # Attack surface analysis
β β βββ anomaly_detector.py # AI-powered anomaly detection
β β βββ reasoning_engine.py # Decision-making logic
β β βββ memory_store.py # Adaptive memory management
β β
β βββ api/ # FastAPI server
β β βββ __init__.py
β β βββ main.py # API entry point
β β βββ routes/ # API endpoints
β β β βββ telemetry.py # Telemetry ingestion
β β β βββ phase.py # Mission phase management
β β β βββ history.py # Historical data queries
β β βββ models.py # Pydantic data models
β β βββ dependencies.py # Dependency injection
β β
β βββ core/ # Core system components
β β βββ __init__.py
β β βββ error_handler.py # Centralized error handling
β β βββ health_monitor.py # System health tracking
β β βββ policy_engine.py # Mission phase policies
β β βββ config.py # Configuration management
β β
β βββ utils/ # Shared utilities
β βββ __init__.py
β βββ logger.py # Logging configuration
β βββ validators.py # Input validation
β
βββ tests/ # Automated test suite
β βββ unit/ # Unit tests
β β βββ test_scanner.py
β β βββ test_anomaly_detector.py
β β βββ test_policy_engine.py
β βββ integration/ # Integration tests
β β βββ test_api_endpoints.py
β β βββ test_end_to_end.py
β βββ fixtures/ # Test data and mocks
β βββ sample_telemetry.json
β
βββ examples/ # Usage examples
β βββ api_usage_examples.py # API integration examples
β βββ security_scan_example.py # Security engine usage
β βββ ai_analysis_example.py # AI agent usage
β
βββ docs/ # Documentation
β βββ GETTING_STARTED.md # Quick start guide
β βββ TECHNICAL.md # Technical documentation
β βββ TECHNICAL_REPORT.md # Detailed technical report
β βββ ERROR_HANDLING_GUIDE.md # Error handling best practices
β βββ API_REFERENCE.md # API documentation
β βββ ARCHITECTURE.md # Architecture deep-dive
β
βββ config/ # Configuration files
β βββ mission_phases.yaml # Phase definitions
β βββ security_policies.yaml # Security policies
β βββ model_config.yaml # AI model configuration
β
βββ scripts/ # Utility scripts
β βββ setup_dev_env.sh # Development environment setup
β βββ run_tests.sh # Test runner
β βββ deploy.sh # Deployment script
β
βββ .env.example # Environment variables template
βββ .gitignore # Git ignore rules
βββ CHANGES.md # Changelog
βββ CONTRIBUTING.md # Contribution guidelines
βββ LICENSE # MIT License
βββ README.md # This file
βββ requirements.txt # Python dependencies
βββ cli.py # Command-line interface
βββ run_api.py # API server entry point
Before installing AstraGuard AI, ensure you have the following:
| Software | Minimum Version | Recommended Version | Purpose |
|---|---|---|---|
| Python | 3.9 | 3.11+ | Core runtime |
| Node.js | 16.0 | 20.0+ | Frontend & tooling |
| Git | 2.30 | Latest | Version control |
| Docker | 20.0 (optional) | Latest | Containerization |
- OS: Linux, macOS, or Windows (WSL2 recommended)
- RAM: 4GB minimum, 8GB recommended
- Storage: 2GB free space
- Network: Internet connection for initial setup
# Clone via HTTPS
git clone https://github.com/sr-857/AstraGuard-AI.git
# Or clone via SSH (if you have SSH keys configured)
git clone git@github.com:sr-857/AstraGuard-AI.git
# Navigate to project directory
cd AstraGuard-AI
# Verify clone was successful
ls -laOption A: Using venv (Recommended)
# Check Python version (must be 3.9+)
python --version
# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Linux/macOS:
source venv/bin/activate
# On Windows:
venv\Scripts\activate
# Verify activation (you should see (venv) in your prompt)
which python # Should point to venv/bin/python or venv\Scripts\python.exe
# Upgrade pip to latest version
pip install --upgrade pip
# Install Python dependencies
pip install -r requirements.txt
# Verify installation
python -c "import fastapi, pydantic, scapy; print('β
All core dependencies installed')"Option B: Using conda
# Create conda environment
conda create -n astraguard python=3.11 -y
# Activate environment
conda activate astraguard
# Install dependencies
pip install -r requirements.txt
# Verify environment
conda info --envs # Should show astraguard as active# Check Node.js version (must be 16+)
node --version
npm --version
# Navigate to dashboard directory
cd dashboard
# Install Node.js dependencies
npm install
# Verify installation
npm list --depth=0
# Return to project root
cd ..# Copy example environment file
cp .env.example .env
# Edit .env with your preferred editor
# On Linux/macOS:
nano .env
# On Windows:
notepad .env
# Or use VS Code:
code .envRequired Environment Variables:
# .env file
# ==========================================
# API Configuration
# ==========================================
API_HOST=0.0.0.0
API_PORT=8000
API_DEBUG=True
API_WORKERS=1
# ==========================================
# Database Configuration
# ==========================================
MONGODB_URI=mongodb://localhost:27017
MONGODB_DB=astraguard
MONGODB_TIMEOUT=5000
# ==========================================
# AI Model Configuration
# ==========================================
OLLAMA_MODEL=llama3
OLLAMA_HOST=http://localhost:11434
OLLAMA_TIMEOUT=30
# ==========================================
# Mission Configuration
# ==========================================
DEFAULT_MISSION_PHASE=NOMINAL_OPS
MISSION_CONFIG_PATH=config/mission_policies.yaml
# ==========================================
# Logging Configuration
# ==========================================
LOG_LEVEL=INFO
LOG_FILE=logs/astraguard.log
LOG_MAX_SIZE=10MB
LOG_BACKUP_COUNT=5
# ==========================================
# Security Configuration
# ==========================================
SECRET_KEY=your-secret-key-here-change-in-production
JWT_SECRET=your-jwt-secret-here
API_KEY=your-api-key-here
# ==========================================
# Monitoring Configuration
# ==========================================
PROMETHEUS_ENABLED=True
PROMETHEUS_PORT=9090
GRAFANA_ENABLED=TrueLinux/macOS:
# Download and install Ollama
curl -fsSL https://ollama.ai/install.sh | sh
# Verify installation
ollama --version
# Start Ollama service (runs in background)
ollama serve &Windows:
# Download from https://ollama.ai/download
# Install the .exe file
# Start Ollama from Start Menu or command line
ollama servePull Required AI Models:
# Pull Llama 3 model (recommended for best performance)
ollama pull llama3
# Alternative: Pull Mistral model (lighter weight)
ollama pull mistral
# Verify models are available
ollama list
# Expected output:
# NAME ID SIZE MODIFIED
# llama3:latest 365c0bd3c000 4.7 GB 2 minutes ago
# mistral:latest 61e88e884507 4.1 GB 1 minute agoOption A: Using Docker (Recommended)
# Install Docker if not already installed
# Linux/macOS: https://docs.docker.com/get-docker/
# Windows: https://docs.docker.com/docker-for-windows/install/
# Start MongoDB container
docker run -d \
--name astraguard-mongodb \
-p 27017:27017 \
-v mongodb_data:/data/db \
--restart unless-stopped \
mongo:latest
# Verify MongoDB is running
docker ps | grep mongodb
# Test connection
docker exec -it astraguard-mongodb mongosh --eval "db.runCommand('ping')"Option B: Local MongoDB Installation
# Ubuntu/Debian:
sudo apt update
sudo apt install mongodb
# macOS:
brew install mongodb-community
brew services start mongodb-community
# Windows: Download from mongodb.com
# Verify installation
mongod --version# Run comprehensive health check
python cli.py status
# Expected output should show all components as HEALTHY:
# β
Python environment: OK (3.11.0)
# β
Dependencies installed: OK
# β
Ollama running: OK (llama3 loaded)
# β
Database connection: OK
# β
Configuration valid: OK
# β
All systems operational
# If any component shows FAILED, check the troubleshooting section below# Generate sample telemetry data for testing
python cli.py telemetry --duration 300 --output sample_data.json
# Load mission phase policies
python cli.py config --validate-policies
# Run initial system tests
python cli.py test --suite smokeAstraGuard AI provides cross-platform build scripts for automated setup:
Option A: Python Build Script (Recommended - Cross-platform)
# Works on Windows, Linux, and macOS
python build.pyOption B: Bash Script (Linux/macOS)
# Make executable and run
chmod +x build.sh
./build.shOption C: Windows Batch Script
# Run on Windows Command Prompt
build.batWhat the build script does:
- β Checks for required tools (Python, npm)
- β
Installs Python dependencies from
requirements.txt - β
Builds the Next.js frontend in
frontend/as_lp/ - β Validates all installations
- β Provides clear error messages and next steps
Manual Build (if scripts fail):
# Install Python dependencies
pip install -r requirements.txt
# Build frontend
cd frontend/as_lp
npm install
npm run build
cd ../..AstraGuard AI provides a unified CLI for all operations:
# Show help and available commands
python cli.py --help
# Check system status
python cli.py status
# View current configuration
python cli.py config --show# Start Streamlit dashboard
python cli.py dashboard
# Start on custom port
python cli.py dashboard --port 8502
# Start with specific configuration
python cli.py dashboard --config config/custom.yamlAccess dashboard at: http://localhost:8501
# Start FastAPI server
python cli.py api
# Start with auto-reload (development mode)
python cli.py api --reload
# Start on custom host/port
python cli.py api --host 0.0.0.0 --port 9000
# Start with specific workers
python cli.py api --workers 4Access API docs at: http://localhost:8000/docs
# Generate sample telemetry stream
python cli.py telemetry
# Generate with custom parameters
python cli.py telemetry --duration 3600 --interval 1
# Generate and save to file
python cli.py telemetry --output telemetry_data.json
# Import telemetry from file
python cli.py telemetry --import telemetry_data.json# Run fault classifier on live data
python cli.py classify
# Classify historical data
python cli.py classify --input data/historical.json
# Run in analysis mode (no actions)
python cli.py classify --analyze-only# View recent logs
python cli.py logs
# Export logs to file
python cli.py logs --export output.json
# Export with filters
python cli.py logs --export output.json --level ERROR --since "2026-01-01"
# Clear old logs
python cli.py logs --clear --before "2025-12-01"# Run all tests
python cli.py test
# Run specific test suite
python cli.py test --suite unit
python cli.py test --suite integration
# Run with coverage report
python cli.py test --coverage
# Run specific test file
python cli.py test --file tests/unit/test_scanner.py# Format code with Black
python cli.py format
# Run linter
python cli.py lint
# Type checking with mypy
python cli.py typecheck
# Security scanning (Bandit + Safety)
python cli.py security
# Run all checks
python cli.py check # format + lint + typecheck + tests + securityAstraGuard AI includes automated security scanning to detect vulnerabilities:
# Install security tools
pip install -r config/requirements-dev.txt
# Run Bandit (static security analysis)
bandit -r core anomaly state_machine memory_engine
# Run Safety (dependency vulnerability scanning)
safety check --file=config/requirements.txt
safety check --file=config/requirements-dev.txt
# Run all security checks (via test script)
./run_tests.sh --qualityFor a containerized setup:
# Build Docker image
docker build -t astraguard-ai .
# Run dashboard container
docker run -p 8501:8501 astraguard-ai dashboard
# Run API container
docker run -p 8000:8000 astraguard-ai api
# Run with docker-compose (all services)
docker-compose up -d-
π Read the Documentation
-
π Complete the Tutorial
- Follow the First Steps Tutorial
- Try the API Examples
- Explore the Security Scanner
-
π€ Join the Community
- Join our WhatsApp Group
- Check out Good First Issues
- Read Contributing Guidelines
import requests
import json
# Base URL
BASE_URL = "http://localhost:8000/api/v1"
# 1. Check system health
response = requests.get(f"{BASE_URL}/status")
print(json.dumps(response.json(), indent=2))
# 2. Submit telemetry for analysis
telemetry = {
"timestamp": "2026-01-04T12:00:00Z",
"voltage": 7.2,
"temperature": 35.5,
"gyro": 0.08,
"mission_phase": "NOMINAL_OPS"
}
response = requests.post(f"{BASE_URL}/telemetry", json=telemetry)
result = response.json()
if result['is_anomaly']:
print(f"β οΈ ANOMALY DETECTED!")
print(f" Type: {result['anomaly_type']}")
print(f" Confidence: {result['confidence']:.2%}")
print(f" Recommended Action: {result['recommended_action']}")
print(f" Reasoning: {result['reasoning']}")
else:
print("β
All systems nominal")
# 3. Query historical anomalies
response = requests.get(f"{BASE_URL}/history/anomalies", params={
"start_time": "2026-01-03T00:00:00Z",
"end_time": "2026-01-04T23:59:59Z",
"min_confidence": 0.8
})
anomalies = response.json()
print(f"\nFound {len(anomalies['items'])} high-confidence anomalies")Submit Single Telemetry Point
POST /api/v1/telemetry
Content-Type: application/json
{
"timestamp": "2026-01-04T12:00:00Z",
"voltage": 7.2,
"temperature": 35.5,
"gyro": 0.08,
"mission_phase": "NOMINAL_OPS"
}Response:
{
"is_anomaly": true,
"anomaly_type": "VOLTAGE_DROP",
"confidence": 0.94,
"recommended_action": "POWER_OPTIMIZATION",
"reasoning": "Voltage dropped below 7.3V threshold during NOMINAL_OPS phase",
"telemetry_id": "tlm_abc123",
"processed_at": "2026-01-04T12:00:01Z"
}Submit Batch Telemetry
POST /api/v1/telemetry/batch
Content-Type: application/json
{
"items": [
{"timestamp": "2026-01-04T12:00:00Z", "voltage": 7.4, ...},
{"timestamp": "2026-01-04T12:01:00Z", "voltage": 7.3, ...},
...
]
}Response:
{
"processed_count": 100,
"total_count": 100,
"anomaly_count": 3,
"processing_time_ms": 247,
"anomalies": [
{"index": 15, "type": "VOLTAGE_DROP", "confidence": 0.89},
{"index": 42, "type": "TEMPERATURE_SPIKE", "confidence": 0.92},
{"index": 78, "type": "GYRO_DRIFT", "confidence": 0.87}
]
}Get System Status
GET /api/v1/statusResponse:
{
"overall_status": "HEALTHY",
"timestamp": "2026-01-04T12:00:00Z",
"uptime_seconds": 86400,
"components": {
"ai_model": {"status": "HEALTHY", "details": "Llama3 loaded"},
"memory_store": {"status": "HEALTHY", "details": "1247 patterns stored"},
"policy_engine": {"status": "HEALTHY", "details": "All phases configured"},
"action_orchestrator": {"status": "DEGRADED", "details": "Retry mode active"},
"database": {"status": "HEALTHY", "details": "Connected to MongoDB"},
"api_server": {"status": "HEALTHY", "details": "All endpoints operational"}
},
"metrics": {
"total_telemetry_processed": 15234,
"anomalies_detected": 42,
"actions_taken": 18,
"avg_response_time_ms": 156
}
}Get Current Mission Phase
GET /api/v1/phaseResponse:
{
"phase": "NOMINAL_OPS",
"set_at": "2026-01-04T08:00:00Z",
"duration_seconds": 14400,
"constraints": {
"max_actions": null,
"allowed_actions": ["LOG", "ALERT", "RECOVER", "OPTIMIZE"],
"power_change_limit": "50%",
"attitude_change_allowed": true
},
"next_review": "2026-01-04T16:00:00Z"
}Update Mission Phase
POST /api/v1/phase
Content-Type: application/json
{
"phase": "PAYLOAD_OPS",
"reason": "Starting science data collection"
}Response:
{
"previous_phase": "NOMINAL_OPS",
"new_phase": "PAYLOAD_OPS",
"changed_at": "2026-01-04T12:00:00Z",
"reason": "Starting science data collection",
"constraints_updated": true
}Get Memory Statistics
GET /api/v1/memory/statsResponse:
{
"total_patterns": 1247,
"pattern_categories": {
"VOLTAGE_DROP": 342,
"TEMPERATURE_SPIKE": 187,
"GYRO_DRIFT": 156,
"NORMAL": 562
},
"oldest_pattern": "2026-01-01T00:00:00Z",
"newest_pattern": "2026-01-04T12:00:00Z",
"storage_size_mb": 12.4,
"avg_pattern_age_hours": 48.3
}Query Anomaly History
GET /api/v1/history/anomalies?start_time=2026-01-03T00:00:00Z&end_time=2026-01-04T23:59:59Z&anomaly_type=VOLTAGE_DROP&min_confidence=0.8Response:
{
"items": [
{
"id": "anom_123",
"timestamp": "2026-01-04T08:15:23Z",
"type": "VOLTAGE_DROP",
"confidence": 0.94,
"telemetry": {"voltage": 6.8, "temperature": 32.1, "gyro": 0.03},
"mission_phase": "NOMINAL_OPS",
"action_taken": "POWER_OPTIMIZATION",
"outcome": "SUCCESS",
"recovery_time_seconds": 45
},
...
],
"total_count": 15,
"page": 1,
"page_size": 50
}Export Historical Data
GET /api/v1/history/export?format=json&start_time=2026-01-01T00:00:00Z&end_time=2026-01-04T23:59:59ZReturns downloadable file with all telemetry and anomaly data.
import requests
import time
BASE_URL = "http://localhost:8000/api/v1"
def monitor_telemetry(duration_seconds=3600, interval=1):
"""Monitor telemetry for specified duration"""
start_time = time.time()
anomaly_count = 0
while time.time() - start_time < duration_seconds:
# Simulate getting telemetry (replace with actual sensor readings)
telemetry = {
"timestamp": time.strftime("%Y-%m-%dT%H:%M:%SZ"),
"voltage": 7.2 + (time.time() % 10) / 100, # Simulated
"temperature": 32.0 + (time.time() % 20) / 10,
"gyro": 0.02 + (time.time() % 5) / 1000
}
# Submit to API
response = requests.post(f"{BASE_URL}/telemetry", json=telemetry)
result = response.json()
if result['is_anomaly']:
anomaly_count += 1
print(f"β οΈ Anomaly #{anomaly_count}: {result['anomaly_type']}")
print(f" Action: {result['recommended_action']}")
else:
print("β
Normal")
time.sleep(interval)
print(f"\nMonitoring complete. Detected {anomaly_count} anomalies.")
# Run monitoring
monitor_telemetry(duration_seconds=300) # 5 minutesimport requests
import json
BASE_URL = "http://localhost:8000/api/v1"
def analyze_historical_data(filepath):
"""Analyze historical telemetry from file"""
# Load historical data
with open(filepath, 'r') as f:
data = json.load(f)
# Submit in batches of 100
batch_size = 100
total_anomalies = 0
for i in range(0, len(data), batch_size):
batch = data[i:i+batch_size]
response = requests.post(f"{BASE_URL}/telemetry/batch", json={
"items": batch
})
result = response.json()
total_anomalies += result['anomaly_count']
print(f"Batch {i//batch_size + 1}: {result['anomaly_count']} anomalies")
print(f"\nTotal anomalies in dataset: {total_anomalies}")
# Run analysis
analyze_historical_data("data/historical_telemetry.json")import requests
BASE_URL = "http://localhost:8000/api/v1"
def transition_mission_phase(new_phase, reason):
"""Safely transition to new mission phase"""
# Get current phase
current = requests.get(f"{BASE_URL}/phase").json()
print(f"Current phase: {current['phase']}")
# Update to new phase
response = requests.post(f"{BASE_URL}/phase", json={
"phase": new_phase,
"reason": reason
})
if response.status_code == 200:
result = response.json()
print(f"β
Transitioned to {result['new_phase']}")
print(f" Reason: {result['reason']}")
print(f" New constraints: {result['constraints_updated']}")
else:
print(f"β Transition failed: {response.json()['detail']}")
# Example transitions
transition_mission_phase("PAYLOAD_OPS", "Starting science data collection")
transition_mission_phase("SAFE_MODE", "Critical battery low warning")import requests
from collections import Counter
import matplotlib.pyplot as plt
BASE_URL = "http://localhost:8000/api/v1"
def analyze_anomaly_patterns(days=7):
"""Analyze anomaly patterns over time"""
# Query last N days of anomalies
end_time = "2026-01-04T23:59:59Z"
start_time = f"2026-01-{4-days:02d}T00:00:00Z"
response = requests.get(f"{BASE_URL}/history/anomalies", params={
"start_time": start_time,
"end_time": end_time
})
anomalies = response.json()['items']
# Count by type
type_counts = Counter(a['type'] for a in anomalies)
# Count by mission phase
phase_counts = Counter(a['mission_phase'] for a in anomalies)
print(f"Anomaly Analysis ({days} days)")
print(f"Total anomalies: {len(anomalies)}")
print("\nBy Type:")
for type_, count in type_counts.most_common():
print(f" {type_}: {count}")
print("\nBy Mission Phase:")
for phase, count in phase_counts.most_common():
print(f" {phase}: {count}")
# Visualization
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5))
ax1.bar(type_counts.keys(), type_counts.values())
ax1.set_title("Anomalies by Type")
ax1.set_xlabel("Type")
ax1.set_ylabel("Count")
ax1.tick_params(axis='x', rotation=45)
ax2.pie(phase_counts.values(), labels=phase_counts.keys(), autopct='%1.1f%%')
ax2.set_title("Anomalies by Mission Phase")
plt.tight_layout()
plt.savefig("anomaly_analysis.png")
print("\nVisualization saved to anomaly_analysis.png")
# Run analysis
analyze_anomaly_patterns(days=7)π More Examples: See examples/api_usage_examples.py for complete code
We welcome contributions of all types! Here's how to get started:
Browse our issue tracker:
- π’ Good First Issue: Perfect for newcomers
- π‘ Help Wanted: Need community assistance
- π΄ High Priority: Urgent items for the project
Comment on the issue with:
I'd like to work on this!
Expected completion: [date]
Maintainers will assign it to you within 24 hours.
# Fork the repository on GitHub, then:
git clone https://github.com/YOUR_USERNAME/AstraGuard-AI.git
cd AstraGuard-AI
# Add upstream remote
git remote add upstream https://github.com/sr-857/AstraGuard-AI.git# Create feature branch
git checkout -b feature/your-feature-name
# Or bugfix branch
git checkout -b bugfix/issue-number-descriptionBranch naming convention:
feature/add-health-monitoringbugfix/123-fix-api-timeoutdocs/update-readmetest/add-scanner-tests
- Write clean, well-documented code
- Follow our Code Style Guide
- Add tests for new features
- Update documentation if needed
# Run all tests
python cli.py test
# Run specific tests
python cli.py test --file tests/unit/test_your_feature.py
# Check code formatting
python cli.py format --check
# Run linter
python cli.py lint# Stage your changes
git add .
# Commit with descriptive message
git commit -m "feat: add health monitoring endpoint
- Implement GET /api/v1/status endpoint
- Add component health tracking
- Include system metrics in response
- Add comprehensive tests
Closes #123"Commit message format:
<type>: <short description>
<detailed description>
<footer>
Types: feat, fix, docs, test, refactor, style, chore
# Push to your fork
git push origin feature/your-feature-nameThen create a Pull Request on GitHub with:
PR Title: [Type] Brief description
Example: [Feature] Add health monitoring endpoint
PR Description Template:
## Description
Brief description of changes
## Related Issue
Closes #123
## Type of Change
- [ ] Bug fix
- [x] New feature
- [ ] Documentation update
- [ ] Performance improvement
## Testing
- [x] Unit tests added/updated
- [x] Integration tests added/updated
- [x] Manual testing completed
## Checklist
- [x] Code follows style guide
- [x] Documentation updated
- [x] Tests pass locally
- [x] No breaking changes- Respond to reviewer feedback within 48 hours
- Make requested changes in new commits
- Don't force-push after review starts
- Mark conversations as resolved when addressed
Once approved, a maintainer will merge your PR. Congratulations! π
We're looking for contributors in these areas:
Required Skills:
- React 18+ and hooks
- TailwindCSS or similar CSS framework
- Data visualization (Recharts/D3.js)
Projects:
- Real-time telemetry dashboard
- Anomaly visualization components
- Mission phase control panel
- Health monitoring interface
Good First Issues:
#45- Add dark mode to dashboard#52- Improve chart responsiveness#61- Create mission phase selector component
Required Skills:
- Python 3.9+ (FastAPI experience preferred)
- RESTful API design
- Database design (MongoDB)
- Async programming
Projects:
- API endpoint implementation
- Database optimization
- Authentication system
- WebSocket support for real-time updates
Good First Issues:
#38- Add pagination to anomaly history endpoint#47- Implement API rate limiting#56- Add authentication middleware
Required Skills:
- Python for security tooling
- Network protocols (TCP/IP, HTTP)
- Basic penetration testing knowledge
- Familiarity with Scapy/Nmap
Projects:
- Payload generator improvements
- Vulnerability scanner enhancements
- Security test suite
- Research lab experiments
Good First Issues:
#42- Add SQL injection payload templates#49- Implement XSS detection#58- Create vulnerability database connector
β
Quality over quantity: One well-tested feature > ten half-finished PRs
β
Clear communication: Ask questions, share progress, flag blockers
β
Documentation: Code comments, README updates, API docs
β
Testing: Unit tests, integration tests, manual verification
β
Best practices: Follow conventions, write maintainable code
β Spam PRs (minor formatting changes, typo fixes in non-critical areas)
β Uncommented complex code
β Breaking changes without discussion
β Copy-pasted code without attribution
β PRs without associated issues (except docs/typos)
π Full Guidelines: CONTRIBUTING.md
Before diving into specific issues, run this diagnostic script:
# Create diagnostic script
cat > diagnose.py << 'EOF'
#!/usr/bin/env python3
import sys
import subprocess
import requests
import json
def run_command(cmd, description):
"""Run command and return success status"""
try:
result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=10)
success = result.returncode == 0
print(f"{'β
' if success else 'β'} {description}: {'OK' if success else 'FAILED'}")
if not success:
print(f" Error: {result.stderr.strip()}")
return success
except Exception as e:
print(f"β {description}: FAILED")
print(f" Error: {e}")
return False
def check_service(url, name):
"""Check if service is responding"""
try:
response = requests.get(url, timeout=5)
success = response.status_code == 200
print(f"{'β
' if success else 'β'} {name}: {'OK' if success else 'FAILED'}")
if not success:
print(f" Status: {response.status_code}")
return success
except Exception as e:
print(f"β {name}: FAILED")
print(f" Error: {e}")
return False
print("π AstraGuard AI Diagnostic Report")
print("=" * 40)
# System checks
print("\nπ System Requirements:")
run_command("python --version", "Python version (3.9+)")
run_command("node --version", "Node.js version (16+)")
run_command("npm --version", "NPM version")
run_command("docker --version", "Docker version")
# Environment checks
print("\nπ Python Environment:")
run_command("python -c 'import fastapi, pydantic, scapy'", "Core dependencies")
run_command("python -c 'import ollama'", "Ollama client")
# Service checks
print("\nπ Services:")
check_service("http://localhost:11434/api/version", "Ollama API")
check_service("http://localhost:27017", "MongoDB")
check_service("http://localhost:8000/api/v1/status", "AstraGuard API")
check_service("http://localhost:8501", "Dashboard")
# Configuration checks
print("\nβοΈ Configuration:")
run_command("test -f .env", ".env file exists")
run_command("test -f config/mission_policies.yaml", "Mission policies")
run_command("test -d logs", "Logs directory")
print("\nπ Next Steps:")
print("1. Fix any FAILED items above")
print("2. Check logs/astraguard.log for errors")
print("3. Run 'python cli.py status' for detailed status")
print("4. See troubleshooting section below for specific issues")
EOF
# Run diagnostic
python diagnose.pyIssue: Installation fails with "Python 3.9+ required"
Solution:
# Check current version
python --version
# If too old, install Python 3.11
# On Ubuntu/Debian:
sudo apt update
sudo apt install python3.11 python3.11-venv
# On macOS:
brew install python@3.11
# On Windows:
# Download from python.orgVerify:
python3.11 --version
python3.11 -m venv venvπ¦ Dependency Installation Fails
Issue: pip install -r requirements.txt fails with compilation errors
Solution:
# Upgrade pip and setuptools
pip install --upgrade pip setuptools wheel
# Install system dependencies first
# On Ubuntu/Debian:
sudo apt install python3-dev build-essential
# On macOS:
xcode-select --install
# Retry installation
pip install -r requirements.txtAlternative: Install dependencies individually to identify problem package
pip install fastapi
pip install pydantic
pip install scapy
# ... etcπ₯ Streamlit Command Not Found
Issue: streamlit: command not found
Solution:
# Ensure virtual environment is activated
source venv/bin/activate # Linux/macOS
venv\Scripts\activate # Windows
# Install Streamlit explicitly
pip install streamlit
# Verify installation
streamlit --version
# If still not found, use module syntax
python -m streamlit run dashboard/app.pyπ Port Already in Use
Issue: "Address already in use" when starting dashboard/API
Solution:
# Find process using port 8501 (Streamlit)
lsof -i :8501 # Linux/macOS
netstat -ano | findstr :8501 # Windows
# Kill the process
kill -9 <PID> # Linux/macOS
taskkill /PID <PID> /F # Windows
# Or run on different port
streamlit run dashboard/app.py --server.port 8502
python cli.py api --port 9000π€ Ollama Connection Fails
Issue: "Cannot connect to Ollama server"
Solution:
# Check if Ollama is running
curl http://localhost:11434/api/version
# If not running, start it
# Linux/macOS:
ollama serve
# Check if model is installed
ollama list
# Pull model if missing
ollama pull llama3
# Update .env with correct host
OLLAMA_HOST=http://localhost:11434ποΈ MongoDB Connection Errors
Issue: "Cannot connect to MongoDB"
Solution:
# Check if MongoDB is running
# Linux:
sudo systemctl status mongodb
# macOS:
brew services list
# If not running, start it
# Linux:
sudo systemctl start mongodb
# macOS:
brew services start mongodb-community
# Or use Docker:
docker run -d -p 27017:27017 --name mongodb mongo:latest
# Verify connection
mongosh # Should connect successfullyπ Dashboard Shows No Data
Issue: Dashboard loads but displays no telemetry
Solution:
# Generate sample telemetry
python cli.py telemetry --duration 60
# Check if API is running
curl http://localhost:8000/api/v1/status
# Verify configuration
python cli.py config --show | grep API_
# Check logs for errors
python cli.py logs --level ERROR
# Restart dashboard with debug mode
python cli.py dashboard --debugβ‘ API Tests Failing
Issue: Tests fail with connection or timeout errors
Solution:
# Run tests in verbose mode
pytest -v tests/
# Run specific failing test
pytest tests/integration/test_api.py::test_telemetry_endpoint -v
# Check test environment
python -m pytest --version
# Reset test database
python cli.py test --reset-db
# Ensure no conflicting processes
pkill -f "python.*api"
python cli.py api &
sleep 2
pytest tests/π Permission Denied Errors
Issue: "Permission denied" when accessing files/directories
Solution:
# Check file permissions
ls -la
# Fix permissions for project directory
chmod -R u+rw .
# For log directory
sudo chown -R $USER:$USER logs/
# For pip installation issues
pip install --user -r requirements.txtπ§ AI Model Performance Issues
Issue: AI analysis is very slow or times out
Solution:
# Use faster model
ollama pull llama3:70b-instruct-q4_K_M # Quantized version
# Update config
nano config/model_config.yaml
# Set: model_name: "llama3:70b-instruct-q4_K_M"
# Allocate more resources
# In .env:
OLLAMA_NUM_PARALLEL=4
OLLAMA_MAX_LOADED_MODELS=2
# Monitor resource usage
ollama ps
# Reduce context window
# In model_config.yaml:
context_window: 2048 # Instead of 4096π¦ Docker Build Fails
Issue: Docker image build fails
Solution:
# Clean Docker cache
docker system prune -a
# Build with verbose output
docker build -t astraguard-ai . --progress=plain
# Build with no cache
docker build -t astraguard-ai . --no-cache
# Check Docker disk space
docker system df
# Increase Docker memory
# Docker Desktop -> Settings -> Resources -> Memory: 4GB+If you're still stuck after trying the solutions above:
- π Check Documentation: docs/TROUBLESHOOTING.md
- π Search Issues: GitHub Issues
- π¬ Ask Community: WhatsApp Group
- π Report Bug: Bug Report Template
When reporting issues, include:
- OS and version (
systeminfoon Windows,uname -aon Linux/macOS) - Python version (
python --version) - Full error message and stack trace
- Output of
python cli.py status - Recent logs (
python cli.py logs --tail 50) - Steps to reproduce the issue
- Expected vs actual behavior
Debug Information Script:
# Run this to gather debug info
cat > debug_info.py << 'EOF'
#!/usr/bin/env python3
import sys
import platform
import subprocess
print("π AstraGuard AI Debug Information")
print("=" * 40)
print(f"OS: {platform.system()} {platform.release()}")
print(f"Python: {sys.version}")
print(f"Executable: {sys.executable}")
print("\nπ¦ Installed Packages:")
try:
result = subprocess.run([sys.executable, "-m", "pip", "list"],
capture_output=True, text=True)
for line in result.stdout.split('\n')[:20]: # First 20 packages
if line.strip():
print(f" {line}")
if len(result.stdout.split('\n')) > 20:
print(" ... (truncated)")
except:
print(" Could not retrieve package list")
print("\nπ Environment Variables:")
import os
for key in ['OLLAMA_HOST', 'MONGODB_URI', 'API_HOST', 'API_PORT']:
value = os.getenv(key, 'Not set')
print(f" {key}: {value}")
print("\nπ§ System Status:")
try:
import requests
services = [
("Ollama", "http://localhost:11434/api/version"),
("MongoDB", "http://localhost:27017"),
("API", "http://localhost:8000/api/v1/status"),
("Dashboard", "http://localhost:8501")
]
for name, url in services:
try:
resp = requests.get(url, timeout=3)
print(f" {name}: {resp.status_code}")
except:
print(f" {name}: Connection failed")
except:
print(" Could not check services")
print("\nπ File Structure:")
import os
files_to_check = ['.env', 'requirements.txt', 'config/mission_policies.yaml', 'logs/']
for file in files_to_check:
exists = os.path.exists(file)
print(f" {file}: {'Exists' if exists else 'Missing'}")
EOF
python debug_info.pyInclude this output when asking for help!
| Document | Description | Audience |
|---|---|---|
| Getting Started | Quick start guide for new users | Everyone |
| Technical Documentation | Detailed system architecture | Developers |
| Technical Report | Academic-style technical report | Researchers |
| API Reference | Complete API documentation | API Users |
| Contributing Guide | How to contribute to the project | Contributors |
| Document | Description | Audience |
|---|---|---|
| Architecture Deep-Dive | System design and patterns | Senior Developers |
| Error Handling Guide | Error handling best practices | All Developers |
| Mission-Phase Policies | Phase configuration guide | Operators |
| Security Model | Security architecture | Security Team |
| Performance Tuning | Optimization guide | DevOps |
| Document | Description | Audience |
|---|---|---|
| AI Integration | LLM integration strategy | ML Engineers |
| Vulnerability Analysis | Security findings | Security Researchers |
| Performance Benchmarks | System benchmarks | Performance Engineers |
- π₯ Video Tutorials
- π‘ Code Examples
- π§ͺ Test Examples
- π¨ UI Components
Link: https://chat.whatsapp.com/HZXk0vo62945S33qTXheON
Purpose: Formal team collaboration and project discussion
Rules:
- Project-related discussions only
- No sensitive data or credentials
- Be respectful and professional
- Response time: < 6 hours
Link: github.com/sr-857/AstraGuard-AI/discussions
Categories:
- π‘ Ideas & Feature Requests
- β Q&A (Technical Questions)
- π Show & Tell (Your Implementations)
- π’ Announcements
Server invite will be shared once we reach 10 contributors.
| Need | Where to Go | Response Time |
|---|---|---|
| Bug Report | GitHub Issues | < 24 hours |
| Feature Request | GitHub Issues | < 48 hours |
| Quick Question | WhatsApp Group | < 6 hours |
| Technical Discussion | GitHub Discussions | < 48 hours |
| Security Issue | Email (see SECURITY.md) | < 12 hours |
When: Every Friday, 6-7 PM IST
Where: Discord (link in WhatsApp group)
Format: Open Q&A, pair programming, code reviews
Thanks to all our amazing contributors! π
See CONTRIBUTORS.md for complete list.
This project is licensed under the MIT License - see the LICENSE file for details.
β You can:
- Use the code commercially
- Modify the code
- Distribute the code
- Use it privately
- Sublicense
β You must:
- Include the license and copyright notice
- Not hold us liable
π Learn more: MIT License Explained