{"id":43896287,"url":"https://github.com/muhammad4dev/nest-erp-backend","last_synced_at":"2026-02-06T17:30:46.677Z","repository":{"id":330773358,"uuid":"1121966539","full_name":"muhammad4dev/nest-erp-backend","owner":"muhammad4dev","description":null,"archived":false,"fork":false,"pushed_at":"2025-12-29T12:39:36.000Z","size":329,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-30T00:20:33.194Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/muhammad4dev.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":"docs/roadmap.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-23T21:43:12.000Z","updated_at":"2025-12-29T12:39:40.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/muhammad4dev/nest-erp-backend","commit_stats":null,"previous_names":["muhammad4dev/nest-erp-backend"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/muhammad4dev/nest-erp-backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muhammad4dev%2Fnest-erp-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muhammad4dev%2Fnest-erp-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muhammad4dev%2Fnest-erp-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muhammad4dev%2Fnest-erp-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/muhammad4dev","download_url":"https://codeload.github.com/muhammad4dev/nest-erp-backend/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muhammad4dev%2Fnest-erp-backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29170036,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T16:33:35.550Z","status":"ssl_error","status_checked_at":"2026-02-06T16:33:30.716Z","response_time":59,"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":[],"created_at":"2026-02-06T17:30:45.824Z","updated_at":"2026-02-06T17:30:46.668Z","avatar_url":"https://github.com/muhammad4dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NestJS ERP (Modular Monolith)\n\nA production-grade, compliance-ready ERP backend built with **NestJS**, **PostgreSQL 18+**, and **TypeORM**.\n\n## 🚀 Key Features\n\n### 🛡️ Core Architecture\n\n- **Multi-Tenancy**: Strict data isolation using Row-Level Security (RLS).\n- **Security**: JWT-based authentication with Role-Based Access Control (RBAC).\n- **Data Integrity**: **UUID v7** for all primary keys (time-request sortable) and immutable **Audit Logs** via PL/pgSQL triggers.\n- **Double-Entry Bookkeeping**: Finance module enforces `Debits = Credits` at the database level.\n\n### 📦 Modular Design\n\n- **Finance**: General Ledger, Journals, Accounts, Trial Balance.\n- **Inventory**: Multi-warehouse stock, Unit of Measure (UOM) conversion.\n- **Supply Chain**: Sales (Quote-\u003eInvoice) \u0026 Procurement (RFQ-\u003eBill).\n- **HRMS**: Employee profiles and payroll structure.\n- **POS**: Offline-first Point of Sale API with batch synchronization.\n- **Localization**: Master data translation tables (e.g., bi-lingual Product names).\n- **Compliance**: **ETA eInvoicing** integration (Egyptian Tax Authority) canonical JSON mapping.\n\n## 🛠️ Tech Stack\n\n- **Framework**: NestJS (Modular Monolith)\n- **Database**: PostgreSQL 18+\n- **ORM**: TypeORM\n- **Package Manager**: pnpm\n\n## 📖 Documentation\n\nFor detailed information, please refer to the following guides:\n\n- [🚀 Core Architecture](docs/architecture.md)\n- [🛠️ Developer Guide](docs/development.md)\n- [📦 Database Setup \u0026 RLS](docs/db-setup.md) - **START HERE** for multi-tenant database initialization\n- [⚙️ Operations \u0026 Maintenance](docs/operations.md)\n- [🧪 Testing Strategy](docs/testing.md)\n- [📈 Future Roadmap](docs/roadmap.md)\n\n## ⚡ Getting Started\n\n### Prerequisites\n\n- Node.js 20+\n- pnpm\n- Docker (for remote DB usage or local dev)\n\n### Installation\n\n```bash\npnpm install\n\n# 2. Database Setup (Initial Dev Only)\n# WARNING: This initializes RLS policies and Audit triggers.\npnpm db:setup\n```\n\n### Environment Config\n\nCreate a `.env` file in the root:\n\n```env\nDB_HOST=localhost\nDB_PORT=5432\nDB_USERNAME=postgres\nDB_PASSWORD=postgres\nDB_DATABASE=postgres\nJWT_SECRET=super_secret_key\n```\n\n### Running the App\n\n```bash\n# Development\npnpm run start:dev\n\n# Production Build\npnpm run build\npnpm run start:prod\n```\n\n### 📚 API Documentation\n\nOnce running, access the Swagger UI at:\nhttp://localhost:3000/api\n\n## 🧪 Testing \u0026 Verification\n\nWe prioritize strictly enforcing architectural boundaries.\n\n### The Leak Test\n\nA dedicated E2E test suite that attempts to access Tenant A's data using Tenant B's credentials. **This MUST fail** for the system to be considered secure.\n\n```bash\n# Run The Leak Test\npnpm test test/leak.e2e-spec.ts\n```\n\n### Unit Tests\n\nVerify business logic for complex domains (Tax Calculation, PO Status transitions):\n\n```bash\npnpm test\n```\n\n## 🏗️ Module Overview\n\n| Module          | Description           | Key Entities                       |\n| --------------- | --------------------- | ---------------------------------- |\n| **Core**        | Kernel, Auth, Context | `Tenant`, `User`, `AuditLog`       |\n| **Finance**     | Accounting Engine     | `JournalEntry`, `Account`          |\n| **Inventory**   | Stock \u0026 Product       | `Product`, `StockQuant`, `UomUnit` |\n| **Sales**       | CRM \u0026 Orders          | `SalesOrder`, `Partner`            |\n| **Procurement** | Purchasing            | `PurchaseOrder`, `VendorBill`      |\n| **POS**         | Retail API            | `PosSession` (stateless sync)      |\n| **Compliance**  | Tax Authority         | `EtaInvoiceDto`                    |\n\n## 🤝 Contribution\n\n1.  Fork the repository.\n2.  Create a feature branch (`feat/new-module`).\n3.  Ensure \"The Leak Test\" passes.\n4.  Submit a Pull Request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuhammad4dev%2Fnest-erp-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuhammad4dev%2Fnest-erp-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuhammad4dev%2Fnest-erp-backend/lists"}