Overview
BarberApp uses dependency injection with repository tokens to maintain clean architecture. All Firebase services implement repository interfaces and are located insrc/app/services/firebase/.
Firebase Services
FirebaseAuthService
Handles authentication operations using Firebase Authentication. Location:src/app/services/firebase/firebase-auth.service.ts:18
Implements: AuthRepository
Methods
register(email: string, password: string): Promise<string>
register(email: string, password: string): Promise<string>
email- User’s email addresspassword- User’s password
firebase-auth.service.ts:22login(email: string, password: string): Promise<void>
login(email: string, password: string): Promise<void>
email- User’s email addresspassword- User’s password
auth/invalid-credential)Location: firebase-auth.service.ts:27logout(): Promise<void>
logout(): Promise<void>
firebase-auth.service.ts:31isAuthenticated(): Promise<boolean>
isAuthenticated(): Promise<boolean>
true if a user is signed in, false otherwiseLocation: firebase-auth.service.ts:35Uses onAuthStateChanged to detect the current auth state.getCurrentUser(): Promise<UserBase | null>
getCurrentUser(): Promise<UserBase | null>
UserBase object from Firestore, or null if not authenticatedLocation: firebase-auth.service.ts:43Behavior:- First checks Firebase Auth for the current user
- Then fetches full user data from Firestore via
FirebaseUserService - Falls back to a minimal
UserBaseobject if Firestore data is missing
FirebaseUserService
Manages user data in Firestore. Location:src/app/services/firebase/firebase-user.service.ts:18
Implements: UserRepository
Methods
createUser(user: Client | Specialist): Promise<void>
createUser(user: Client | Specialist): Promise<void>
user- Client or Specialist object with all required fields
firebase-user.service.ts:21Behavior:- Automatically assigns a default profile picture URL if not provided
- Stores the document with the user’s ID as the document ID
dniExists(dni: string): Promise<boolean>
dniExists(dni: string): Promise<boolean>
dni- National identity document number
true if DNI exists, false otherwiseLocation: firebase-user.service.ts:33Used during registration to prevent duplicate DNIs.getUserByUId(uid: string): Promise<UserBase | null>
getUserByUId(uid: string): Promise<UserBase | null>
uid- Firebase Authentication user ID
null if not foundLocation: firebase-user.service.ts:42Date objectsgetUserById(id: string): Promise<UserBase | null>
getUserById(id: string): Promise<UserBase | null>
id- Application user ID (may differ from Firebase UID)
null if not foundLocation: firebase-user.service.ts:57getUsersByIds(ids: string[]): Promise<UserBase[]>
getUsersByIds(ids: string[]): Promise<UserBase[]>
ids- Array of user IDs
firebase-user.service.ts:72getUsersByRole(role: string): Promise<UserBase[]>
getUsersByRole(role: string): Promise<UserBase[]>
role- User role (e.g.,'client','specialist')
firebase-user.service.ts:89updateUser(updatedData: Partial<Client | Specialist>): Promise<void>
updateUser(updatedData: Partial<Client | Specialist>): Promise<void>
updatedData- Partial user object withidand fields to update
id is missing or user not foundLocation: firebase-user.service.ts:105FirebaseAppointmentService
Manages appointments in Firestore. Location:src/app/services/firebase/firebase-appointment.service.ts:20
Implements: AppointmentRepository
Methods
create(appointment: Appointment): Promise<void>
create(appointment: Appointment): Promise<void>
appointment- Complete appointment object
firebase-appointment.service.ts:24getById(id: string): Promise<Appointment | null>
getById(id: string): Promise<Appointment | null>
id- Appointment ID
nullLocation: firebase-appointment.service.ts:33update(appointment: Partial<Appointment>): Promise<void>
update(appointment: Partial<Appointment>): Promise<void>
appointment- Partial appointment object withidrequired
firebase-appointment.service.ts:47Uses setDoc with merge: true to perform partial updates.getForClient(clientId: string): Promise<Appointment[]>
getForClient(clientId: string): Promise<Appointment[]>
clientId- Client’s user ID
firebase-appointment.service.ts:81getForSpecialist(specialistId: string): Promise<Appointment[]>
getForSpecialist(specialistId: string): Promise<Appointment[]>
specialistId- Specialist’s user ID
firebase-appointment.service.ts:85getCompletedForClient(clientId: string): Promise<Appointment[]>
getCompletedForClient(clientId: string): Promise<Appointment[]>
clientId- Client’s user ID
firebase-appointment.service.ts:89Used for displaying client medical history.getForSpecialistByStatuses(specialistId: string, statuses: AppointmentStatus[]): Promise<Appointment[]>
getForSpecialistByStatuses(specialistId: string, statuses: AppointmentStatus[]): Promise<Appointment[]>
specialistId- Specialist’s user IDstatuses- Array of appointment statuses to include
firebase-appointment.service.ts:108Example:getAppointmentsBySpecialistAndDateRange(specialistId: string, startDate: Date, endDate: Date): Promise<Appointment[]>
getAppointmentsBySpecialistAndDateRange(specialistId: string, startDate: Date, endDate: Date): Promise<Appointment[]>
specialistId- Specialist’s user IDstartDate- Range start dateendDate- Range end date
firebase-appointment.service.ts:127getAppointmentsByClientAndDateRange(clientId: string, startDate: Date, endDate: Date): Promise<Appointment[]>
getAppointmentsByClientAndDateRange(clientId: string, startDate: Date, endDate: Date): Promise<Appointment[]>
clientId- Client’s user IDstartDate- Range start dateendDate- Range end date
firebase-appointment.service.ts:147FirebaseSpecialtyService
Manages specialty/service definitions. Location:src/app/services/firebase/firebase-specialty.service.ts:17
Implements: SpecialtyRepository
Methods
getAll(): Promise<Specialty[]>
getAll(): Promise<Specialty[]>
firebase-specialty.service.ts:21getById(id: string): Promise<Specialty | null>
getById(id: string): Promise<Specialty | null>
id- Specialty ID
nullLocation: firebase-specialty.service.ts:28create(specialty: Specialty): Promise<void>
create(specialty: Specialty): Promise<void>
specialty- Complete specialty object
firebase-specialty.service.ts:34update(specialty: Specialty): Promise<void>
update(specialty: Specialty): Promise<void>
specialty- Complete specialty object with updated fields
firebase-specialty.service.ts:39delete(id: string): Promise<void>
delete(id: string): Promise<void>
id- Specialty ID to delete
firebase-specialty.service.ts:44External Services
CloudinaryService
Handles image uploads and transformations using Cloudinary CDN. Location:src/app/services/cloudinary/cloudinary.service.ts:8
Properties
Methods
uploadImage(file: File): Promise<string>
uploadImage(file: File): Promise<string>
file- Image file to upload
cloudinary.service.ts:15Example:environment.cloudinaryConfig.upload_preset.getTransformedUrl(imageUrl: string, transformations?: string): string
getTransformedUrl(imageUrl: string, transformations?: string): string
imageUrl- Original Cloudinary image URLtransformations- Optional transformation string (e.g.,'w_200,h_200,c_fill')
cloudinary.service.ts:42Example: