This project is a NestJS backend service for user authentication, user management, document management, and ingestion controls. It includes role-based access control (RBAC) and integrates PostgreSQL as the database.
- Authentication: User registration, login, logout, JWT-based authentication.
- User Management: CRUD operations for users with role-based permissions.
- Document Management: Upload, fetch, update, and delete documents.
- Ingestion API: Trigger ingestion process and track ongoing ingestion tasks.
- Microservices Architecture: Scalable and modular design.
- NestJS (Node.js framework)
- TypeScript
- PostgreSQL with TypeORM
- JWT Authentication
- bcrypt (Password hashing)
- Swagger (API documentation)
Ensure you have the following installed:
- Node.js (v16+)
- PostgreSQL
git clone https://github.com/your-repo.git
cd your-reponpm installCreate a .env file and configure the necessary variables:
DATABASE_URL=postgres://user:password@localhost:5432/mydatabase
JWT_SECRET=your_jwt_secret
PORT=3000npm run start:devPOST /auth/register
{
"email": "[email protected]",
"password": "password123",
"role": "viewer"
}Response:
{
"id": 1,
"email": "[email protected]",
"role": "viewer"
}POST /auth/login
{
"email": "[email protected]",
"password": "password123"
}Response:
{
"access_token": "jwt_token_here"
}POST /auth/logout
Response:
{
"message": "Logout successful"
}GET /users
Response:
[
{ "id": 1, "email": "[email protected]", "role": "admin" },
{ "id": 2, "email": "[email protected]", "role": "editor" }
]PATCH /users/:id/role
{
"role": "admin"
}Response:
{
"id": 2,
"email": "[email protected]",
"role": "admin"
}DELETE /users/:id
Response:
{
"message": "User deleted successfully"
}POST /documents/upload
Headers: Authorization: Bearer <JWT>
Form-Data:
file: Upload a document file.
Response:
{
"id": 1,
"filename": "document.pdf",
"uploadedBy": "[email protected]"
}GET /documents
Response:
[
{ "id": 1, "filename": "doc1.pdf", "uploadedBy": "[email protected]" },
{ "id": 2, "filename": "doc2.docx", "uploadedBy": "[email protected]" }
]DELETE /documents/:id
Response:
{
"message": "Document deleted successfully"
}POST /ingestion/trigger
{
"documentId": 1
}Response:
{
"message": "Ingestion process started for documentId 1"
}GET /ingestion/status/:id
Response:
{
"documentId": 1,
"status": "Processing"
}To run unit tests:
npm run testTo run integration tests:
npm run test:e2eTo build the project:
npm run buildTo start in production mode:
npm run start:prod- Harsh Verma - Developer
This project is licensed under the MIT License.