A Spring Boot backend application designed to manage legal contracts through a secure consultancy workflow.
The system implements role-based and ownership-based access control to ensure that users can only access contracts they are authorized to view. Clients can manage their own contracts, consultants can review and approve contracts assigned to them, and administrators can oversee workflow progress without accessing confidential contract content.
In addition to contract management, the application supports document parsing using Apache Tika and provides contract question-answering through keyword-based retrieval from extracted contract text.
Legal contracts often contain sensitive information that should only be accessible to specific stakeholders. This project focuses on enforcing those access boundaries throughout the entire contract lifecycle.
Key security rules include:
- Clients can only access, update, download, and query their own contracts.
- Consultants can only access contracts assigned to them.
- Administrators can monitor contract workflow and user activity without viewing contract contents.
- Every contract retrieval request validates both user role and contract ownership/assignment before data is returned.
- Unauthorized access attempts result in application-level exceptions and access denial.
Beyond access control, the system supports:
- Secure JWT-based authentication
- Contract upload and storage
- Document text extraction using Apache Tika
- Contract lifecycle management (Draft → Review → Approved)
- Contract question-answering using keyword-based retrieval
- File download and document management
- MongoDB-based persistence
- JWT-based Authentication
- Spring Security Integration
- Stateless Session Management
- Role-Based Access Control (RBAC)
- Ownership-based contract access validation
- Users can only access resources permitted by their role and ownership rules
Supported Roles:
- ADMIN
- CONSULTANT
- CLIENT
- Upload PDF/DOCX contracts
- Update contract details
- Retrieve contracts
- Download uploaded contract files
- Track and Update contract status
- Store metadata in MongoDB
- Store uploaded files locally
- Text extraction using Apache Tika
- Extracted content stored for retrieval
- Contract Question & Answer functionality
- Keyword-based answer retrieval from extracted contract text
Contracts move through the following lifecycle:
DRAFT
↓
REVIEW
↓
APPROVED
This workflow ensures contracts are reviewed and approved before completion.
Client Request
│
▼
Spring Security Filter Chain
│
▼
JWT Authentication Filter
│
▼
Security Context
│
▼
Role & Ownership Validation
│
▼
Controller Layer
│
▼
Service Layer
│
▼
MongoDB / File Storage
- View contracts status across the system
- View consultants
- View clients
- Assign consultant roles
- Monitor contract workflow
- View assigned contracts
- Review assigned contracts
- Approve assigned contracts
- Download assigned contract files
- Ask questions from assigned contract content
- Upload contracts
- Update own contracts
- View own contracts
- Download own contracts
- Ask questions from own uploaded contracts
Upload Contract
│
▼
Store File Locally
│
▼
Apache Tika Extraction
│
▼
Store Extracted Text
│
▼
Contract Q&A Retrieval
- Java 21
- Spring Boot 3
- Spring Web
- Spring Security
- Spring Validation
- MongoDB
- Spring Data MongoDB
- Apache Tika
- Maven
- Lombok
- JWT (JSON Web Token)
src/main/java/com/contractmanagementsystem
├── controller
├── dto
├── exception
├── model
├── repository
├── security
├── service
├── utils
└── ContractManagementSystemApplication.java
POST /auth/register
POST /authPOST /client
PUT /client/{id}
GET /client
GET /client/{id}
POST /client/{id}/askGET /consultant
GET /consultant/{id}
PUT /consultant/updateStatusToReview/{id}
PUT /consultant/updateStatusToApproved/{id}GET /admin/getAllContracts
PUT /admin/{id}What are the payment terms?
{
"contractId": "contract-id",
"contractName": "Rent Contract",
"question": "What are the payment terms?",
"answer": "Matched contract content...",
"score": 2
}git clone https://github.com/mansisharma011/Contract-Management-System.git
cd Contract-Management-Systemspring.data.mongodb.uri=mongodb://localhost:27017/contract_dbjwt.secret=YOUR_BASE64_SECRET_KEYWindows:
mvnw.cmd spring-boot:runLinux/macOS:
./mvnw spring-boot:runApplication runs on:
http://localhost:8080
- LLM-powered Contract Q&A using Retrieval-Augmented Generation (RAG)
- Semantic Search using Vector Embeddings
- OpenAPI / Swagger Documentation
- Unit & Integration Testing
- Pagination & Filtering
- Cloud File Storage (AWS S3)
- Contract Versioning
- Audit Logging
Mansi Sharma
Java Backend Developer | Spring Boot | MongoDB | Spring Security | REST APIs