Skip to main content

Overview

Trippins provides a comprehensive browsing experience for finding the perfect accommodation. Whether you’re looking for a budget-friendly option or a luxury hotel, the platform offers multiple ways to discover and filter housing options.

Accessing the Housing Catalog

The housing catalog is publicly accessible - you don’t need to be logged in to browse available accommodations.

Navigate to /room

View all available accommodations in the platform
@Component({
  selector: 'app-room',
  templateUrl: './room.component.html'
})
export class RoomComponent implements OnInit {
  houses: any[] = [];
  currentPage = -1;
  pageSize = 6;
  isLoading = false;
  hasMore = true;

  ngOnInit(): void {
    this.loadHouses();
  }
}

Housing Data Structure

Each housing listing contains the following information:
interface HousingDTO {
  code: number;            // Unique identifier
  location: string;        // City/address
  name: string;           // Hotel name
  imageBase64: string;    // Property image
  price: number;          // Price per night
  description: string;    // Full description
  stars: number;          // Star rating (1-5)
  acepted: boolean;       // Admin approval status
  tags: Tag[];           // Feature tags
}

Pagination

Infinite Scroll Loading

The housing list uses pagination to load properties efficiently:
loadHouses(): void {
  if (this.isLoading || !this.hasMore) return;

  this.isLoading = true;
  this.currentPage++;

  this.houseService.getRooms(this.currentPage, this.pageSize).subscribe({
    next: (response) => {
      // Append new properties to existing list
      this.houses = [...this.houses, ...response.content];
      
      // Check if more pages are available
      this.hasMore = !response.last;
      this.isLoading = false;
    },
    error: (err) => {
      console.error('Error loading houses:', err);
      this.isLoading = false;
    }
  });
}

API Endpoint for Pagination

GET /v1/api/houses

Retrieve paginated list of housing properties
page
number
default:"0"
Page number (zero-indexed)
size
number
default:"6"
Number of items per page
# Get first page with 6 items
curl http://localhost:8080/v1/api/houses?page=0&size=6

# Response format
{
  "content": [...],      // Array of housing items
  "totalElements": 42,   // Total number of houses
  "totalPages": 7,       // Total number of pages
  "size": 6,            // Items per page
  "number": 0,          // Current page number
  "last": false         // Is this the last page?
}
The default page size is 6 properties, optimized for grid display with 2 columns on desktop and 1 column on mobile.

Search Functionality

Search by Tags and Stars

Users can filter accommodations using two parameters:
interface SearchParams {
  tags?: string;      // Comma-separated tag names
  stars?: number;     // Minimum star rating (1-5)
}

onSearchSubmit(): void {
  this.currentPage = 1;
  this.houses = [];
  
  // Call search with both parameters
  this.houseService.searchHouses(
    this.searchParams.tags || '', 
    this.searchParams.stars || 1
  ).subscribe({
    next: (houses) => {
      this.houses = houses;
    },
    error: (error) => {
      console.error('Search error:', error);
    }
  });
}

Available Search Tags

Common property tags include:

Pool

Swimming pool available

WiFi

Free wireless internet

Parking

On-site parking

Breakfast

Breakfast included

Gym

Fitness center access

Pet Friendly

Pets allowed

Search API Endpoint

GET /v1/api/query

Advanced search with tags and star filtering
# Search for hotels with pool and WiFi, minimum 4 stars
curl "http://localhost:8080/v1/api/query?tags=Pool,WiFi&stars=4"

# Search by stars only
curl "http://localhost:8080/v1/api/query?stars=5"

# Search by tags only
curl "http://localhost:8080/v1/api/query?tags=Parking,Breakfast"
Tags are case-sensitive. Make sure to use exact tag names as they appear in the database.

Viewing Property Details

Click on any property to view full details:
// Navigate to room details page
this.router.navigate(['/room', houseCode]);

Loading Specific Property

loadHouseDetails(code: number): void {
  this.housingService.getSpecificRoom(code).subscribe({
    next: (house: any) => {
      this.house = {
        ...house,
        image: `${environment.baseUrlApi}/houses/${code}/image`
      };
    },
    error: (err: any) => {
      console.error('Error loading house details:', err);
    }
  });
}

