A NestJS-based backend service for managing users and documents with ingestion capabilities.
-
🔐 Authentication and Authorization
- JWT-based authentication
- Role-based access control (Admin, Editor, Viewer)
- Rate limiting and security measures
-
📄 Document Management
- CRUD operations for documents
- File upload with validation
- Role-based access control
- File type validation
-
🔄 Ingestion System
- Document processing pipeline
- Job management
- Node.js (v18 or higher)
- PostgreSQL (v14 or higher)
- Redis (v6 or higher)
- npm or yarn
Create a .env file in the root directory:
# App Configuration
NODE_ENV=development
PORT=3001
# Throttle
THROTTLE_TTL=60
THROTTLE_LIMIT=10
# Database Connection
DB_DIALECT=postgres
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=postgres
DB_PASSWORD=postgres
DB_DATABASE=postgres
# JWT Configuration
JWT_SECRET=your-secret-key-change-in-production
JWT_EXPIRES_IN=1d- Clone the repository:
git clone <repository-url>
cd document-management-system- Install dependencies:
npm install- Start the application:
# Development
npm run start:dev
# Production
npm run build# Start all services (app, database, redis)
docker-compose up -d
# View logs
docker-compose logs -f
# Stop all services
docker-compose down# Rebuild and start services
docker-compose up -d --build
# Run commands in the app container
docker-compose exec app npm run <command># Run seeds
docker-compose exec app npm run seed:run
# Access database CLI
docker-compose exec db psql -U admin -d jkOnce the application is running, access the Swagger API documentation at:
http://localhost:3000/api/docs
- POST
/api/auth/register- Register a new user - POST
/api/auth/login- Login user
- POST
/api/users- Create a new users (Admin only) - GET
/api/users- Get all users (Admin only) - GET
/api/users/:id- Get user by ID (Admin only) - PATCH
/api/users/:id- Update user (Admin only) - DELETE
/api/users/:id- Delete user (Admin only)
- POST
/api/documents- Upload a new document - GET
/api/documents- Get all documents - GET
/api/documents/:id- Get document by ID - PATCH
/api/documents/:id- Update document - DELETE
/api/documents/:id- Delete document - GET
/api/documents/:id/download- Download document
- POST
/api/ingestion- Create ingestion job - GET
/api/ingestion- Get all ingestion jobs - GET
/api/ingestion/:id- Get ingestion job by ID
# Format code
npm run format
# Lint code
npm run lint# Seed development data
npm run seed:devsrc/
├── common/ # Common utilities, guards, and decorators
├── config/ # Application configuration
├── database/ # Database configuration and migrations
├── modules/ # Feature modules
│ ├── auth/ # Authentication module
│ ├── users/ # User management module
│ ├── documents/ # Document management module
│ └── ingestion/ # Document ingestion module
├── main.ts # Application entry point
└── app.module.ts # Root module
- JWT-based authentication
- Role-based access control
- Rate limiting
- File type validation
- Password hashing
- CORS enabled
- Helmet security headers
- Redis caching
- Database indexing
- File streaming
- Request throttling
- Connection pooling
- Centralized error handling
- Structured logging
- Request validation
- Error monitoring
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License.