Un sistema completo per la gestione di ristoranti con funzionalitΓ OCR per l'estrazione di testo da documenti e immagini.
- OCR Automatico: Estrazione testo da PDF e immagini usando AWS Textract e pypdf
- Gestione Ristoranti: Database PostgreSQL per ristoranti e referenti
- Archiviazione Cloud: AWS S3 per documenti e immagini
- API Serverless: AWS Lambda per elaborazione backend
- Frontend Web: Interfaccia utente per upload e visualizzazione risultati
- Storico Estrazioni: Visualizza e scarica file elaborati in precedenza
- Analisi NLP: Validazione testo con Amazon Comprehend
- Monitoraggio Costi: Dashboard per costi AWS in tempo reale
- Python 3.8+
- AWS CLI configurato
- Terraform 1.0+
- Account AWS
git clone <repository-url>
cd Heypip install -r requirements.txtCopia il file di esempio e configura le tue credenziali:
cp .env.example .envModifica .env con i tuoi valori reali:
# Database PostgreSQL
DB_HOST=your-rds-endpoint.rds.amazonaws.com
DB_NAME=hey
DB_USER=postgres
DB_PASSWORD=your-secure-password-here
DB_PORT=5432
# AWS (opzionale, usa AWS CLI)
AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key
AWS_DEFAULT_REGION=eu-west-2Copia il file di variabili Terraform:
cp terraform.tfvars.example terraform.tfvarsModifica terraform.tfvars con i tuoi valori:
# Database password
db_username = "postgres"
db_password = "your-secure-password-here"
# AWS Region
region = "eu-west-2"
# Project name
project_name = "Hey"cd terraform
terraform init
terraform plan
terraform apply- β API Gateway con 6 routes (GET/POST/PUT)
- β Lambda Functions: validate-text, visitor-stats (+ altre in deploy)
- β
DynamoDB Tables: ocr-extractions, ocr-visitors, menu-items, ocr-todos
Note: I recently adjusted the Terraform DynamoDB configuration. The project keeps
hash_keyinterraform/dynamodb.tfto stay compatible with the current AWS provider in this repo; doterraform validatein theterraformfolder before applying changes. If you upgrade the provider to a version that supportskey_schema, consider migrating accordingly.
Developer Setup
- Enable repository hooks (recommended): the project provides a repository hooks folder
.githookswith apre-commitscript that validates Terraform and Python syntax. To enable locally run:
git config core.hooksPath .githooks- Quick validation workflow:
cd terraform
terraform init -backend=false
terraform validate-
Commits: We sign commits in this repo. Configure GPG signing or use your platform key. To skip hooks for a one-off commit, use
--no-verify. -
Docs: Additional developer docs are available in the
docs/folder β seedocs/index.md. -
β RDS PostgreSQL: Database per gestione ristoranti
-
β S3 Bucket: Hosting sito statico con CloudFront
-
β VPC: Rete isolata con subnet private/public
-
β WAF: Protezione sicurezza per il sito web
- Sito Web: Visita l'URL S3 website per l'interfaccia utente
- API: Usa l'API Gateway URL per chiamate backend
- Database: PostgreSQL accessibile via Lambda functions
IMPORTANTE: Questo progetto Γ¨ configurato per NON includere credenziali nel codice sorgente.
.env(variabili d'ambiente locali)terraform.tfvars(variabili Terraform)terraform.tfstate*(stato Terraform con dati sensibili)
import boto3
secrets_client = boto3.client('secretsmanager')
secret = secrets_client.get_secret_value(SecretId='your-db-secret')
db_config = json.loads(secret['SecretString'])import boto3
ssm_client = boto3.client('ssm')
password = ssm_client.get_parameter(
Name='/prod/db/password',
WithDecryption=True
)['Parameter']['Value']Configura le variabili d'ambiente direttamente nella console AWS Lambda o tramite Terraform.
# Esporta dati
python 'DB Management/export_db_csv.py'
# Controlla contenuto database
python 'DB Management/check_db.py'
# Backup completo
python 'DB Management/backup_data.py'
# Restore da backup
python 'DB Management/restore_data.py' backup_20240101_120000Apri site/index.html nel browser per accedere all'interfaccia web.
Hey/
βββ DB Management/ # Script gestione database
βββ lambda/ # Funzioni AWS Lambda
βββ site/ # Frontend web
βββ scripts/ # Documentazione funzioni
βββ main.tf # Configurazione Terraform
βββ variables.tf # Variabili Terraform
βββ requirements.txt # Dipendenze Python
βββ .env.example # Template variabili ambiente
βββ terraform.tfvars.example # Template variabili Terraform
βββ .gitignore # File da escludere dal Git
- Verifica che
.envsia configurato correttamente - Controlla che l'RDS sia accessibile:
terraform output rds_endpoint - Assicurati che la security group permetta connessioni
- Verifica che le variabili d'ambiente siano configurate in Terraform
- Controlla i log CloudWatch per errori specifici
- Le password di default sono
password123per sviluppo locale - In produzione, usa password complesse e ruota regolarmente
- Monitora i costi AWS, specialmente Textract e Lambda
- Crea un fork del progetto
- Crea un branch per la tua feature (
git checkout -b feature/nuova-feature) - Committa le modifiche (
git commit -am 'Aggiunge nuova feature') - Pusha il branch (
git push origin feature/nuova-feature) - Crea una Pull Request
Questo progetto Γ¨ distribuito sotto licenza MIT. Vedi il file LICENSE per dettagli.