{"id":26591585,"url":"https://github.com/felipegf/ambev.omnia.eval","last_synced_at":"2026-04-09T07:35:08.876Z","repository":{"id":280528329,"uuid":"942298892","full_name":"felipegf/Ambev.Omnia.Eval","owner":"felipegf","description":"Technical assessment for a .NET position in the Omnia project (Ambev), using .NET 8 and best practices. Implements CQRS, Event Sourcing, and Clean Architecture with PostgreSQL, MongoDB, MediatR, and Serilog. Follows Dependency Injection, Unit Testing, and API versioning for scalability.","archived":false,"fork":false,"pushed_at":"2025-03-11T22:07:10.000Z","size":141,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T14:18:31.080Z","etag":null,"topics":["api-versioning","clean-architecture","cqrs-pattern","dependency-injection","dotnet","dotnet-core","event-sourcing","mediatr","mongodb","postgresql","serilog","unit-testing"],"latest_commit_sha":null,"homepage":"https://github.com/felipegf/Ambev.Omnia.Eval","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/felipegf.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}},"created_at":"2025-03-03T22:20:39.000Z","updated_at":"2025-03-11T22:12:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"38aebb40-cb6f-4180-aed8-e92d747627fe","html_url":"https://github.com/felipegf/Ambev.Omnia.Eval","commit_stats":null,"previous_names":["felipegf/ambev.omnia.eval"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipegf%2FAmbev.Omnia.Eval","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipegf%2FAmbev.Omnia.Eval/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipegf%2FAmbev.Omnia.Eval/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipegf%2FAmbev.Omnia.Eval/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/felipegf","download_url":"https://codeload.github.com/felipegf/Ambev.Omnia.Eval/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245111880,"owners_count":20562511,"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":["api-versioning","clean-architecture","cqrs-pattern","dependency-injection","dotnet","dotnet-core","event-sourcing","mediatr","mongodb","postgresql","serilog","unit-testing"],"created_at":"2025-03-23T14:18:39.501Z","updated_at":"2025-12-30T23:31:46.824Z","avatar_url":"https://github.com/felipegf.png","language":"C#","readme":"# Ambev Developer Evaluation - Sales API 🚀\n\n![Build Status](https://img.shields.io/badge/build-passing-brightgreen)\n![Test Coverage](https://img.shields.io/badge/coverage-85%25-green)\n![Version](https://img.shields.io/badge/version-1.1.0-blue)\n![License](https://img.shields.io/badge/license-MIT-yellow)\n\nThis project is a **Sales Management API**, developed as part of the Ambev Developer Evaluation process. It provides a **robust CRUD (Create, Read, Update, Delete)** for managing sales while integrating best practices such as **CQRS, dependency injection, validation, unit testing, and event sourcing**.\n\n## 📋 Table of Contents\n\n- [✨ Features](#-features)\n- [🚀 Quick Start](#-quick-start)\n- [🔧 Technologies Used](#-technologies-used)\n- [📝 Prerequisites](#-prerequisites)\n- [⚙️ Installation](#️-installation)\n- [🔐 Environment Variables](#-environment-variables)\n- [🏃‍♂️ Running the Application](#️-running-the-application)\n- [🔒 Authentication](#-authentication)\n- [🔌 API Endpoints](#-api-endpoints)\n- [📊 Architecture](#-architecture)\n- [📜 Event Sourcing \u0026 Logging](#-event-sourcing--logging)\n- [🧪 Running Tests](#-running-tests)\n- [❓ Troubleshooting](#-troubleshooting)\n- [🛣️ Roadmap](#️-roadmap)\n- [🤝 Contributing](#-contributing)\n- [📜 License](#-license)\n- [👤 Author](#-author)\n\n## ✨ Features\n\n- ✅ **CRUD operations** for sales (create, read, update, delete)\n- ✅ **CQRS pattern** with MediatR for better separation of concerns\n- ✅ **Event Sourcing** with MongoDB for auditability and tracking\n- ✅ **MongoDB-based Log Storage** for scalable logging\n- ✅ **FluentValidation** for input validation\n- ✅ **AutoMapper** for DTO-to-domain mapping\n- ✅ **JWT Authentication** for secure API access\n- ✅ **Entity Framework Core** (EF Core) with PostgreSQL\n- ✅ **API versioning** for backward compatibility\n- ✅ **Comprehensive exception handling**\n- ✅ **Performance monitoring**\n- ✅ **Unit testing** with xUnit, Moq, and FluentAssertions\n- ✅ **Docker support** for seamless deployment\n\n## 🚀 Quick Start\n\n```bash\n# Clone the repository\ngit clone https://github.com/felipegf/Ambev.Omnia.Eval.git\n\n# Navigate to the project directory\ncd Ambev.Omnia.Eval\n\n# Start with Docker (recommended)\ndocker-compose up -d\n\n# The API is now running at https://localhost:8080\n# Swagger UI available at https://localhost:8080/swagger\n```\n\n## 🔧 Technologies Used\n\n* **.NET 8**: ASP.NET Core Web API with modern features\n* **Entity Framework Core**: ORM for PostgreSQL database operations\n* **MongoDB**: Used for event storage and log storage\n* **Serilog**: Integrated with MongoDB as a logging sink\n* **FluentValidation**: Advanced input validation\n* **MediatR**: Implements the CQRS pattern\n* **AutoMapper**: Simplifies object-to-object mapping\n* **xUnit \u0026 Moq**: Unit testing framework\n* **JWT Authentication**: Secure access to protected endpoints\n* **Docker**: Containerized environment for seamless deployment\n* **Swagger/OpenAPI**: API documentation\n\n## 📝 Prerequisites\n\nEnsure you have the following installed:\n* .NET 8 SDK\n* PostgreSQL (or use Docker)\n* MongoDB (or use Docker)\n* Docker (optional)\n* Git\n\n## ⚙️ Installation\n\n### Option 1: Using Docker (Recommended)\n\n```bash\n# Clone the repository\ngit clone https://github.com/felipegf/Ambev.Omnia.Eval.git\ncd Ambev.Omnia.Eval\n\n# Start the application and database\ndocker-compose up -d\n```\n\n### Option 2: Manual Setup\n\n```bash\n# Clone the repository\ngit clone https://github.com/felipegf/Ambev.Omnia.Eval.git\ncd Ambev.Omnia.Eval\n\n# Configure the database connection in appsettings.json\n\n# Apply database migrations\ndotnet ef database update\n\n# Run the application\ndotnet run --project src/Ambev.DeveloperEvaluation.WebApi\n```\n\n## 🔐 Environment Variables\n\n| Variable | Description | Default | Required |\n|----------|-------------|---------|----------|\n| `Jwt:SecretKey` | Secret key for JWT token encryption | - | Yes |\n| `MongoDB:ConnectionString` | Connection string for MongoDB | - | Yes |\n| `MongoDB:DatabaseName` | Name of MongoDB database | events_db | No |\n| `Jwt:Issuer` | Token issuer | api.ambev.com | No |\n| `Jwt:Audience` | Token audience | ambev.users | No |\n| `Jwt:ExpiryMinutes` | Token expiry in minutes | 60 | No |\n| `ConnectionStrings:DefaultConnection` | PostgreSQL connection string | - | Yes |\n\n## 🏃‍♂️ Running the Application\n\nAfter installation, the API will be available at:\n- API Endpoint: `https://localhost:8080`\n- Swagger Documentation: `https://localhost:8080/swagger`\n\n## 🔒 Authentication\n\nThe API uses JWT Bearer token authentication:\n1. Obtain a token via the `/api/auth/login` endpoint\n2. Include the token in the Authorization header: `Bearer {token}`\n\n## 🔌 API Endpoints\n\n| Method | Endpoint | Description | Authentication |\n|--------|----------|-------------|----------------|\n| GET | `/api/v1/sales` | List all sales | Required |\n| GET | `/api/v1/sales/{id}` | Get sale by ID | Required |\n| POST | `/api/v1/sales` | Create new sale | Required |\n| PUT | `/api/v1/sales/{id}` | Update existing sale | Required |\n| DELETE | `/api/v1/sales/{id}` | Delete sale | Required |\n| POST | `/api/auth/login` | Authenticate user | Not Required |\n\n## 📊 Architecture\n\nThis project implements **CQRS and Event Sourcing** for scalability and maintainability.\n\n```\n┌───────────────┐     ┌───────────────┐     ┌───────────────┐\n│  Controllers  │────▶│    MediatR    │────▶│   Commands    │\n└───────────────┘     └───────────────┘     └───────┬───────┘\n                                                    │\n┌───────────────┐     ┌───────────────┐     ┌───────▼───────┐\n│   Database    │◀────│ Repositories  │◀────│   Handlers    │\n└───────────────┘     └───────────────┘     └───────────────┘\n```\n\n## 📜 Event Sourcing \u0026 Logging\n\nThis API utilizes **event sourcing** and **centralized logging** to enhance traceability:\n\n1. **MongoDB Event Store**\n   * Stores domain events related to sales transactions.\n   * Provides a historical timeline of all modifications.\n\n2. **MongoDB Log Storage**\n   * Uses **Serilog MongoDB Sink** for scalable log storage.\n   * Supports structured and queryable logs.\n\n## 🧪 Running Tests\n\n```bash\n# Run all tests\ndotnet test\n\n# Run tests with coverage report\ndotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover\n\n# Run specific test category\ndotnet test --filter \"Category=Integration\"\n\n# Run specific test class\ndotnet test --filter \"FullyQualifiedName~CreateSaleHandlerTests\"\n```\n\n## ❓ Troubleshooting\n\n### Common Issues \u0026 Fixes\n\n1. **Database connection failures**\n   * Ensure PostgreSQL and MongoDB are running\n   * Verify connection strings in `appsettings.json`\n   * Check network connectivity\n\n2. **JWT Authentication issues**\n   * Ensure token is valid and not expired\n   * Verify secret key configuration\n   * Check if roles are properly assigned\n\n3. **Event store not persisting data**\n   * Verify MongoDB connection\n   * Check if the `events` collection exists\n\n## 🛣️ Roadmap\n\n* Implement **Product Management Module**\n* Develop **Customer Management Module**\n* Enhance **Reporting Features**\n* Build **Admin Dashboard**\n* Integrate with **Ambev Inventory System**\n* Develop a **Mobile Application**\n* Add **Offline Capabilities**\n\n## 🤝 Contributing\n\nContributions are welcome! Follow these steps:\n\n1. Fork the repository\n2. Create a feature branch: `git checkout -b feature/new-feature`\n3. Commit changes: `git commit -m 'feat: add new feature'`\n4. Push to branch: `git push origin feature/new-feature`\n5. Open a Pull Request\n\nAdhere to the Conventional Commits standard.\n\n## 📜 License\n\nThis project is licensed under the **MIT License**. See the LICENSE file for details.\n\n## 👤 Author\n\n* 👨‍💻 **Felipe Gonçalves Ferreira**\n* 📧 Contact: **contato@felipegf.com.br**\n* 📌 [GitHub](https://github.com/yourusername) | [LinkedIn](https://linkedin.com/in/yourusername)\n\n\u003cp align=\"center\"\u003e Made with ❤️ for Ambev Developer Evaluation \u003c/p\u003e","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelipegf%2Fambev.omnia.eval","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffelipegf%2Fambev.omnia.eval","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelipegf%2Fambev.omnia.eval/lists"}