How moesiomarcelino/gobarber-web works
Project Type and Purpose
• This is a single-page, front-end React/TypeScript application (“GoBarber Web”) for managing barbershop appointments.
• It provides user authentication, profile management, password reset flows, and a dashboard to view/create appointments by integrating with a separate back-end API.
Main Architectural Components
a. Browser / Client
• React SPA entry point (src/index.tsx → src/App.tsx)
• Routing layer (src/routes)
• Pages (src/pages/*): SignIn, SignUp, ForgotPassword, ResetPassword, Profile, Dashboard
• Shared UI Components (src/components/*): Button, Input, Tooltip, ToastContainer, etc.
• Hooks (src/hooks/*): Auth context, Toast notifications
• Styles (src/styles/global.ts + per-component styles)
b. HTTP API Layer
• axios instance in src/services/api.ts
• Token injection via interceptors (Auth hook)
• Exposed REST calls for authentication, user profile, appointments
c. External Back-end Services (not in this repo)
• Authentication service
• Appointments service
• Users/profile service
• Database (PostgreSQL / MongoDB / etc.)
d. Build & Tooling
• Node/Yarn or npm build scripts (package.json)
• ESLint, Prettier configurations
• Static assets served via public/index.html
Component Interactions and Data Flow
• User interacts with UI Components on the Browser → React Page renders form/data → triggers Hook calls or dispatches service methods.
• Services/api.ts sends HTTP requests to back-end microservices (Auth, Appointments, Users).
• Responses flow back → global state/hooks update (e.g., setUser, push Toast).
• Routing guards (Auth hook) redirect unauthenticated users to SignIn.
• ToastContainer listens to toast events via Toast hook and displays notifications.
Key Architectural Patterns
• Component-based UI (atomic components + pages)
• Client-side routing (react-router)
• Context API / custom hooks for cross-cutting concerns (authentication, notifications)
• Service layer for API abstraction (single axios instance)