mohd-faraz

_blogs

// blogs / 20260607.md

Dev Log: June 07 Wrap-up

2026-06-07
#Spring Boot#Java#PostgreSQL#MongoDB#Docker#Backend

Overview

Today was all about that 'blank canvas' feeling. I spent the day bootstrapping the core architecture for the new e-commerce backend. It's a lot of boilerplate at first, but getting the foundation right now saves so much headache later.

What I Worked On

Setting up the skeleton

I kicked things off by spinning up a fresh Spring Boot 3.3.5 project. I'm sticking with a pretty standard layered architecture—controllers, services, repositories—because it just works and everyone knows where to find things. For the database, I started with PostgreSQL 16 and integrated Flyway immediately. I've learned the hard way that if you don't start with schema migrations on day one, you'll eventually end up with a mess of 'final_v2.sql' files that no one understands.

Going Polyglot (Postgres + MongoDB)

I decided to bring MongoDB into the mix alongside PostgreSQL. It's a bit more work up front, but it gives us the flexibility to handle relational data where consistency matters and document-based data for things like product catalogs or logs where schemas might be more fluid.

One thing that tripped me up for a second was Spring getting confused about which repository belonged where. If you have both JPA and Mongo dependencies, you have to be explicit about which packages they should scan. I ended up creating a small configuration bean to keep them separate:

@Configuration
@EnableJpaRepositories(basePackages = "com.hawkflit.ecommerce.repository.jpa")
@EnableMongoRepositories(basePackages = "com.hawkflit.ecommerce.repository.mongo")
public class PersistenceConfig {
    // Separating these stops the framework from trying to 
    // map a document to a relational table.
}

The "Port Already in Use" Trap

I hit a classic developer snag while testing the Docker Compose setup. I already have native instances of Postgres and MongoDB running on my local machine for another project, so the default ports (5432 and 27017) were totally blocked. I had to remap the container ports to 5433 and 27018. It's a small tweak, but I made sure to document it in the README so the rest of the team doesn't spend an hour wondering why their connection is being refused.

Wrapping Up

The build is green, the containers are talking to each other, and the basic package structure is ready for actual business logic. Tomorrow, I'll probably start looking at the security layer and setting up some initial API endpoints. It feels good to have the plumbing finished.