{"id":20027956,"url":"https://github.com/mohamedelareeg/ecommerceeventsourcing","last_synced_at":"2026-05-09T07:36:59.458Z","repository":{"id":248187933,"uuid":"828011846","full_name":"mohamedelareeg/ECommerceEventSourcing","owner":"mohamedelareeg","description":"This repository uses Marten with Postgres for event sourcing:  **Event Sourcing:** Captures state changes as events.  **Services:** Manages Cart, Order, Inventory, Transactions, Warehouses. **Marten with Postgres:** Reliable event store and advanced querying.","archived":false,"fork":false,"pushed_at":"2024-07-12T22:36:41.000Z","size":72,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-02T04:43:59.867Z","etag":null,"topics":["dotnet","dotnet-core","event-driven","event-sourcing","events","marten","martendb","microservice","postgres","postgresql","sql"],"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/mohamedelareeg.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":"2024-07-12T22:08:58.000Z","updated_at":"2024-07-13T07:21:30.000Z","dependencies_parsed_at":"2024-07-13T00:03:48.492Z","dependency_job_id":null,"html_url":"https://github.com/mohamedelareeg/ECommerceEventSourcing","commit_stats":null,"previous_names":["mohamedelareeg/inventoryeventsourcing"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mohamedelareeg/ECommerceEventSourcing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohamedelareeg%2FECommerceEventSourcing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohamedelareeg%2FECommerceEventSourcing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohamedelareeg%2FECommerceEventSourcing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohamedelareeg%2FECommerceEventSourcing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mohamedelareeg","download_url":"https://codeload.github.com/mohamedelareeg/ECommerceEventSourcing/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohamedelareeg%2FECommerceEventSourcing/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32811655,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"online","status_checked_at":"2026-05-09T02:00:06.633Z","response_time":123,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["dotnet","dotnet-core","event-driven","event-sourcing","events","marten","martendb","microservice","postgres","postgresql","sql"],"created_at":"2024-11-13T09:12:38.270Z","updated_at":"2026-05-09T07:36:59.432Z","avatar_url":"https://github.com/mohamedelareeg.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ecommerce Event Sourcing\n\nThis repository demonstrates an event sourcing implementation using Marten with Postgres for managing Inventory, Warehouse, Order, and Cart functionalities. Event sourcing captures all changes to application state as a sequence of events, providing detailed auditing, reconstruction of past states, and a clear history of data changes.\n\n![Add/Remove from Cart](images/cart_example.png)\n\n## Features\n\n- **Event Sourcing:** Utilizes Marten with Postgres to implement event sourcing for Inventory, Warehouse, Order, and Cart management.\n- **Services Implemented:**\n  - CartService: Manages shopping cart operations such as adding/removing items, updating quantities, and shipping information.\n  - OrderService: Handles order creation, cancellation, submission, and retrieval.\n  - InventoryService: Provides operations for managing inventory like adding/removing products, updating product information, and retrieving product details.\n  - ProductTransactionService: Manages product transactions including sales, purchases, and transfers between warehouses.\n  - WarehouseService: Retrieves information about warehouses and their products.\n\n## Cart Endpoints\n\n- **GET /cart/{userId}**\n  - Retrieves the cart items for a specific user.\n\n- **POST /cart/add/{userId}/{productId}/{quantity}**\n  - Adds a product to the user's cart with the specified quantity.\n\n- **PUT /cart/update/{userId}/{productId}/{quantity}**\n  - Updates the quantity of a product in the user's cart.\n\n- **DELETE /cart/remove/{userId}/{productId}**\n  - Removes a product from the user's cart.\n\n- **DELETE /cart/clear/{userId}**\n  - Clears all items from the user's cart.\n\n## Order Endpoints\n\n- **POST /order/create/{userId}**\n  - Creates a new order.\n\n- **DELETE /order/cancel/{userId}/{orderId}**\n  - Cancels an order.\n\n- **GET /order/{userId}**\n  - Retrieves orders for a user.\n\n- **POST /order/submit/{userId}**\n  - Submits an order.\n\n## Inventory Endpoints\n\n- **POST /inventory/add/{name}/{warehouseId}**\n  - Adds a new product to inventory.\n\n- **GET /inventory/product/{productId}/{warehouseId}**\n  - Retrieves product details including quantity and transactions.\n\n- **DELETE /inventory/remove/{productId}/{warehouseId}**\n  - Removes a product from inventory.\n\n- **PUT /inventory/update/{productId}/{name}/{warehouseId}**\n  - Updates product information.\n\n- **POST /inventory/sale/add/{warehouseId}/{productId}/{quantity}/{price}**\n  - Adds a sale transaction for a product.\n\n- **POST /inventory/purchase/add/{warehouseId}/{productId}/{quantity}/{price}**\n  - Adds a purchase transaction for a product.\n\n- **POST /inventory/transfer/{sourceWarehouseId}/{targetWarehouseId}/{productId}/{quantity}**\n  - Transfers a product between warehouses.\n\n- **GET /warehouses**\n  - Retrieves all warehouses.\n\n## Marten with Postgres\n\n### Marten\n\n[Marten](https://github.com/JasperFx/marten) is a library for .NET applications that combines the benefits of event sourcing and document databases. It provides:\n\n- **Event Store:** Marten uses Postgres as an event store, storing all domain events that occur within the application. Each event represents a change to the application's state.\n  \n- **Document Database:** Postgres, as the underlying database, not only stores event streams efficiently but also supports complex querying capabilities needed for reconstructing application state from events.\n\n- **Event Handlers:** Marten allows you to define event handlers that react to domain events by updating read models or external systems. This facilitates real-time updates and projections based on changes in the event store.\n\n### Why Postgres with Marten?\n\nUsing Postgres with Marten offers several advantages:\n\n- **Scalability:** Postgres is known for its scalability and reliability, making it suitable for applications that require handling large volumes of data and high transaction rates, such as inventory management.\n\n- **Rich Querying:** Postgres provides powerful SQL querying capabilities, which Marten leverages for efficiently querying event streams and reconstructing application state.\n\n- **ACID Compliance:** Postgres ensures ACID (Atomicity, Consistency, Isolation, Durability) compliance, ensuring data integrity and reliability even in the face of concurrent operations and failures.\n\n- **Community and Ecosystem:** Postgres has a large and active community, along with extensive ecosystem support, including tools for monitoring, replication, and management, which are beneficial for enterprise-grade applications.\n\n## Setup Instructions\n\nTo run the project locally:\n\n1. Clone this repository.\n2. Set up a Postgres database and configure connection details in `appsettings.json`.\n3. Restore NuGet packages and build the solution.\n4. Run the application.\n\n### API Documentation\n\nExplore and test the API using the Swagger UI available at `{base_url}/swagger`.\n\n### Contributing\n\nContributions are welcome! Please fork the repository and submit pull requests for any enhancements or bug fixes.\n\n### License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohamedelareeg%2Fecommerceeventsourcing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohamedelareeg%2Fecommerceeventsourcing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohamedelareeg%2Fecommerceeventsourcing/lists"}