A modern pizza ordering platform built with ASP.NET Core 9.0 and React 19, featuring a clean architecture, JWT authentication, and real-time cart management.
- User Authentication: Secure JWT-based authentication with role-based access control
- Pizza Catalog: Browse pizzas with customizable toppings
- Shopping Cart: Real-time cart management with topping customization
- Order Management: Place and track orders with status updates
- Admin Panel: Manage pizzas, toppings, and orders (Admin role required)
- Responsive Design: Mobile-friendly interface built with React
- Framework: ASP.NET Core 9.0 Web API
- ORM: Entity Framework Core
- Database: SQLite
- Authentication: JWT Bearer Tokens
- Mapping: AutoMapper
- API Documentation: Swagger/OpenAPI
- Framework: React 19 with TypeScript
- Build Tool: Vite
- Routing: React Router v7
- State Management: Zustand
- Data Fetching: TanStack Query (React Query)
- HTTP Client: Axios
- Notifications: React Hot Toast
CSharpPizza/
βββ CSharpPizza.Api/ # Web API Controllers & Middleware
βββ CSharpPizza.Domain/ # Business Logic & Services
βββ CSharpPizza.Data/ # Data Access Layer & Entities
βββ CSharpPizza.DTO/ # Data Transfer Objects
βββ CSharpPizza.WebUI/ # React Frontend Application
- .NET 9.0 SDK
- Node.js 18+ (with npm)
- Visual Studio 2022 or VS Code
git clone <repository-url>
cd csharp-project# Navigate to API project
cd CSharpPizza.Api
# Restore dependencies
dotnet restore
# Run the application (migrations and seeding run automatically)
dotnet runThe API will be available at:
- HTTPS:
https://localhost:7000 - HTTP:
http://localhost:5000 - Swagger UI:
https://localhost:7000/swagger
# Navigate to WebUI project
cd CSharpPizza.WebUI
# Install dependencies
npm install
# Start development server
npm run devThe frontend will be available at: http://localhost:5173
The application uses SQLite with automatic migrations and data seeding:
- Database File:
CSharpPizza.Api/csharp-pizza.db - Migrations: Auto-applied on startup
- Seeding: Sample data (pizzas, toppings, admin user) auto-seeded on first run
Email: admin@csharppizza.com
Password: Admin123!
Email: customer@example.com
Password: Customer123!
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /api/auth/register |
Register new user | No |
| POST | /api/auth/login |
Login user | No |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/pizzas |
Get all pizzas | No |
| GET | /api/pizzas/{id} |
Get pizza by ID | No |
| POST | /api/pizzas |
Create pizza | Admin |
| PUT | /api/pizzas/{id} |
Update pizza | Admin |
| DELETE | /api/pizzas/{id} |
Delete pizza | Admin |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/toppings |
Get all toppings | No |
| POST | /api/toppings |
Create topping | Admin |
| PUT | /api/toppings/{id} |
Update topping | Admin |
| DELETE | /api/toppings/{id} |
Delete topping | Admin |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/cart |
Get user's cart | Yes |
| POST | /api/cart/items |
Add item to cart | Yes |
| PUT | /api/cart/items/{id} |
Update cart item | Yes |
| DELETE | /api/cart/items/{id} |
Remove cart item | Yes |
| DELETE | /api/cart |
Clear cart | Yes |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/orders |
Get user's orders | Yes |
| GET | /api/orders/{id} |
Get order details | Yes |
| POST | /api/orders |
Create order | Yes |
| PUT | /api/orders/{id}/status |
Update order status | Admin |
# Create a new migration
dotnet ef migrations add MigrationName --project CSharpPizza.Data --startup-project CSharpPizza.Api
# Apply migrations
dotnet ef database update --project CSharpPizza.Data --startup-project CSharpPizza.Api
# Remove last migration
dotnet ef migrations remove --project CSharpPizza.Data --startup-project CSharpPizza.Apicd CSharpPizza.Api
dotnet publish -c Release -o ./publishcd CSharpPizza.WebUI
npm run build- Navigate to
https://localhost:7000/swagger - Click "Authorize" and enter JWT token (get from login endpoint)
- Test endpoints directly from the UI
Open CSharpPizza.Api/CSharpPizza.Api.http and use the REST Client extension to test endpoints.
- JWT Authentication: Secure token-based authentication
- Password Hashing: BCrypt password hashing
- Role-Based Authorization: Admin and Customer roles
- CORS Protection: Restricted to frontend origin
- HTTPS: Enforced in production
- SQL Injection Prevention: EF Core parameterized queries
- Soft Deletes: Data preservation with IsDeleted flag
CSharpPizza.Api/Program.cs- Application configuration and DI setupCSharpPizza.Data/PizzaDbContext.cs- Database contextCSharpPizza.Domain/Services/- Business logic servicesCSharpPizza.Api/Controllers/- API endpoints
CSharpPizza.WebUI/src/App.tsx- Main app component and routingCSharpPizza.WebUI/src/stores/- Zustand state storesCSharpPizza.WebUI/src/api/- API client functionsCSharpPizza.WebUI/src/pages/- Page components
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Use async/await for all I/O operations
- Follow repository pattern for data access
- Use DTOs for all API responses
- Implement proper error handling
- Use soft deletes (IsDeleted flag)
- All entities inherit from BaseEntity
- Use TypeScript strict mode
- Use functional components with hooks
- Use TanStack Query for server state
- Use Zustand for client state
- Follow React best practices
# Delete database and recreate
rm CSharpPizza.Api/csharp-pizza.db
dotnet run --project CSharpPizza.Api- Backend: Change ports in
CSharpPizza.Api/Properties/launchSettings.json - Frontend: Change port in
CSharpPizza.WebUI/vite.config.ts
- Ensure frontend URL matches CORS configuration in
Program.cs - Default:
http://localhost:5173
This project is licensed under the MIT License.
- Your Name - Initial work
- ASP.NET Core team for the excellent framework
- React team for the amazing frontend library
- All open-source contributors
Happy Coding! π