feat: initial project setup with scenarios, database and web ui

Add complete mockupAWS platform for AWS cost estimation:
- FastAPI backend with scenario management
- PostgreSQL database schema for scenarios, metrics, logs
- AWS pricing table with real pricing data
- React frontend dashboard (planned)
- PII detection and token counting
- Report generation (PDF/CSV)
- Complete test suite with pytest
- Docker Compose setup
- Documentation: README, PRD, Architecture
- OpenCode configuration (.opencode/)
This commit is contained in:
Luca Sacchi Ricciardi
2026-04-07 12:52:18 +02:00
parent b539134280
commit 59e5cf48f0
23 changed files with 2982 additions and 29 deletions

26
src/profiler.py Normal file
View File

@@ -0,0 +1,26 @@
import sys
import tiktoken
# Inizializziamo l'encoder globalmente.
# cl100k_base è lo standard di fatto per le misurazioni token moderne.
_encoder = tiktoken.get_encoding("cl100k_base")
def count_tokens(text: str) -> int:
"""
Calcola il numero esatto di token in ingresso per una data stringa.
Fondamentale per il calcolo accurato dei costi LLM.
"""
if not text:
return 0
return len(_encoder.encode(text))
def calculate_sqs_blocks(payload_json: str) -> int:
"""
Calcola i blocchi fatturabili per Amazon SQS.
AWS addebita 1 richiesta per ogni payload (o frammento) fino a 64 KB (65536 bytes).
"""
# sys.getsizeof restituisce la dimensione in byte della stringa in memoria
payload_size_bytes = sys.getsizeof(payload_json)
# Calcolo dei blocchi (divisione intera + 1)
return (payload_size_bytes // 65536) + 1