{"id":28447474,"url":"https://github.com/Jayakrishnan-mk/User-Doc-Management-NEST-JS","last_synced_at":"2025-06-30T10:31:19.403Z","repository":{"id":297267022,"uuid":"996221085","full_name":"Jayakrishnan-mk/User-Doc-Management-NEST-JS","owner":"Jayakrishnan-mk","description":"User-Document-Management System - Modular Nest Js Backend. This is a production-ready NestJS backend application for user and document management.","archived":false,"fork":false,"pushed_at":"2025-06-15T04:12:36.000Z","size":162,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-15T05:23:49.997Z","etag":null,"topics":["axios","bcryptjs","jest","jwt","multer","nestjs","nodejs","ocr-python","passport-jwt","pdf-parse","postgresql","typeorm","typescript","virustotal"],"latest_commit_sha":null,"homepage":"","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/Jayakrishnan-mk.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-04T16:22:10.000Z","updated_at":"2025-06-15T04:12:40.000Z","dependencies_parsed_at":"2025-06-15T05:34:02.952Z","dependency_job_id":null,"html_url":"https://github.com/Jayakrishnan-mk/User-Doc-Management-NEST-JS","commit_stats":null,"previous_names":["jayakrishnan-mk/jktech-task","jayakrishnan-mk/jk_tech-task","jayakrishnan-mk/jk_tech-user-doc-management","jayakrishnan-mk/user-doc-management-nest-js"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Jayakrishnan-mk/User-Doc-Management-NEST-JS","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jayakrishnan-mk%2FUser-Doc-Management-NEST-JS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jayakrishnan-mk%2FUser-Doc-Management-NEST-JS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jayakrishnan-mk%2FUser-Doc-Management-NEST-JS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jayakrishnan-mk%2FUser-Doc-Management-NEST-JS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jayakrishnan-mk","download_url":"https://codeload.github.com/Jayakrishnan-mk/User-Doc-Management-NEST-JS/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jayakrishnan-mk%2FUser-Doc-Management-NEST-JS/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260567253,"owners_count":23029071,"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":["axios","bcryptjs","jest","jwt","multer","nestjs","nodejs","ocr-python","passport-jwt","pdf-parse","postgresql","typeorm","typescript","virustotal"],"created_at":"2025-06-06T11:32:55.180Z","updated_at":"2025-06-30T10:31:19.383Z","avatar_url":"https://github.com/Jayakrishnan-mk.png","language":"TypeScript","readme":"# User and Document Management - Nest Js\n\n## Overview\n\nA production-ready, modular NestJS backend for user and document management, featuring:\n\n- Modular architecture (SOLID, best practices)\n- DTO validation, error handling, and clear separation of concerns\n- JWT authentication and role-based access (admin/editor/viewer)\n- PostgreSQL integration via TypeORM\n- File upload, document ingestion (OCR/PDF parsing), and status tracking\n- VirusTotal integration\n- Comprehensive unit and e2e tests\n\n## Features\n\n- **User Management:** Registration, login, CRUD, role management\n- **Auth:** JWT-based, role-based guards, secure endpoints\n- **Document Management:** CRUD, ownership checks, file upload\n- **Ingestion:** Trigger OCR/PDF parsing, status tracking, error handling\n- **Testing:** Unit and e2e tests for all modules\n\n## Getting Started\n\n### Prerequisites\n\n- Docker and Docker Compose\n- Node.js (v18+ recommended)\n- PostgreSQL\n\n### Installation\n\n```sh\nnpm install\n```\n\n### Environment Setup\n\nCreate a `.env` file in the project root from the example:\n\n```sh\ncp .env.example .env\n```\n\nEdit `.env` and update the following values:\nPORT=3000\n\n- DB_HOST\n- DB_PORT\n- DB_USERNAME\n- DB_PASSWORD\n- DB_DATABASE\n- JWT_SECRET\n- OCR_SPACE_API_KEY\n- VIRUSTOTAL_API_KEY\n\n### Running the App (Local Development)\n\n```sh\nnpm run start:dev\n```\n\n### Running the App (Docker)\n\n1. Build and run containers:\n```sh\ndocker-compose up --build\n```\n\n2. Access the application at http://localhost:3000\n\n3. To stop the containers:\n```sh\ndocker-compose down\n```\n\n### Running Tests\n\n- **Unit tests:**\n  ```sh\n  npm run test\n  ```\n- **e2e tests:**\n  ```sh\n  npm run test:e2e\n  ```\n\n### Database Migration\n\nIf using TypeORM migrations:\n\n```sh\nnpm run typeorm migration:run\n```\n\n### Docker Commands\n\n- Build and run containers:\n  ```sh\n  docker-compose up --build\n  ```\n- Run in detached mode:\n  ```sh\n  docker-compose up -d\n  ```\n- Stop containers:\n  ```sh\n  docker-compose down\n  ```\n- View logs:\n  ```sh\n  docker-compose logs -f\n  ```\n- Run migrations in Docker:\n  ```sh\n  docker-compose exec app npm run typeorm migration:run\n  ```\n- Run tests in Docker:\n  ```sh\n  docker-compose exec app npm run test\n  ```\n\n## API Overview\n\n### Auth\n\n- `POST /auth/register` — Register user `{ username, password, role? }`\n- `POST /auth/login` — Login `{ username, password }` → `{ access_token }`\n\n### Users\n\n- `GET /users/:id` — Get user profile (auth required)\n- `GET /users` — List users (auth required)\n- `PUT /users/:id` — Update user (self or admin)\n- `PATCH /users/:id/role` — Update user role (admin only)\n- `DELETE /users/:id` — Delete user (admin only)\n\n### Documents\n\n- `POST /documents` — Create document (auth required)\n- `GET /documents` — List documents (auth required)\n- `GET /documents/:id` — Get document by ID (auth required)\n- `PUT /documents/:id` — Update document (owner only)\n- `DELETE /documents/:id` — Delete document (owner only)\n- `POST /documents/upload` — Upload file (auth required)\n\n### Ingestion\n\n- `POST /ingestion/trigger` — Trigger ingestion `{ documentId }`\n- `GET /ingestion/status/:id` — Get ingestion status\n\n## Roles\n\n- `admin`: Full access, can manage users and roles\n- `editor`: Can manage own documents\n- `viewer`: Read-only access\n\n## File Uploads\n\nUploaded files are stored in `/uploads`. File URLs are returned in API responses.\n\n## Ingestion\n\n- Supports OCR (images) and PDF parsing\n- Status tracked per document\n- VirusTotal scan\n\n## Testing\n\n- All modules have unit and e2e tests\n- Run with `npm run test` and `npm run test:e2e`\n\n## Deployment\n\n- Dockerfile and docker-compose recommended for production\n- Ensure environment variables are set in production\n\n## Postman Collection\n\n- [Online Postman Workspace](https://postman.co/workspace/My-Workspace~392b206e-087a-4088-8de3-b885ca4343fa/collection/27063930-dd3c579f-c9ed-4d72-bdbc-ae6578ad841e?action=share\u0026creator=27063930\u0026active-environment=27063930-e072c2cc-0bbd-48d5-9a93-8cc1f0aa9ecd)\n- [Download Postman Collection (JSON)](./postman_collection.json)\n\n---\n\n**For more details, see code comments and tests.**\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJayakrishnan-mk%2FUser-Doc-Management-NEST-JS","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJayakrishnan-mk%2FUser-Doc-Management-NEST-JS","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJayakrishnan-mk%2FUser-Doc-Management-NEST-JS/lists"}