File size: 2,613 Bytes
fe893f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from typing import Dict, Any, List

class TechKnowledgeBase:
    def __init__(self):
        self.architect_patterns = {
            "microservices": "Decoupled services communicating via API/Events. Pros: Scalability. Cons: Complexity.",
            "serverless": "Event-driven, scale-to-zero logic. Best for intermittent workloads.",
            "layered_architecture": "Separation of concerns (UI, Domain, Data). Standard for enterprise apps."
        }
        
        self.api_best_practices = {
            "versioning": "Use URL versioning (e.g., /v1/) or Header versioning.",
            "security": "Implement OAuth2/OIDC. Use rate limiting and input validation.",
            "documentation": "OAS3 (Swagger) is the industry standard for REST APIs."
        }
        
        self.webhook_wizardry = {
            "security": "Verify signatures using HMAC SHA256. Use secret rotation.",
            "reliability": "Implement exponential backoff retries. Use an idempotency key to prevent double processing.",
            "payloads": "Keep payloads small; use 'thin' webhooks that prompt a GET request for full data."
        }
        
        self.domain_routing = {
            "dns_types": {
                "A": "Points domain to IPv4.",
                "CNAME": "Alias for another domain (good for CDNs/PaaS).",
                "TXT": "Used for SPF/DKIM/DMARC and site verification.",
                "MX": "Mail Exchange records."
            },
            "ssl_tls": "Always use Let's Encrypt for automated certificates. Force HTTPS redirection."
        }
        
        self.app_builder_templates = {
            "fastapi_mcp": "Python-based high performance API with built-in MCP support.",
            "nextjs_tailwind": "Modern React frontend with utility-first CSS and server-side rendering.",
            "docker_slim": "Multi-stage builds to keep image size small and secure."
        }

    def get_info(self, module: str) -> Dict[str, Any]:
        data = {
            "architecture": self.architect_patterns,
            "api": self.api_best_practices,
            "webhooks": self.webhook_wizardry,
            "domains": self.domain_routing,
            "apps": self.app_builder_templates
        }
        return data.get(module, {"error": "Module knowledge not found."})

    def get_all(self) -> Dict[str, Any]:
        return {
            "architecture": self.architect_patterns,
            "api": self.api_best_practices,
            "webhooks": self.webhook_wizardry,
            "domains": self.domain_routing,
            "apps": self.app_builder_templates
        }