{"id":24135069,"url":"https://github.com/adarsonmez/cleanarchitecturetemplate","last_synced_at":"2026-05-06T04:31:19.862Z","repository":{"id":262516781,"uuid":"887482994","full_name":"adarSonmez/CleanArchitectureTemplate","owner":"adarSonmez","description":"CleanArchitectureTemplate is a .NET 9 Clean Architecture starter that integrates Docker, Redis, and Semantic Kernel for AI, along with EF Core/PostgreSQL, CQRS/MediatR, JWT auth, and robust logging.","archived":false,"fork":false,"pushed_at":"2025-07-26T21:46:08.000Z","size":1032,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-27T01:23:11.464Z","etag":null,"topics":["asp-net-core","clean-architecture","docker","docker-compose","domain-driven-design","dotnet","e-commerce","postgres","postgresql","redis","semantic-kernel","solid","template"],"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/adarSonmez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2024-11-12T20:27:56.000Z","updated_at":"2025-07-26T21:46:13.000Z","dependencies_parsed_at":"2024-11-30T19:26:35.642Z","dependency_job_id":"e064d8f3-2c27-4daa-b163-849114ed3ac6","html_url":"https://github.com/adarSonmez/CleanArchitectureTemplate","commit_stats":null,"previous_names":["adarsonmez/commerceportal.be","adarsonmez/cleanarchitecturetemplate"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/adarSonmez/CleanArchitectureTemplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adarSonmez%2FCleanArchitectureTemplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adarSonmez%2FCleanArchitectureTemplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adarSonmez%2FCleanArchitectureTemplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adarSonmez%2FCleanArchitectureTemplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adarSonmez","download_url":"https://codeload.github.com/adarSonmez/CleanArchitectureTemplate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adarSonmez%2FCleanArchitectureTemplate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32678574,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-06T02:33:58.958Z","status":"ssl_error","status_checked_at":"2026-05-06T02:33:39.611Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["asp-net-core","clean-architecture","docker","docker-compose","domain-driven-design","dotnet","e-commerce","postgres","postgresql","redis","semantic-kernel","solid","template"],"created_at":"2025-01-12T01:19:56.710Z","updated_at":"2026-05-06T04:31:19.845Z","avatar_url":"https://github.com/adarSonmez.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀 CleanArchitectureTemplate\n\nCleanArchitectureTemplate is a **modern, robust starting point** for building scalable and maintainable .NET applications. Now upgraded to **.NET 9 and C# 12**, it follows the principles of **Clean Architecture** to promote separation of concerns, testability, and ease of evolution over time.\n\n---\n\n## ✨ Key Features\n\n- 🏗️ **Clean Architecture Implementation**: Organized into distinct layers—Presentation, Application, Domain, Infrastructure—for clear separation of concerns.\n- ⚡ **Upgraded to .NET 9 and C# 12**: Leverages the latest framework improvements and performance enhancements.\n- 🐳 **Docker Support**: Easily containerize and orchestrate your application using Docker Compose.\n- 🔴 **Redis Integration with Sentinel**: Implements robust caching and distributed data management with Redis, including master-slave replication and sentinel support.\n- 🤖 **Semantic Kernel for AI Actions**: Integrated Semantic Kernel capabilities to empower AI-driven features within your application.\n- 🛢️ **Entity Framework Core with PostgreSQL**: Simplifies database operations using EF Core with PostgreSQL provider.\n- 🔄 **CQRS with MediatR**: Implements the Command Query Responsibility Segregation pattern using MediatR.\n- ✅ **Fluent Validation**: Ensures robust validation for input models with automatic integration.\n- 🛠️ **Custom Mapping Extensions**: Clean, handcrafted mappings for full control—no AutoMapper or third-party mapping libraries used.\n- ☁️ **Azure Blob Storage Integration**: Supports file storage with Azure Storage Blobs and local storage options.\n- 🔑 **JWT Authentication**: Provides secure authentication using JWT bearer tokens.\n- 🔐 **ASP.NET Core Identity Mechanism**: Offers a comprehensive identity management system for user authentication and role-based authorization.\n- 🌍 **Login with Facebook or Google**: Provides seamless integration with external login providers to enhance user experience.\n- 📌 **Logging with Serilog**: Structured logging for easier debugging and tracking.\n- 🔍 **Visualization with Seq**: Centralized logging visualization for enhanced observability.\n- 📜 **Swagger UI**: Includes interactive API documentation with Swashbuckle.AspNetCore.\n- ⚙️ **Global Exception Handler**: Ensures centralized and consistent error handling across the application.\n- 📧 **Email Integration**: Built-in email service using MailKit for transactional emails.\n- 🚀 **Response Caching**: Integrated response caching for improved performance.\n\n---\n\n## 🛠️ Getting Started\n\n### Prerequisites\n\nBefore setting up the project, ensure you have the following installed:\n\n- ⚙️ [.NET 9 SDK](https://dotnet.microsoft.com/download)\n- 🖥️ [Visual Studio 2022](https://visualstudio.microsoft.com/) or [VS Code](https://code.visualstudio.com/)\n- 🐘 [PostgreSQL](https://www.postgresql.org/download/)\n- 🐳 [Docker \u0026 Docker Compose](https://docs.docker.com/get-docker/) (for containerized deployment)\n- 🔴 [Redis](https://redis.io/) (integrated via Docker containers with Sentinel support)\n- ☁️ Azure account (optional, for Blob Storage integration)\n- 🔎 [Seq](https://datalust.co/seq) (optional, for log visualization)\n\n---\n\n### 📥 Installation\n\nFollow these steps to get the solution up and running:\n\n1. **Clone the Repository** git clone https://github.com/adarSonmez/CleanArchitectureTemplate.git2. \n2. **Navigate to the Solution Directory**  cd CleanArchitectureTemplate3. \n3. **Restore NuGet Packages**  dotnet restore4. \n4. **Configure the Database Connection**  Update the `ConnectionStrings:DefaultConnection` in `appsettings.json` (located in `Presentation/CleanArchitectureTemplate.WebAPI`) with your PostgreSQL details.\n5. **Apply Migrations**  dotnet ef database update --project Infrastructure/CleanArchitectureTemplate.Persistence6. \n6. **Set Up Serilog and Seq**  \n   - Ensure `appsettings.json` includes the Seq configuration under `Logging`:\n     ```json\n     \"Logging\": {\n         \"LogLevel\": {\n             \"Default\": \"Information\",\n             \"Microsoft.AspNetCore\": \"Warning\"\n         },\n         \"Seq\": {\n             \"ServerUrl\": \"http://localhost:5341\"\n         }\n     }\n     ```\n   - Start Seq locally or on a server and ensure the application is pointed to the correct URL.\n\n7. **Configure Cloud Storage (Optional)**  \n   Update the `Storage` section in `appsettings.json` with your provider details. Example:\"Storage\": {\n    \"Azure\": \"\u003cYourAzureBlobConnectionString\u003e\",\n    \"AWS\": \"\u003cYourAWSStorageKey\u003e\",\n    \"Google\": \"\u003cYourGoogleCloudStorageKey\u003e\"\n}\n8. **Set Up External Login Providers (Optional)**  \n   Update the `OAuth:Google` and `OAuth:Facebook` sections in `appsettings.json` with the appropriate client ID and secret.\n\n9. **Configure JWT Authentication**  \n   Ensure the `Jwt` section in `appsettings.json` contains the necessary values for your application's secret key, issuer, audience, and token expiration times. Example:\"Jwt\": {\n    \"SecretKey\": \"千里之行，始于足下。- Lao Tzu\",\n    \"Issuer\": \"\u003cYourIssuer\u003e\",\n    \"Audience\": \"\u003cYourAudience\u003e\",\n    \"AccessTokenExpiration\": 360,\n    \"RefreshTokenExpiration\": 60\n   }\n\n10. **Configure Redis Settings**  \n    The application is integrated with Redis (with Sentinel support) for caching and distributed data management. Update the `ConnectionStrings:Redis` in `appsettings.json`:\n    ```json\n    \"ConnectionStrings\": {\n        \"DefaultConnection\": \"\u003cYourPostgreSQLConnectionString\u003e\",\n        \"Redis\": \"\u003cYourRedisConnectionString\u003e\"\n    }\n    ```\n\n11. **Configure AI Actions with Semantic Kernel**  \n    The AI module leverages Semantic Kernel with connectors like Ollama and OpenAI. Update the `AI` section in `appsettings.json` with your desired settings:\n    ```json\n    \"AI\": {\n      \"Ollama\": {\n        \"Model\": \"deepseek-r1:latest\",\n        \"ServerUrl\": \"http://localhost:11434\"\n      },\n      \"OpenAI\": {\n        \"Model\": \"google/gemini-2.0-pro-exp-02-05:free\",\n        \"ApiKey\": \"\",\n        \"ServerUrl\": \"https://openrouter.ai/api/v1\"\n      }\n    }\n    ```\n\n12. **Configure Email Settings (Optional)**  \n    If you plan to use email functionality, configure the email settings in `appsettings.json`:\n    ```json\n    \"Email\": {\n        \"SmtpServer\": \"\u003cYourSmtpServer\u003e\",\n        \"Port\": 587,\n        \"Username\": \"\u003cYourEmailUsername\u003e\",\n        \"Password\": \"\u003cYourEmailPassword\u003e\",\n        \"EnableSsl\": true\n    }\n    ```\n\n---\n\n### 🐳 Docker Deployment\n\nFor a containerized setup, use the provided `docker-compose.yml`. This file defines services for:\n\n- **Web API**: Runs the ASP.NET Core application.\n- **PostgreSQL**: Database service.\n- **Redis (Master, Slaves, and Sentinels)**: Ensures high availability caching.\n- **Ollama**: AI service container for Semantic Kernel integration.\n- **Seq**: Log visualization service.\n\nTo launch the containers:\n\n1. **Ensure Docker is running** on your machine.\n2. **Build and start the containers** using Docker Compose: docker-compose up --build\n3. The API will be available at:  \n   - HTTP: `http://localhost:8080`\n   - HTTPS: `http://localhost:8081`\n4. Seq can be accessed at `http://localhost:5341` (or as configured in your environment).\n\n---\n\n### 🚀 Usage\n\n1. **Run the Application (Non-Docker)**  dotnet run --project Presentation/CleanArchitectureTemplate.WebAPI\n\n2. **Access Swagger UI**  \n   Open your browser and navigate to:  \n   🌐 `http://localhost:5000/swagger` (or the port defined in your environment) for interactive API documentation.\n\n3. **Monitor Logs**  \n   View application logs in Seq by navigating to:  \n   🌐 `http://localhost:5341` (or your configured Seq server URL).\n\n4. **Available Authentication Endpoints**  \n   The template provides several authentication methods:\n   - `/api/Auth/Login` - Internal login with username/password\n   - `/api/Auth/GoogleLogin` - Google OAuth login\n   - `/api/Auth/FacebookLogin` - Facebook OAuth login (note: typo in current implementation as \"FacobookLogin\")\n   - `/api/Auth/RefreshToken` - Refresh JWT tokens\n   - `/api/Auth/RevokeRefreshToken` - Revoke refresh tokens\n   - `/api/Auth/Logout` - User logout\n\n---\n\n## 🏗️ Project Structure\n\nThe solution is organized into the following layers:\n\n### Core Layer\n- **📦 Domain Layer**  \n  - `CleanArchitectureTemplate.Domain`: Defines domain entities, value objects, and interfaces.\n  \n- **🧠 Application Layer**  \n  - `CleanArchitectureTemplate.Application`: Contains business logic, DTOs, commands, queries, validators, and interfaces for all services.\n\n### Infrastructure Layer\n- **🔌 Infrastructure Layer**  \n  - `CleanArchitectureTemplate.Infrastructure`: Implements external services like file storage, email sending, JWT authentication, and Redis integration.\n  \n- **💾 Persistence Layer**  \n  - `CleanArchitectureTemplate.Persistence`: Manages data access with Entity Framework Core, including database contexts and repositories.\n  \n- **🤖 AI Layer**  \n  - `CleanArchitectureTemplate.AI`: Provides AI actions leveraging Semantic Kernel for tasks such as language detection, translation, and summarization.\n  \n- **📡 Realtime Communication Layer**  \n  - `CleanArchitectureTemplate.RealtimeCommunication`: Supports real-time communication features using SignalR.\n\n- **📨 Messaging Layer**  \n  - `CleanArchitectureTemplate.Messaging`: Handles message processing and communication patterns.\n\n### Presentation Layer\n- **🎨 Presentation Layer**  \n  - `CleanArchitectureTemplate.WebAPI`: The ASP.NET Core Web API project serving as the entry point with controllers, middleware, and configuration.\n\n---\n\n## 🔧 Key Technical Features\n\n### Repository Pattern\nThe template implements a comprehensive repository pattern with:\n- **Read Repository**: Optimized for query operations with filtering, pagination, and includes\n- **Write Repository**: Handles CRUD operations with both hard and soft delete capabilities\n- **Generic Implementation**: Type-safe operations for all entities inheriting from `BaseEntity`\n\n### Validation System\n- **Fluent Validation**: Automatic validation with custom filters\n- **Model State Suppression**: Clean API responses without default model state errors\n- **Validation Filter**: Custom validation filter for consistent error handling\n\n### Caching Strategy\n- **Response Caching**: Built-in HTTP response caching\n- **Redis Caching**: Distributed caching with StackExchange.Redis\n- **Configurable Cache Settings**: Flexible caching configuration per endpoint\n\n### Security Features\n- **JWT Bearer Authentication**: Secure token-based authentication\n- **External OAuth Providers**: Google and Facebook login integration\n- **Authorization Policies**: Role-based and policy-based authorization\n- **Content Security Policy**: Built-in CSP middleware\n\n---\n\n## 🤝 Contributing\n\nContributions are welcome! To contribute:\n\n1. Fork the repository.\n2. Create a new branch for your feature:  git checkout -b feature/YourFeature\n3. Commit your changes:  git commit -m \"Add YourFeature\"\n4. Push to the branch:  git push origin feature/YourFeature\n5. Open a pull request.\n\n✅ **Pro Tip**: Ensure your code follows the project's coding standards and includes appropriate tests.\n\n---\n\n## 📝 Development Notes\n\n### Known Issues\n- There's a typo in the AuthController: `FacobookLogin` should be `FacebookLogin`\n- The SignalR package version in `CleanArchitectureTemplate.RealtimeCommunication` uses an older version (1.2.0) - consider updating to the latest version\n\n### Recommended Improvements\n- Add comprehensive unit tests for repository implementations\n- Implement health checks for external dependencies\n- Add API versioning support\n- Consider implementing the Outbox pattern for reliable messaging\n\n---\n\n## 📜 License\n\nThis project is licensed under the [MIT License](https://github.com/adarSonmez/CleanArchitectureTemplate/blob/master/LICENSE).\n\n---\n\n## 🙌 Acknowledgements\n\nThis template is inspired by the principles outlined in 📘 [*Clean Architecture: A Craftsman's Guide to Software Structure and Design* by Robert C. Martin](https://www.amazon.com/Clean-Architecture-Craftsmans-Software-Structure/dp/0134494164).\n\n---\n\n### 🔗 Links\n\n- 🌟 [GitHub Repository](https://github.com/adarSonmez/CleanArchitectureTemplate)  \n- 🛠️ [Official .NET Documentation](https://docs.microsoft.com/dotnet/)  \n- 🐳 [Docker Documentation](https://docs.docker.com/)  \n- 🔴 [Redis Documentation](https://redis.io/)  \n- 🤖 [Semantic Kernel Documentation](https://github.com/microsoft/semantic-kernel)\n- 📧 [MailKit Documentation](https://github.com/jstedfast/MailKit)\n- ✅ [FluentValidation Documentation](https://docs.fluentvalidation.net/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadarsonmez%2Fcleanarchitecturetemplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadarsonmez%2Fcleanarchitecturetemplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadarsonmez%2Fcleanarchitecturetemplate/lists"}