A lightweight Customer Relationship Management system for managing sellers and their transactions.
- Seller & Transaction Management: Create, retrieve, update, soft-delete, and hard-delete sellers and transactions.
- Analytics:
- Identify the top seller within a given period.
- Find sellers with a turnover below a specified amount.
- Data History Preservation:
- Versioning of database records for
Updateoperations. - Delete Types:
- Soft-delete: Records are marked as deleted but remain in the database.
- Hard-delete: Records are permanently removed from the database.
- Versioning of database records for
- Java 21 (Gradle)
- Spring Boot 3.4+ (Data JPA, WebMVC, Test)
- PostgreSQL 12+ — primary database
- Flyway — database migration management
- H2 — in-memory database for integration testing
- SwaggerUI (OpenAPI) — automatic API documentation
- Spring Boot Test (JUnit 5 + Mockito) — unit and integration testing
- Lombok
- Gradle — build and dependency management
- Postman — manual API testing and debugging
- Java 21
- Gradle 8.0+
- PostgreSQL 12+
- Create a PostgreSQL database, e.g.
simple_crm_db. - Ensure the user has read/write permissions.
- Create a
.envfile under thePresentation/.envdirectory. - Configure your database connection according to the example in
.env.example. - Create a
gradle.propertiesfile in the project root. - Configure Flyway settings based on
gradle.properties.example. - Verify the configured data source in your IDE.
# Stop all running Spring Boot processes (if any)
taskkill /f /im java.exe
# Clean and build the project
./gradlew clean build --refresh-dependencies
# Run Flyway migrations
./gradlew :Presentation:flywayClean :Presentation:flywayMigrate
# Start the application
./gradlew :Presentation:bootRunWarning
Flyway rollbacks are available only in the Pro or Enterprise editions. If you encounter migration issues (missing tables, invalid flyway_schema_history, etc.), manually recreate the necessary tables using PgAdmin or your IDE’s SQL console.
If the build succeeds, the application will be available at: http://localhost:8080
Request:
POST http://localhost:8080/api/sellers
Content-Type: application/json
{
"name": "John Doe",
"contactInfo": "john.doe@example.com",
"registrationDate": "2025-10-07T12:30:00"
}Response:
201 Created
{
"seller": {
"id": 1,
"name": "John Doe",
"contactInfo": "john.doe@example.com",
"registrationDate": "2025-10-10T19:46:19.7552163",
"version": null
},
"message": null,
"errorType": null
}
Request:
DELETE http://localhost:8080/api/transactions/1?deleteType=softResponse:
204 No Content
Request:
GET http://localhost:8080/api/analytics/best-period/1
Content-Type: application/json
{
"amount": 65.05,
"paymentType": "CASH",
"transactionDate" : "2025-09-07T14:00:00",
"sellerId": 1
}Response:
200 OK
{
"startDate": "2025-06-07T14:00:00",
"endDate": "2025-10-07T14:00:00",
"transactionCount": 3
}
Once the application is running, the full API specification is available at: http://localhost:8080/swagger-ui/index.html
- Unit Tests for entities, DTOs, services, and utilities. Average coverage: 90%
- API Tests covering all main usage scenarios.
- Integration Tests for repositories using an H2 in-memory database.
# run tests
./gradlew test# generate JaCoCo coverage reports
./gradlew jacocoRootReportCode coverage reports are available at: build/reports/jacoco/rootHtml/index.html
The application can be easily deployed using Docker with the provided Dockerfile and docker-compose.yaml configuration files.
- Docker Engine 20.10+
- Docker Compose v2.0+
-
Create a
.envfile in the project root directory with your database credentials:DB_USER=postgres DB_PASSWORD=your_secure_password DB_URL=jdbc:postgresql://db:5432/SimpleCrmDb
-
Build and start the services:
# Build the Docker images docker-compose build # Start all services docker-compose up -d
-
Access the application: Once the containers are running, the application will be available at: http://localhost:8080
Dockerfile: Multi-stage build configuration for the Spring Boot application with security best practicesdocker-compose.yaml: Production-ready configuration with environment variables and resource limitsdocker-compose.override.yaml: Development configuration with volume mounts for live code reloading
The Docker deployment uses the following environment variables (can be set in .env file):
DB_NAME: Database name (default: SimpleCrmDb)DB_USER: Database usernameDB_PASSWORD: Database passwordDB_PORT: Database port (default: 5432)APP_PORT: Application port (default: 8080)SPRING_PROFILES_ACTIVE: Spring profile to use (default: docker)
# View container logs
docker-compose logs -f
# Stop all services
docker-compose down
# View running containers
docker-compose ps
# Execute commands in the running container
docker-compose exec app bash- Runs application with non-root user
- Resource limits to prevent DoS attacks
- Health checks for service monitoring
- Environment variables for secret management
- Minimal base images to reduce attack surface
This project is licensed under the MIT License - see the LICENSE.md file for details.
For questions or feedback: limosha@inbox.ru
Feel free to customize this further to better fit your needs!