Overview
This guide covers running the TelegrmBot API directly on your local machine without Docker. This setup is ideal for:- Active development with fast iteration
- Debugging with IDE integration
- Testing changes without rebuilding Docker images
- Learning the codebase architecture
While Docker provides environment consistency, local development offers faster feedback loops and better debugging capabilities.
Prerequisites
Ensure you have the following installed:Required Software
Java Development Kit
Apache Maven
PostgreSQL
Git
Optional Tools
- IntelliJ IDEA (recommended) or Eclipse/VS Code
- pgAdmin or DBeaver for database management
- Postman or Insomnia for API testing
Database Setup
Install PostgreSQL
- macOS
- Ubuntu/Debian
- Windows
Using Homebrew:
Create Database
Create application user (optional but recommended)
For development, using a dedicated user is good practice. For simplicity, you can also use the
postgres superuser.Configure Database Connection
Test the connection:If you created a dedicated user, test with:
Project Setup
Clone Repository
Configure Environment Variables
Verify Configuration
Ensure Spring Boot can read the.env file. The application.yaml includes:
.env on startup.
Build and Run
Maven Build
Run tests (optional)
Tests use Testcontainers, which requires Docker. If Docker isn’t available, skip tests with
-DskipTests.Run Application
- Maven Spring Boot Plugin
- Java JAR
- With Profile
Recommended for development - Supports hot reload:
This method enables Spring Boot DevTools for automatic restarts when code changes.
Verify Application Started
Successful startup shows:The Telegram bot will automatically start polling for messages. Send a message to your bot to test the integration.
IDE Setup
IntelliJ IDEA
Import project
- Open IntelliJ IDEA
- Select File → Open
- Navigate to project directory and select
pom.xml - Choose Open as Project
- IntelliJ will automatically import Maven dependencies
Enable annotation processing
Required for Lombok:
- Go to Settings → Build, Execution, Deployment → Compiler → Annotation Processors
- Check Enable annotation processing
- Click Apply
Create run configuration
- Click Run → Edit Configurations
- Click + and select Spring Boot
- Name:
TelegrmApplication - Main class:
com.acamus.telegrm.TelegrmApplication - Environment variables: Load from
.envor set manually - Click OK
IntelliJ IDEA Ultimate includes advanced Spring Boot support with:
- Spring Boot dashboard
- Endpoint mappings view
- Database tools
- HTTP client
VS Code
Install extensions
Install the following extensions:
- Extension Pack for Java (Microsoft)
- Spring Boot Extension Pack (VMware)
- Lombok Annotations Support
Eclipse
Import Maven project
- File → Import → Maven → Existing Maven Projects
- Browse to project directory
- Select
pom.xml - Click Finish
Configure JDK
- Right-click project → Properties
- Java Build Path → Libraries
- Ensure JDK 21 is configured
Install Lombok
- Download
lombok.jarfrom projectlombok.org - Run:
java -jar lombok.jar - Install into Eclipse
- Restart Eclipse
Development Workflow
Hot Reload with Spring Boot DevTools
The project includes Spring Boot DevTools for automatic restarts:- Make code changes
- Save files (or build in IDE)
- Application automatically restarts
DevTools only restarts the application context, not the JVM, making restarts much faster than full restarts.
Database Migrations
The project uses Flyway for database migrations. Migration scripts are in:-
Create a new SQL file following the naming convention:
Example:
V003__add_user_roles_table.sql -
Place in
src/main/resources/db/migration/ - Restart application - Flyway will apply the migration
Testing
Integration tests use Testcontainers, which requires Docker. Ensure Docker is running when executing tests.
Debugging
- IntelliJ IDEA
- VS Code
- Remote Debug
- Set breakpoints by clicking left margin
- Click debug icon (bug) or press Shift + F9
- Use debug controls to step through code
Accessing the Application
API Endpoints
Swagger UI
URL: http://localhost:8080/swagger-ui.htmlInteractive API documentation and testing interface
OpenAPI Spec
URL: http://localhost:8080/v3/api-docsRaw OpenAPI 3.0 specification in JSON format
Health Check
URL: http://localhost:8080/actuator/healthApplication health status
Metrics
URL: http://localhost:8080/actuator/metricsApplication metrics and monitoring data
Database Access
Connect to PostgreSQL:Troubleshooting
Port Already in Use
Error:- Find and Kill Process
- Use Different Port
Database Connection Failed
Error:Lombok Not Working
Error:- Ensure Lombok plugin is installed in IDE
- Enable annotation processing (IntelliJ/Eclipse)
- Rebuild project:
mvn clean compile - Restart IDE
Maven Dependency Issues
Error:Flyway Migration Failed
Error:- Check migration syntax in SQL files
- Clean database (development only):
- Manual repair:
Next Steps
Architecture Guide
Understand the hexagonal architecture
API Reference
Explore available endpoints
Docker Deployment
Deploy with containers
Development Guide
Learn about the development workflow