Spring Dadata is a web application designed to integrate and demonstrate the capabilities of the Dadata API. It allows users to search, clean, and enrich address and company data using a clean and responsive web interface.
- Address Search & Standardization:
- Cleans and standardizes raw address strings.
- Displays detailed administrative divisions (region, city, district).
- Shows geo-coordinates and nearest metro stations.
- Identifies tax office codes (IFNS, OKATO, OKTMO).
- Company Search:
- Search organizations by INN (Taxpayer Identification Number).
- Retrieves full company details including management, status, and legal address.
- Displays KPP, OGRN, OKVED, and other statistical codes.
- UI/UX:
- Modern and responsive interface built with Thymeleaf and Bootstrap 5.
- Card-based result layout for better readability.
- Dynamic search forms for different data types.
- Java 21
- Spring Boot 4+ (Spring Web, Spring MVC)
- Thymeleaf
- Maven
- Docker & Docker Compose
- Dadata API (RestClient)
- Lombok
- JDK 21+
- Maven
- A valid Dadata API Token and Secret key.
You need to configure your Dadata credentials in src/main/resources/application.yml or via environment variables:
dadata:
token: ${DADATA_TOKEN:your_token_here}
secret: ${DADATA_SECRET:your_secret_here}-
Clone the repository:
git clone https://github.com/castroy10/spring-dadata.git cd spring-dadata -
Build the project:
./mvnw clean install
-
Run the application:
./mvnw spring-boot:run
-
Access the app: Open your browser and navigate to
http://localhost:8080.
-
Build and start the container:
docker-compose up -d --build
-
Stop the application:
docker-compose down
-
Build the image:
docker build -t spring-dadata . -
Run the container:
docker run -d -p 8080:8080 -e DADATA_TOKEN=your_token -e DADATA_SECRET=your_secret --name spring-dadata spring-dadata
- AddressService: Handles communication with Dadata's "Clean" API to process address data.
- CompanyService: Interacts with Dadata's "Suggest" API to find organization details by INN. Implements null-safe handling for API responses.
- Comprehensive DTOs mapping the complex JSON responses from Dadata, including nested structures like
Management,Opf,State, and detailedAddresscomponents.
- MainController: Manages web routes, handles search form submissions, and populates the Thymeleaf model with search results.
The project includes comprehensive unit tests covering:
- Service Layer: Mocking
RestClientto test API interactions and edge cases (null responses, empty lists). - Controller Layer: Testing web endpoints and view resolution using
MockMvcin standalone mode.
To run tests:
./mvnw test