{"id":29406372,"url":"https://github.com/moustafaa91/discountcode_be","last_synced_at":"2026-01-20T16:27:26.788Z","repository":{"id":271106658,"uuid":"912415669","full_name":"Moustafaa91/DiscountCode_BE","owner":"Moustafaa91","description":"An application to Generate and use random CouponCodes using WebSocket SignalR communication","archived":false,"fork":false,"pushed_at":"2025-07-06T00:38:03.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-29T01:03:52.990Z","etag":null,"topics":["csharp","csharp-code","mongodb","signalr","websocket"],"latest_commit_sha":null,"homepage":"https://discountcode-be.onrender.com/discountHub","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Moustafaa91.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-01-05T14:14:01.000Z","updated_at":"2025-07-06T00:38:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"3f24b844-1c86-44a6-adfe-c58f84740c85","html_url":"https://github.com/Moustafaa91/DiscountCode_BE","commit_stats":null,"previous_names":["moustafaa91/discountcode_be"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Moustafaa91/DiscountCode_BE","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moustafaa91%2FDiscountCode_BE","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moustafaa91%2FDiscountCode_BE/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moustafaa91%2FDiscountCode_BE/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moustafaa91%2FDiscountCode_BE/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Moustafaa91","download_url":"https://codeload.github.com/Moustafaa91/DiscountCode_BE/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moustafaa91%2FDiscountCode_BE/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267612744,"owners_count":24115520,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"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":["csharp","csharp-code","mongodb","signalr","websocket"],"created_at":"2025-07-10T23:20:08.395Z","updated_at":"2026-01-20T16:27:26.762Z","avatar_url":"https://github.com/Moustafaa91.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Discount Code Service (SignalR Backend)\n\nThis is a C# backend application for managing discount codes, built using **ASP.NET Core** and **SignalR**. The backend exposes a WebSocket hub that allows real-time interaction for generating, using, and retrieving discount codes.\n\nA corresponding client application is available at [SignalR Console Client](https://github.com/Moustafaa91/DiscountCode_ConsoleApp).\n\n## Features\n- **GenerateCodes**: Create unique discount codes with a specified count and length.\n- **UseCode**: Mark discount code as used.\n- **GetUsedCodes**: Retrieve a list of used discount codes.\n- **GetUnusedCodes**: Retrieve a list of unused discount codes.\n- **Ping**: Test the connectivity to the WebSocket hub.\n\n## Technologies Used\n- **C#** (.NET)\n- **SignalR** for real-time WebSocket communication\n- **MongoDB** for data storage\n- **Docker** (optional) for deployment\n\n## Prerequisites\n- **.NET SDK**: Install the latest version from [here](https://dotnet.microsoft.com/download).\n- **MongoDB**: Either host MongoDB locally or use a cloud service like [MongoDB Atlas](https://www.mongodb.com/cloud/atlas).\n\n## Installation\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/Moustafaa91/DiscountCode_BE.git\n   cd DiscountCode_BE\n   ```\n\n2. Restore dependencies:\n   ```bash\n   dotnet restore\n   ```\n\n3. Set up environment variables:\n   Create a `.env` file in the project root with the following:\n   ```env\n   MONGODB_CONNECTION_STRING=\u003cYour MongoDB Connection String\u003e\n   MONGODB_DATABASE_NAME=DiscountCodeDB\n   ```\n\n4. Run the application:\n   ```bash\n   dotnet run\n   ```\n\n## API Reference\nThe backend exposes the following WebSocket endpoints via SignalR:\n- **Ping**: Tests connectivity.\n- **GenerateCodes(count, length)**: Generates discount codes with the specified count and length.\n- **UseCode(code)**: Marks a discount code as used.\n- **GetUsedCodes()**: Retrieves a list of used codes.\n- **GetUnusedCodes()**: Retrieves a list of unused codes.\n\nThe WebSocket hub is hosted at:\n[https://discountcode-be.onrender.com/discountHub](https://discountcode-be.onrender.com/discountHub)\n\n## Packages Used\nThis project uses the following NuGet packages:\n- `Microsoft.AspNetCore.SignalR`: Enables SignalR hub functionality.\n- `Microsoft.AspNetCore.SignalR.Client`: Allows communication with SignalR hubs.\n- `MongoDB.Driver`: MongoDB .NET Driver for database operations.\n- `dotenv.net`: For managing environment variables.\n- `Newtonsoft.Json`: For JSON serialization.\n\n## Deployment\n### Using Docker\nBuild and run the application using Docker:\n1. Create a `Dockerfile` in the project root:\n   ```dockerfile\n   FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build\n   WORKDIR /app\n   COPY . .\n   RUN dotnet restore\n   RUN dotnet publish -c Release -o out\n\n   FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime\n   WORKDIR /app\n   COPY --from=build /app/out .\n   ENTRYPOINT [\"dotnet\", \"DiscountCodeService.dll\"]\n   ```\n\n2. Build and run the Docker image:\n   ```bash\n   docker build -t discountcode-backend .\n   docker run -p 5000:5000 discountcode-backend\n   ```\n\n### Hosting on Render\nThe application is currently hosted on Render:\n[https://discountcode-be.onrender.com](https://discountcode-be.onrender.com)\n\n## Client Application\nA console-based client application to interact with this backend is available at:\n[SignalR Console Client](https://github.com/Moustafaa91/DiscountCode_ConsoleApp)\n\n## Contributions\n\nContributions are welcome! Feel free to fork this repository and submit pull requests for any improvements or bug fixes.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoustafaa91%2Fdiscountcode_be","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoustafaa91%2Fdiscountcode_be","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoustafaa91%2Fdiscountcode_be/lists"}