Back to projects
Full Stack2024

Embarca.ai

Brazilian bus ticket marketplace with Elasticsearch-powered route search, a coupon validation engine rebuilt after exploited bugs caused more than R$80k in losses, and React white-label pages for partner clients.

Embarca.ai

About the project

Embarca.ai is a Brazilian online marketplace for long-distance bus tickets. Customers search routes by origin, destination, and date, compare schedules and fares from multiple bus operators, and book through Pix or credit card installments. The backend runs on Ruby on Rails and the logged-in area uses React.

Route data flows in from external operator APIs and is combined with the internal database of companies serving each route. The combined catalog is indexed into Elasticsearch so that customer-facing searches skip PostgreSQL entirely and respond from the search index, which keeps the booking flow fast even as the route catalog grows.

The product also includes a coupon engine used by marketing, sales, and partner operators, with rules spanning validity windows, travel date ranges, first-purchase restrictions, percentage versus fixed discounts, minimum trip value, single-use per customer, and partner-specific campaigns. After the finance team traced more than R$80k in losses to bugs being exploited in the coupon flow, I rewrote the validation layer from the ground up, extracting every rule into a dedicated module with test coverage for each scenario.

My other work covered maintenance on the Elasticsearch indexing and search flows, operational tasks across Heroku, AWS S3, and Route 53, and a four-month stretch helping the single frontend developer ship React-based white-label landing pages for partner clients. Each white-label page embedded the Embarca search widget so that bookings still routed through the main platform.

Challenges

The coupon engine combined many independent rules that interacted in subtle ways: date windows, travel windows, first-purchase restrictions, percentage versus fixed discounts, minimum trip value, single-use constraints, and partner-specific campaigns. The original logic was scattered across the checkout flow, which made bugs easy to miss and hard to reproduce. Users who noticed the gaps were exploiting them, and the finance team estimated the total loss at more than R$80k before the rewrite closed the leaks.

Route search also had to stay fast while the underlying catalog combined data from external operator APIs with internal company records. Keeping the Elasticsearch index in sync with both sources required careful indexing logic so customers never saw stale or incomplete route listings.

Learnings

Rewriting the coupon engine taught me the value of isolating business rules into a single layer with explicit test coverage per scenario. When a domain has many independent rules that compose, scattered logic is not just a maintainability problem, it is a direct revenue risk.

This was also my first production exposure to Elasticsearch. The shift from relational-first thinking to "index what the user searches, not what the database stores" changed how I approach search-heavy features.

Gallery

Technologies

Ruby on RailsReactElasticsearchPostgreSQLHerokuAWS S3Docker

Year

2024

View Live Site