{"id":24582808,"url":"https://github.com/hemmatiali/clientserver-grpc","last_synced_at":"2026-04-18T11:32:16.012Z","repository":{"id":271986865,"uuid":"915173724","full_name":"Hemmatiali/ClientServer-gRPC","owner":"Hemmatiali","description":"This repository demonstrates a client-server architecture using gRPC with .NET 8, EF Core for data persistence, and Razor Pages for the client UI. It showcases how to structure a multi-layered application with clean domain, business, and data layers, along with gRPC services for efficient communication.","archived":false,"fork":false,"pushed_at":"2025-02-01T11:13:01.000Z","size":978,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T11:29:15.467Z","etag":null,"topics":["dotnet8","grpc","grpc-client","grpc-server","grpc-service","software-development"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hemmatiali.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-11T06:43:10.000Z","updated_at":"2025-02-01T11:18:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"fe786a59-e579-4b5b-a18e-f18cdee477b9","html_url":"https://github.com/Hemmatiali/ClientServer-gRPC","commit_stats":null,"previous_names":["hemmatiali/clientserver-grpc"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hemmatiali%2FClientServer-gRPC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hemmatiali%2FClientServer-gRPC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hemmatiali%2FClientServer-gRPC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hemmatiali%2FClientServer-gRPC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hemmatiali","download_url":"https://codeload.github.com/Hemmatiali/ClientServer-gRPC/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244068427,"owners_count":20392819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotnet8","grpc","grpc-client","grpc-server","grpc-service","software-development"],"created_at":"2025-01-24T03:58:34.214Z","updated_at":"2025-10-10T16:02:09.251Z","avatar_url":"https://github.com/Hemmatiali.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ClientServer-gRPC\n\nA sample gRPC project demonstrating both **server** and **client** implementations in a single solution.  \nThis project showcases a typical layered architecture with **EF Core**, **Manual Mapping**, **Projections**, **Minimal APIs**, **Interceptors** for error handling, and usage of **grpcui**.  \n\n## Table of Contents\n1. [Overview](#overview)\n2. [Features](#features)\n3. [Technologies](#technologies)\n4. [Architecture](#architecture)\n5. [Setup \u0026 Installation](#setup--installation)\n6. [Running the Application](#running-the-application)\n7. [Usage \u0026 Testing](#usage--testing)\n8. [Project Structure](#project-structure)\n9. [Contributing](#contributing)\n10. [License](#license)\n\n---\n\n## Overview\nIn **real-world projects**, you often either **provide** a gRPC service or **consume** one—but rarely both at the same time in the same codebase.  \nThis sample project, **ClientServer-gRPC**, demonstrates how to:\n- Implement a **gRPC service** (server) offering CRUD operations on a `Student` entity.\n- Implement a **client** that consumes those gRPC services and provides CRUD functionality via **Razor Pages**.\n\n---\n\n## Features\n- **.NET 8** application for both Server and Client.\n- **Entity Framework Core (EF Core)** for data access on the **server** side.\n- **Manual mapping \u0026 projection** to reduce unnecessary database calls.\n- **Interceptors** for centralizing error handling in gRPC services.\n- **Minimal APIs** approach for simpler service definitions.\n- A **protofile provider** pattern to handle `.proto` files effectively.\n- **grpcui** support to interactively test and explore the gRPC endpoints.\n- Layered architecture for **Business Logic (BLL)**, **Data Access (DAL)**, **Domain** models, and **GRPC** (Web).\n\n---\n\n## Technologies\n- **C# .NET 8**\n- **gRPC** (Google Remote Procedure Call)\n- **Razor Pages** (client UI)\n- **EF Core** for database operations\n- **SQL Server** database\n- **grpcui** for testing\n\n---\n\n## Architecture\nThe solution is split into multiple layers/projects for both the **service** and **client**:\n\n1. **DAL (Data Access Layer)**  \n   - **Server-side**: Communicates with the database using EF Core.  \n   - **Client-side**: Calls the server’s gRPC endpoints (instead of a database).\n\n2. **BLL (Business Logic Layer)**  \n   - Handles core application logic, validations, and orchestration of data.\n\n3. **Domain**  \n   - Contains entities like `Student` and possibly related domain logic or value objects.\n\n4. **GRPC/Web**  \n   - **Server**: Hosts the gRPC services (including `.proto` files, minimal APIs, interceptors).  \n   - **Client**: Contains the gRPC client stubs and Razor Pages for the UI.\n\n---\n\n## Setup \u0026 Installation\n\n1. **Clone the Repository**  \n   - Run the following commands:\n    \n        git clone https://github.com/Hemmatiali/ClientServer-gRPC.git\n        cd ClientServer-gRPC\n\n2. **Install .NET 8 SDK (if not already installed)**  \n   - [Download .NET 8 SDK](https://dotnet.microsoft.com/en-us/download)\n\n3. **Restore NuGet Packages**  \n   - From the project root, run:\n    \n        dotnet restore\n\n4. **Set up Database (Server-Side)**  \n   - Ensure your database connection string is correct in the server’s `appsettings.json` (or equivalent).\n   - Run Entity Framework migrations (if applicable):\n    \n        cd ServiceProject\n        dotnet ef database update\n\n## Running the Application\n\n1. **Start the gRPC Server**  \n   - Navigate to the server project and run:\n    \n        cd ServiceProject\n        dotnet run\n\n   - This will launch the service, hosting gRPC endpoints.\n\n2. **Start the Client**  \n   - In a separate terminal, navigate to the client project and run:\n    \n        cd ClientProject\n        dotnet run\n\n   - This will launch the Razor Pages application that consumes the gRPC services.\n\n## Usage \u0026 Testing\n\n### Razor Pages (Client-Side)\n- Open the client application in your browser (commonly `https://localhost:5001` or similar).\n- Perform CRUD operations for **Student** entities via the UI forms.\n\n### grpcui\n- With the service running, install and run `grpcui` to explore the endpoints:\n    \n        grpcui -plaintext localhost:PORT\n\n  - Replace **PORT** with the gRPC server port (e.g., 5000).\n  - You can call the service methods interactively, view request/response schemas, etc.\n\n### Interceptors\n- Any server-side exceptions or validations will be handled by the configured interceptor, returning structured error responses.\n\n## Project Structure\n\n    ClientServer-gRPC/\n    ├── src/\n    │   ├── Domain/\n    │   │   └── Entities (Student.cs, etc.)\n    │   ├── BLL/\n    │   ├── DAL/\n    │   │   └── EF Core DbContext, Migrations, Repositories, etc.\n    │   ├── GRPC/\n    │   │   ├── Protos (student.proto, etc.)\n    │   │   ├── Services (StudentService.cs, etc.)\n    │   │   ├── Interceptors\n    │   │   └── Program.cs (Minimal APIs, gRPC hosting)\n    │   └── appsettings.json\n    ├── srcClient/\n    │   ├── Domain/ (Shared models if needed)\n    │   ├── BLL/\n    │   ├── DAL/\n    │   │   └── gRPC Clients (generated from .proto)\n    │   ├── GRPC/\n    │   │   ├── Razor Pages (CRUD forms for Student)\n    │   │   └── Program.cs (Client hosting)\n    └── README.md\n\n## Contributing\n1. Fork the repo\n2. Create a new branch for your feature/bugfix\n3. Commit and push\n4. Open a Pull Request\n\n## License\nThis project is licensed under the **MIT License**. Feel free to use and modify as needed for your own projects.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhemmatiali%2Fclientserver-grpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhemmatiali%2Fclientserver-grpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhemmatiali%2Fclientserver-grpc/lists"}