Routing Strategy
Happy Habitat uses HashLocationStrategy for routing, which prefixes all URLs with#:
http://localhost:4200/#/homehttp://localhost:4200/#/auth/loginhttp://localhost:4200/#/resident/visitantes
- No server-side configuration required
- Works with any hosting environment
- Compatible with static file servers
Root Routes
Location:src/app/app.routes.ts
Route Structure
Public Routes
Authentication Routes
Path:/auth/*
/auth/login- User login/auth/register- New user registration/auth/forgot-password- Password recovery/auth/reset-password- Password reset (requires auth)
AuthPageComponent which provides a clean layout without application chrome.
Protected Routes
Routes that require authentication use theauthGuard.
General Routes
| Route | Component | Guard | Description |
|---|---|---|---|
/home | HomePageComponent | authGuard | Landing page |
/dashboard | DashboardPageComponent | authGuard | Dashboard |
/comunicados | ComunicadosListComponent | authGuard | Announcements |
/proveedores | ProveedoresServiciosComponent | authGuard | Service providers |
/anuncios | ComunicadosListComponent | authGuard | Public notices |
/social | PostsListComponent | authGuard | Social feed |
/documents | DocumentsPageComponent | authGuard | Documents |
Feature Routes (Lazy Loaded)
Amenities:/amenidades/*
/resident/*
Role-Based Routes
Routes that require specific user roles useroleGuard.
System Administrator Routes
Path:/sysadmin/*
SYSTEM_ADMIN or ADMIN_COMPANY
Admin Company Routes
Path:/admincompany/*
ADMIN_COMPANY
Available Routes:
/admincompany/morosos- Delinquent accounts/admincompany/saldo-banco- Bank balance/admincompany/historial-pagos-residente- Payment history
Vigilance Routes
Path:/vigilancia/*
VIGILANCE
Available Routes:
/vigilancia/incidentes- Incident tracking/vigilancia/reservaciones- Reservation management/vigilancia/residentes- Resident monitoring/vigilancia/tickets- Support tickets
Feature Route Details
Resident Routes
Location:src/app/components/resident/resident-routes.ts
| Pattern | Example | Description |
|---|---|---|
/resident/visitantes | - | Visitor registration |
/resident/preferencias | - | User preferences |
/resident/mascotas | - | Pet registration |
/resident/autos | - | Vehicle registration |
/resident/reservaciones | - | Amenity reservations |
/resident/encuestas | - | Available surveys |
/resident/encuestas/:id | /resident/encuestas/123 | Take specific survey |
/resident/tickets | - | Support tickets list |
/resident/tickets/nuevo | - | Create new ticket |
/resident/tickets/:id | /resident/tickets/456 | Ticket detail |
/resident/pagos | - | Payment history |
/resident/pagos/nuevo | - | New payment |
/resident/pagos/:id | /resident/pagos/789 | Payment detail |
ResidentActividadesLayoutComponent for consistent resident portal UI.
Amenity Routes
Location:src/app/components/amenidades/amenidades-routes.ts
Available Routes:
/amenidades- Amenity list/grid/amenidades/:id- Amenity detail/amenidades/reservar/:id- Make reservation
Navigation Guards
Authentication Guard
Location:src/app/guards/auth.guard.ts
- Checks if user is authenticated via
AuthService - Allows access if authenticated
- Redirects to
/auth/loginwith return URL if not authenticated
Role Guard
Location:src/app/guards/role.guard.ts
allowedRoles: string[]- List of roles that can access the route
- Checks authentication first
- Verifies user has at least one of the allowed roles
- Redirects to
/homeif user lacks required role
Route Parameters
Reading Route Parameters
Query Parameters
Setting Query Params:Programmatic Navigation
Using Router Service
Using RouterLink Directive
Lazy Loading
All feature routes use lazy loading for optimal bundle size:- Smaller initial bundle
- Faster initial load time
- Code splitting by feature
- Load features on-demand
404 Handling
The wildcard route catches all unmatched URLs:Route Configuration Best Practices
1. Route Hierarchy
2. Guard Composition
Guards can be combined:3. Redirect Routes
4. Route Ordering
More specific routes should come before generic ones:Navigation Events
Listen to routing events for loading indicators, etc.:Next Steps
- Frontend Overview - Learn about the framework and stack
- Project Structure - Understand the directory organization