Property Detail API

GET /v1/api/houses/{id}

Get detailed information for a specific property
# Get details for house with code 5
curl http://localhost:8080/v1/api/houses/5 \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
Viewing property details requires authentication. Anonymous users must log in or register to see full property information.

Property Images

Image Storage and Retrieval

Images are stored as Base64-encoded strings in the database but served via a dedicated endpoint:
public class HousingDTO {
    @JsonIgnore
    private String imageBase64; // Not included in JSON response
    
    private transient MultipartFile image;
    
    public String convertToBase64(MultipartFile image) throws IOException {
        String base64Image = Base64.getEncoder().encodeToString(image.getBytes());
        return base64Image;
    }
}

Image Endpoint

GET /v1/api/houses/{id}/image

Retrieve property image
// Construct image URL in frontend
const imageUrl = `${environment.baseUrlApi}/houses/${code}/image`;
<!-- Display in template -->
<img [src]="house.image" [alt]="house.name" />

Housing Management (Admin Only)

Creating New Properties

Only authenticated users with ROLE_USER or ROLE_ADMIN can create new housing listings:

POST /v1/api/houses

Create a new housing property (requires JWT)
@PostMapping
@SecurityRequirement(name = "JWT")
public ResponseEntity<HousingDTO> createHouse(@RequestBody HousingDTO house) {
    HousingDTO createdHouse = housingService.createHouse(house);
    return ResponseEntity.status(HttpStatus.CREATED).body(createdHouse);
}

Approval Workflow

New properties require admin approval before appearing in search results:
  1. User submits property with acepted: false
  2. Admin reviews the listing
  3. Admin sets acepted: true to publish
  4. Property becomes visible to all users
Only properties with acepted: true should be displayed in the public catalog. Filter results appropriately in your queries.

Best Practices

Use lazy loading for property images to improve page load times:
<img loading="lazy" [src]="house.image" />
Consider caching popular search queries client-side to reduce server load and improve response times.
Show loading placeholders while fetching properties to improve perceived performance:
<div *ngIf="isLoading" class="skeleton-card"></div>
Always handle API errors gracefully and show user-friendly messages:
error: (err) => {
  this.errorMessage = 'Unable to load properties. Please try again.';
  console.error('Error loading houses:', err);
}

UI Flow Example

1

User lands on /room

Initial page load with first 6 properties
2

Scroll for more

User scrolls down, triggering automatic load of next page
3

Apply filters

User selects tags (e.g., “Pool, WiFi”) and minimum stars (e.g., 4)
4

View filtered results

Search results display only matching properties
5

Click property

Navigate to detail page to see full information
6

Make reservation

From detail page, user can book the property (requires login)

Property Tags Management

Retrieving Tags for a Property

GET /v1/api/houses/{id}/tags

Get all tags associated with a property
@GetMapping("/{id}/tags")
@SecurityRequirement(name = "JWT")
public ResponseEntity<Set<TagDTO>> getTagsById(@PathVariable int id) {
    Set<TagDTO> tags = housingService.getTagsById(id);
    return ResponseEntity.ok(tags);
}
curl http://localhost:8080/v1/api/houses/5/tags \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

# Response
[
  { "id": 1, "name": "Pool" },
  { "id": 2, "name": "WiFi" },
  { "id": 3, "name": "Parking" }
]

Troubleshooting

  • Check if properties have acepted: true
  • Verify API endpoint is responding
  • Check browser console for JavaScript errors
  • Ensure pagination parameters are correct
  • Verify tag names are spelled correctly (case-sensitive)
  • Check if star rating is within 1-5 range
  • Ensure at least one property matches criteria
  • Try broadening search parameters
  • Verify image endpoint URL is correct
  • Check if Base64 data is properly stored
  • Ensure CORS headers allow image requests
  • Verify JWT token is included for authenticated endpoints
  • Check if hasMore flag is properly set
  • Verify isLoading state is managed correctly
  • Ensure scroll event listener is attached
  • Check network tab for failed requests

Making Reservations

Book a property after browsing

Writing Reviews

Share your experience about properties

Authentication

Log in to access property details

User Roles

Learn about admin approval process

Build docs developers (and LLMs) love