How sanju1098/fullstack-authentication-system works
This is a React frontend backed by an Express authentication API, with DummyJSON supplying credential verification and upstream tokens. The main workflow runs from login through frontend auth state, backend validation and session creation, then cookie-backed session restoration, refresh/retry, protected dashboard access, and logout. The graph preserves the distinct UI, request, API, session, and provider stages. Some listed modules were not excerpted; relationships involving them are included only where the README or SOURCE INDEX supports them.
Main entry points: AuthContext.tsx Auth state · auth.controller.ts Auth controllers · api.ts API client · auth.routes.ts Auth routes
Components 22
Frontend experience
- App routes
src/routes/AppRoutes.tsx - Login page
src/pages/auth/Login.tsx - Dashboard
src/pages/dashboard/Dashboard.tsx - Route guards
src/routes/ProtectedRoute.tsx - Session loader
src/components/common/Loader.tsx
Client authentication
- Auth hook
src/hooks/useAuth.ts - Auth state
src/context/AuthContext.tsx - Auth requests
src/services/auth.service.ts - API client
src/services/api.ts - Token store
src/services/token.store.ts - Auth types
src/types/auth.types.ts
Backend API
- API server
backend-server/src/server.ts - Auth routes
backend-server/src/routes/auth.routes.ts - Login validation
backend-server/src/middleware/validate.middleware.ts - Login schema
backend-server/src/schemas/auth.schema.ts - Auth controllers
backend-server/src/controllers/auth.controller.ts - Provider service
backend-server/src/services/auth.service.ts - Error handling
backend-server/src/middleware/error.middleware.ts
Backend session state
- Cookie handling
backend-server/src/utils/cookies.ts - Session store
backend-server/src/utils/session.store.ts
Other components
- User
- DummyJSON auth
Connections 26
- User → Login page: submits credentials
README.md - Login page → Auth hook: uses auth
src/pages/auth/Login.tsx - Auth hook → Auth state: reads state
src/hooks/useAuth.ts - Auth state → Auth requests: calls auth requests
src/context/AuthContext.tsx - Auth state → API client: sets failure handler
src/context/AuthContext.tsx - Auth state → Token store: clears tokens
src/context/AuthContext.tsx - Auth requests → API client: sends requests
src/services/auth.service.ts - Auth requests → Auth types: uses types
src/services/auth.service.ts - Auth state → Auth types: uses types
src/context/AuthContext.tsx - API client → Auth routes: calls API
README.md - API client → Auth state: notifies auth failure
src/context/AuthContext.tsx - App routes → Login page: routes to
src/routes/AppRoutes.tsx - App routes → Route guards: guards access
src/routes/AppRoutes.tsx - Route guards → Auth hook: checks auth
src/routes/ProtectedRoute.tsx - Route guards → Session loader: renders loading
src/routes/ProtectedRoute.tsx - App routes → Dashboard: routes to
src/routes/AppRoutes.tsx - Dashboard → Auth hook: reads auth
src/pages/dashboard/Dashboard.tsx - API server → Auth routes: mounts routes
backend-server/src/server.ts - API server → Error handling: registers errors
backend-server/src/server.ts - Auth routes → Login validation: validates login
backend-server/src/routes/auth.routes.ts - Login validation → Login schema: checks schema
backend-server/src/middleware/validate.middleware.ts - Auth routes → Auth controllers: dispatches requests
backend-server/src/routes/auth.routes.ts - Auth controllers → Provider service: calls services
backend-server/src/controllers/auth.controller.ts - Auth controllers → Session store: creates and rotates sessions
backend-server/src/controllers/auth.controller.ts - Auth controllers → Cookie handling: sets and clears cookies
backend-server/src/controllers/auth.controller.ts - Provider service → DummyJSON auth: authenticates and refreshes
backend-server/src/services/auth.service.ts