Lubank is a Spring Boot-based API for handling basic banking operations. The project uses Java 17 and PostgreSQL.
- Java 17 or higher
- Gradle
- PostgreSQL
- Clone the repository:
git clone https://github.com/lucianowayand/lubank.git
cd lubank- Create a .env file in the project root using the provided .env.example:
cp .env.example .env- Edit .env with your PostgreSQL credentials and secret key:
# PostgreSQL database credentials
DATABASE_URL=jdbc:postgresql://localhost:5432/lubank
DATABASE_USER=your_db_user
DATABASE_PASSWORD=your_db_password
# JWT Encryption key, must be 256-bits
SECRET_KEY=your_secret_key- Build the project:
./gradlew build- Run the application:
./gradlew bootRunThe API will be available at http://localhost:8080.
To make it easier to run the API, you can use Docker.
- Build the Docker image:
docker build -t lubank:latest .- Run the Docker container:
docker run -p 8080:8080 lubank:latestThe .env file will be automatically copied during the Docker build step, so make sure it is present in the root directory.
The project uses several key dependencies:
- Spring Boot Starter Web: Provides core features for building a REST API.
- Spring Boot Starter Data JPA: Integrates with JPA for database operations.
- Spring Boot Starter Data REST: Exposes JPA entities as RESTful endpoints automatically.
- Spring Boot DevTools: Enables hot reloading for quicker development.
- PostgreSQL Driver: JDBC driver for PostgreSQL connection.
- Flyway: Manages database migrations.
- Dotenv Java: Loads environment variables from a .env file.
- OAuth2 Resource Server: Secures the API with JWT-based authentication.
- Lombok: Reduces boilerplate code with annotations (e.g., @Data, @Builder).
The project uses Flyway for handling database schema migrations. To create a new migration, use the provided shell script create_migration.sh:
./create_migration.sh migration_nameThis script generates a new migration file in the src/main/resources/db/migration/ folder, named with a timestamp for unique versioning. Example:
./create_migration.sh AddUsersTableOutput:
Migration file created: src/main/resources/db/migration/V1699372841__AddUsersTable.sqlThe application will check for pending migrations on start and run the necessary migrations.