Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
242 changes: 169 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
# DevEats - Restaurant Review Platform
# DevEats - Piattaforma di Recensioni Ristoranti

DevEats è una piattaforma moderna per recensire ristoranti, sviluppata con .NET 8, Blazor Server, Entity Framework Core e Azure SQL Database.
DevEats è una piattaforma moderna per recensire ristoranti, sviluppata con .NET 8, Blazor Server, Entity Framework Core e SQL Server. Il progetto è destinato al deployment su Azure (Azure SQL Database + Azure App Service).

## Caratteristiche

- **Blazor Server**: Interfaccia utente reattiva e moderna
- **Entity Framework Core**: ORM per gestione database
- **Azure SQL Database**: Database cloud scalabile
- **Entity Framework Core**: ORM per la gestione del database con migrazioni automatiche
- **SQL Server / Azure SQL Database**: Database relazionale scalabile
- **Bootstrap 5**: Design responsive e accattivante
- **CI/CD**: GitHub Actions per deployment automatico su Azure
- **Test Unitari**: Copertura con NUnit
- **Test Unitari**: Copertura completa con NUnit
- **Seeding Automatico**: Popolamento dati di esempio all'avvio

## Struttura del Progetto

Il progetto segue un'architettura a 3 livelli:

```
DevEats/
├── src/
│ ├── DevEats.Core/ # Modelli di dominio e interfacce
│ ├── DevEats.Infrastructure/ # EF Core, DbContext, servizi
│ └── DevEats.Web/ # Blazor Server UI
└── tests/
└── DevEats.Tests/ # Test unitari con NUnit
│ │ ├── Models/ # Restaurant, Review
│ │ └── Interfaces/ # IRestaurantService, IReviewService
│ ├── DevEats.Infrastructure/ # Implementazione EF Core
│ │ ├── Data/ # DevEatsDbContext, DataSeeder
│ │ ├── Services/ # RestaurantService, ReviewService
│ │ └── Migrations/ # Migrazioni database EF Core
│ └── DevEats.Web/ # Applicazione Blazor Server
│ └── Pages/ # Index.razor, RestaurantDetails.razor
├── tests/
│ └── DevEats.Tests/ # Test unitari NUnit
└── scripts/
├── start-dev.sh/.ps1 # Script di avvio sviluppo
└── stop-dev.sh/.ps1 # Script di arresto
```

## Prerequisiti
Expand All @@ -41,7 +53,7 @@ git clone https://github.com/your-username/deveats.git
cd deveats

# 2. Avviare tutto (Docker + Applicazione)
./start-dev.sh
./scripts/start-dev.sh
```

#### Su Windows (PowerShell):
Expand All @@ -52,17 +64,30 @@ git clone https://github.com/your-username/deveats.git
cd deveats

# 2. Avviare tutto (Docker + Applicazione)
.\start-dev.ps1
.\scripts\start-dev.ps1
```

Lo script automaticamente:
- ✅ Avvia SQL Server 2022 in Docker
- ✅ Aspetta che il database sia pronto
- ✅ Attende che il database sia pronto
- ✅ Avvia l'applicazione Blazor
- ✅ Crea automaticamente il database e popola i dati di esempio
- ✅ Applica automaticamente le migrazioni EF Core
- ✅ Popola i dati di esempio tramite DataSeeder

**L'applicazione sarà disponibile su: `https://localhost:5001`**

#### Fermare l'ambiente di sviluppo

**macOS/Linux:**
```bash
./scripts/stop-dev.sh
```

**Windows:**
```powershell
.\scripts\stop-dev.ps1
```

### Metodo Manuale

Se preferisci maggiore controllo, puoi eseguire i passaggi manualmente:
Expand All @@ -83,41 +108,34 @@ docker ps
dotnet restore
```

#### 3. Avviare l'applicazione
#### 3. Build della soluzione

```bash
cd src/DevEats.Web
dotnet run
dotnet build
```

L'applicazione sarà disponibile su `https://localhost:5001`
#### 4. Avviare l'applicazione

#### 4. Fermare l'ambiente di sviluppo

**macOS/Linux:**
```bash
./stop-dev.sh
cd src/DevEats.Web
dotnet run
```

**Windows:**
```powershell
.\stop-dev.ps1
```
L'applicazione sarà disponibile su `https://localhost:5001`

