{"id":28904778,"url":"https://github.com/shivshankarkushwaha/credit-engine-js","last_synced_at":"2026-04-14T19:31:55.805Z","repository":{"id":298655894,"uuid":"1000656981","full_name":"ShivShankarKushwaha/credit-engine-js","owner":"ShivShankarKushwaha","description":"A lightweight and secure Node.js API for issuing, tracking, and managing thank-you credits using Express and MongoDB. Designed with modular architecture, logging, and rate limiting for production-grade deployments.","archived":false,"fork":false,"pushed_at":"2025-06-12T06:26:59.000Z","size":81,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-21T13:02:42.960Z","etag":null,"topics":["api","authentication","authorization","backend","credit-system","express","logging","mongodb","nodejs","rate-limiting","rest-api","typescript","vercel","winston"],"latest_commit_sha":null,"homepage":"https://credit-engine-new.vercel.app/","language":"JavaScript","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/ShivShankarKushwaha.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-06-12T06:03:16.000Z","updated_at":"2025-06-12T06:26:58.000Z","dependencies_parsed_at":"2025-06-12T07:37:42.935Z","dependency_job_id":"8dfc8d4e-57d6-4f56-8ff5-4ee1967c3946","html_url":"https://github.com/ShivShankarKushwaha/credit-engine-js","commit_stats":null,"previous_names":["shivshankarkushwaha/credit-engine-js"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ShivShankarKushwaha/credit-engine-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShivShankarKushwaha%2Fcredit-engine-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShivShankarKushwaha%2Fcredit-engine-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShivShankarKushwaha%2Fcredit-engine-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShivShankarKushwaha%2Fcredit-engine-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ShivShankarKushwaha","download_url":"https://codeload.github.com/ShivShankarKushwaha/credit-engine-js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShivShankarKushwaha%2Fcredit-engine-js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261126449,"owners_count":23113312,"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","authentication","authorization","backend","credit-system","express","logging","mongodb","nodejs","rate-limiting","rest-api","typescript","vercel","winston"],"created_at":"2025-06-21T13:02:18.411Z","updated_at":"2026-04-14T19:31:55.800Z","avatar_url":"https://github.com/ShivShankarKushwaha.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Credit-Engine Service API](https://credit-engine-new.vercel.app/)\n\nA lightweight API designed to issue and track \"thank-you\" credits for various ecosystem interactions. This project is built with Node.js, Express, and TypeScript, following a robust, company-level directory structure for scalability and maintainability.\n\n## Features\n\n- **Credit Issuance:** API endpoint to issue credits for defined action types.\n- **Action Type Management:** Enumerates valid ecosystem interactions (e.g., `techModule`, `socialPost`, `referral`).\n- **Structured Logging:** Centralized logging using Winston for better observability.\n- **Environment Configuration:** Secure handling of environment variables.\n- **Rate Limiting:** Basic protection against abuse.\n- **Security Headers:** Uses Helmet for basic security enhancements.\n- **Docker Support:** Containerized setup for consistent environments.\n- **Unit \u0026 E2E Testing:** Configured with Vitest for reliable testing.\n- **Code Quality:** ESLint for maintaining code style and quality.\n\n## Technologies Used\n\n- **Runtime:** Bun / Node\n- **Framework:** Express.js\n- **Language:** TypeScript\n- **Database (Placeholder):** MongoDB (via Mongoose)\n- **Caching (Placeholder):** Redis (via ioredis)\n- **Testing:** Vitest, playwright\n- **Linting:** ESLint, Prettier\n- **Containerization:** Docker, Docker Compose\n- **Environment Variables:** `dotenv`, Joi\n- **Logging:** Winston\n- **Security:** `express-rate-limit`\n- **Authentication (Placeholder):** JWT, bcrypt\n\n## Low - level - diagram\n\n\u003cimg src=\"https://i.ibb.co/bjKDfc5X/LLD.png\" alt=\"low level diagram\"\u003e\n\n## Getting Started\n\n### Prerequisites\n\n- Bun (or Node.js v18+)\n- Docker \u0026 Docker Compose (optional)\n\n### Local Development\n\n1.  **Clone the repository:**\n\n    ```bash\n    git clone https://github.com/ShivShankarKushwaha/credit-engine-js\n    cd credit-engine-js\n    ```\n\n2.  **Install dependencies:**\n\n    ```bash\n    bun install\n    ```\n\n3.  **Set up environment variables:**\n    Create a `.env` file in the root directory based on `.env.example`:\n\n    ```\n    PORT=3000\n    NODE_ENV=development\n    MONGO_URI=mongodb://localhost:27017/credit_engine_db\n    REDIS_URL=redis://localhost:6379\n    JWT_SECRET=your_secret_key_here_for_development\n    ```\n\n4.  **Start MongoDB and Redis (using Docker Compose for simplicity):**\n\n    ```bash\n    docker-compose up mongodb redis\n    ```\n\n    Alternatively, ensure you have local instances of MongoDB and Redis running and update your `MONGO_URI` and `REDIS_URL` in `.env` accordingly.\n\n5.  **Run the development server:**\n    ```bash\n    bun run dev\n    ```\n6.  ** Commit and git push rules **\n\n    ```bash\n        # To push code, ensure your branch name matches the required format (`type/name`), where `type` is one of: `ci`, `chore`, `docs`, `ticket`, `feat`, `fix`, `pref`, `refactor`, `revert`, or `style`. Protected branches (`master`, `integration`, `develop`) cannot be pushed to directly.\n\n        # **Valid push workflow:**\n        # Example: create a feature branch\n        git checkout -b feat/my-new-feature\n\n        # Add and commit your changes\n        git add .\n        git commit -m \"feat: add my new feature\"\n\n        # Push to remote (will be validated by pre-push hook)\n        git push origin feat/my-new-feature\n\n        #Pushes that do not follow this convention will be rejected.\n    ```\n\n    The API will be available at `http://localhost:3000`.\n\n### Running with Docker\n\n1.  **Build and run containers:**\n    ```bash\n    docker-compose up --build\n    ```\n    This will build the Docker image for the app and start all services (app, mongodb, redis).\n\n### API Endpoints\n\n### Get Credit Status\n\n```http\nGET http://localhost:3000/api/credits/\u003c user id\u003e\nAccept: application/json\n```\nRetrieves the credit status for a specific user by their ID.\n\n---\n\n### Issue Credit\n\n```https\nPOST http://localhost:3000/api/credits\nContent-Type: application/json\n\n{\n    \"userId\": \u003c user id\u003e,\n    \"actionType\": \u003caction type\u003e,\n    \"amount\": 75,\n    \"metadata\": {\n        \"moduleName\": \"testModule\",\n        \"progress\": \"completed\"\n    }\n}\n```\nIssues thank-you credits to a user for a specific action.\n\n---\n\n### Enroll User\n\n```http\nPOST http://localhost:3000/api/enroll\nContent-Type: application/json\n\n{\n    \"name\": \"testuser3\",\n    \"email\": \"test3@example.com\",\n    \"role\": \"student\",\n    \"password\": \"password\"\n}\n```\nEnrolls a new user into the system.\n\n## Live url test\n\n**For live url testing see the \u003ca href=\"./test.rest\"\u003etest.rest\u003c/a\u003e file**\n\n## Testing\n\n- **Run all tests:**\n  ```bash\n  bun test\n  ```\n- **Run unit tests:**\n  ```bash\n  bun run test:unit\n  ```\n- **Run end-to-end tests:**\n  ```bash\n  bun run test:e2e\n  ```\n- **Get coverage of the tests:**\n  ```bash\n  bun run coverage\n  ```\n\n## Linting\n\n- **Run linter:**\n  ```bash\n  bun run lint\n  ```\n- **Fix linting and formetting errors:**\n  ```bash\n  bun run format\n  ```\n\n## Future Scope\n\n### Planned Enhancements\n\n- **Public/Private Credit Systems:**\n  Allow users to choose whether their credit profile is public (visible to others) or private (only visible to themselves and admins). API endpoints and database schema will be updated to support this privacy setting.\n\n- **Sharable Credit Profiles:**\n  Enable users to generate a secure, shareable link to their credit profile. This link can be shared with others, respecting the user's privacy settings.\n\n- **Admin Controls:**\n  Admins will have the ability to override privacy settings for moderation or compliance purposes.\n\n- **Audit Logs:**\n  Track changes to privacy settings and sharing actions for transparency and security.\n\n## Deployment\n\nThis project includes `Dockerfile` for containerization and `vercel.json` for serverless deployment using Vercel.\n\n---\n\n**Note:** This `Readme.md` is a comprehensive starting point. You will need to fill in specific details and further elaborate as you implement more features.\nThis credit-engine software is created upon [Ts-Server](https://github.com/ShivShankarKushwaha/templates) starting template by Shiv Shankar Kushwaha.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshivshankarkushwaha%2Fcredit-engine-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshivshankarkushwaha%2Fcredit-engine-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshivshankarkushwaha%2Fcredit-engine-js/lists"}