**Oppure manualmente:**
```bash
docker-compose down
```
Le migrazioni e il seeding dei dati avvengono automaticamente all'avvio dell'applicazione.

### Informazioni Database Docker

- **Server**: `localhost,1433`
- **Database**: `DevEatsDB` (creato automaticamente)
- **Database**: `deveats_dev` (creato automaticamente)
- **Username**: `sa`
- **Password**: `DevEats2024!`
- **Connection String**: Già configurata in `appsettings.Development.json`
- **Connection String**: Configurata in `appsettings.Development.json`

### Comandi Utili

### Comandi Utili Docker
#### Docker

```bash
# Visualizzare i log di SQL Server
Expand All @@ -129,18 +147,88 @@ docker-compose down -v
# Riavviare SQL Server
docker-compose restart

# Accedere al container SQL Server
docker exec -it deveats-sqlserver /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "DevEats2024!"
# Fermare i container
docker-compose down
```

### Eseguire i Test
#### Build e Test

```bash
# Test unitari (non richiedono Docker)
# Build dell'intera soluzione
dotnet build

# Build di un progetto specifico
dotnet build src/DevEats.Core/DevEats.Core.csproj
dotnet build src/DevEats.Infrastructure/DevEats.Infrastructure.csproj
dotnet build src/DevEats.Web/DevEats.Web.csproj

# Eseguire tutti i test
dotnet test

# Eseguire test di un progetto specifico
dotnet test tests/DevEats.Tests/DevEats.Tests.csproj

# Eseguire un test specifico
dotnet test --filter "FullyQualifiedName~DataSeederTests"
```

#### Operazioni Database

```bash
# Aggiungere una nuova migrazione
cd src/DevEats.Infrastructure
dotnet ef migrations add NomeMigrazione --startup-project ../DevEats.Web

# Aggiornare il database manualmente (normalmente avviene automaticamente all'avvio)
dotnet ef database update --startup-project ../DevEats.Web

# Rimuovere l'ultima migrazione
dotnet ef migrations remove --startup-project ../DevEats.Web

# Reset completo del database
docker-compose down -v
docker-compose up -d
```

## Setup Azure
## Architettura

### DevEats.Core
Layer di dominio con modelli (Restaurant, Review) e interfacce dei servizi (IRestaurantService, IReviewService).

### DevEats.Infrastructure
Implementazione dell'infrastruttura con:
- **DevEatsDbContext**: Context di Entity Framework Core
- **Services**: Implementazioni concrete dei servizi
- **DataSeeder**: Popola il database con dati di esempio all'avvio
- **Migrations**: Migrazioni EF Core per versioning del database

### DevEats.Web
Applicazione Blazor Server con componenti Razor, configurazione Dependency Injection, middleware, auto-migrazione e seeding.

### DevEats.Tests
Test unitari con NUnit per la logica di seeding, operazioni sulle recensioni e operazioni sui ristoranti. I test utilizzano provider database in-memory per l'isolamento.

## Funzionalità

- **Home Page**: Lista di tutti i ristoranti con rating medio
- **Dettagli Ristorante**: Informazioni dettagliate e visualizzazione recensioni
- **Aggiungi Recensione**: Form per inviare nuove recensioni con rating
- **Rating Automatico**: Calcolo automatico della media dei voti
- **Gestione Relazioni**: Le recensioni sono collegate ai ristoranti con cascade delete

## Setup Azure e CI/CD

### Pipeline GitHub Actions

Il progetto include due workflow GitHub Actions:

- **deploy-test.yml**: Deploy automatico all'ambiente di test
- **deploy-prod.yml**: Deploy automatico all'ambiente di produzione

I workflow eseguono:
1. Build con .NET 8
2. Esecuzione dei test
3. Publish su Azure Web App (richiede `AZURE_WEBAPP_PUBLISH_PROFILE` secret)

### 1. Creare Azure SQL Database

Expand Down Expand Up @@ -196,13 +284,7 @@ az webapp create \
### 3. Configurare Connection String nell'App Service

```bash
# Ottieni la connection string del database
az sql db show-connection-string \
--client ado.net \
--name DevEatsDB \
--server deveats-sql-server

# Configura la connection string nell'App Service (sostituisci i placeholder)
# Configurare la connection string nell'App Service
az webapp config connection-string set \
--resource-group DevEatsRG \
--name DevEats-WebApp \
Expand All @@ -225,56 +307,63 @@ az webapp config connection-string set \
- Crea un nuovo secret chiamato `AZURE_WEBAPP_PUBLISH_PROFILE`
- Incolla il contenuto XML del publish profile

3. **Push su main branch**:
3. **Push sul branch main**:
```bash
git add .
git commit -m "Initial commit"
git commit -m "Deploy to Azure"
git push origin main
```

GitHub Actions eseguirà automaticamente build, test e deploy su Azure!
GitHub Actions eseguirà automaticamente build, test e deploy su Azure!

## Architettura

### DevEats.Core
Contiene i modelli di dominio:
- `Restaurant`: Informazioni sul ristorante
- `Review`: Recensioni degli utenti

### DevEats.Infrastructure
- `DevEatsDbContext`: Context di Entity Framework Core
- `ReviewService`: Logica di business per le recensioni
- `DataSeeder`: Popola il database con dati di esempio
## Dettagli Architetturali

### DevEats.Web
- Pagine Blazor per UI
- Dependency Injection configurata in `Program.cs`
- Bootstrap 5 per lo styling
### Inizializzazione Database all'Avvio
L'applicazione applica automaticamente le migrazioni EF Core e popola i dati di esempio all'avvio. Il DataSeeder verifica se i dati esistono già prima di inserirli.

## Funzionalità
### Pattern Service Layer
I servizi sono iniettati tramite Dependency Injection e implementano le interfacce definite in DevEats.Core. Le recensioni sono collegate ai ristoranti tramite foreign key con cascade delete.

- **Home Page**: Lista di tutti i ristoranti con rating medio
- **Dettagli Ristorante**: Informazioni dettagliate e recensioni
- **Aggiungi Recensione**: Form per inviare nuove recensioni
- **Rating Automatico**: Calcolo automatico della media dei voti
### Gestione Connection String
- **Development**: Usa Docker SQL Server su `localhost,1433` con database `deveats_dev`
- **Production**: Configurato per Azure SQL Database tramite secret `AZURE_WEBAPP_PUBLISH_PROFILE`

## Tecnologie Utilizzate

- **.NET 8**: Framework applicativo
- **Blazor Server**: UI framework
- **Entity Framework Core**: ORM
- **SQL Server / Azure SQL**: Database
- **Bootstrap 5**: CSS framework
- **Blazor Server**: UI framework con SignalR
- **Entity Framework Core**: ORM con Code-First approach
- **SQL Server 2022 / Azure SQL**: Database relazionale
- **Bootstrap 5**: Framework CSS
- **NUnit**: Framework di testing
- **GitHub Actions**: CI/CD pipeline
- **Docker**: Containerizzazione per ambiente di sviluppo

## Workflow di Sviluppo

**IMPORTANTE**: Dopo aver apportato modifiche al codice, è necessario:
1. Eseguire il build dei progetti modificati per verificare la compilazione
2. Eseguire la suite di test per assicurarsi che nulla si sia rotto

```bash
# Build della soluzione
dotnet build

# Eseguire i test
dotnet test
```

Non saltare questi passaggi - rilevano problemi in anticipo e garantiscono la qualità del codice.

## Estensioni Future

- Autenticazione utenti con Azure AD B2C
- Upload immagini ristoranti
- Upload immagini ristoranti con Azure Blob Storage
- Ricerca e filtri avanzati
- Integrazione con Azure OpenAI per analisi sentiment recensioni
- Notifiche in tempo reale con SignalR
- Sistema di moderazione recensioni
- API REST per applicazioni mobile

## Contribuire

Expand All @@ -286,4 +375,11 @@ Le pull request sono benvenute! Per modifiche importanti, apri prima una issue p

## Contatti

Per domande o supporto, apri una issue su GitHub.
Per domande o supporto, apri una issue su GitHub.

## Link Utili

- **GitHub spec-kit**: https://github.com/github/spec-kit
- **GitHub Copilot custom agents**: https://docs.github.com/en/copilot/tutorials/customization-library/custom-agents/your-first-custom-agent
- **GitHub Copilot custom prompts**: https://docs.github.com/en/copilot/tutorials/customization-library/prompt-files/your-first-prompt-file
- **Claude Code**: https://code.claude.com/docs/en/overview
2 changes: 0 additions & 2 deletions note.md

This file was deleted.