How na1969na/bridge-app works
Project type and purpose
• This is a full-stack web application (“Bridge – Check-in App”) whose goal is to enable daily user check-ins, track them on a calendar, and notify emergency contacts (via SMS or email) if a check-in is missed for 72 hours.
File structure
• Top level separates “backend” and “frontend.”
• Backend follows an MVC-like pattern with
• src/controllers
• src/services
• src/repositories
• src/models
• src/middleware (JWT checks, error handling)
• src/config/db.ts for MongoDB connection
• Frontend is a React/Vite app in TypeScript with:
• src/api for HTTP clients (apiClient, checkInApi, userApi)
• src/components (UI, layout, modals, check-in widgets)
• src/hooks (data-fetching with TanStack Query)
• src/stores (Zustand for global state: user, check-in, toast, modal)
• src/pages (Home, About, UserSettings)
• src/schemas (Zod validation)
• Deployment/build files: package.json, tsconfig, vite.config.ts
Extract key insights from README
• Frontend: React, Zustand, TypeScript, TailwindCSS, Auth0 (JWT), React Hook Form + Zod, TanStack Query
• Backend: Node.js, Express.js, MongoDB
• External integrations: Auth0 for auth; an email/SMS service (e.g., Twilio or SendGrid)
Main components
a. Frontend Client
• Browser / React App (pages, components, Zustand stores, TanStack Query)
b. Authentication Service
• Auth0 (issues JWTs to the frontend; backend verifies JWT)
c. API Layer / Backend
• Express Server (server.ts → app.ts)
• Controllers (checkIn.controller, user.controller)
• Services (business logic)
• Repositories (data-access to MongoDB)
• Middleware (JWT validation, error handler)
d. Database
• MongoDB (collections: users, checkIns)
e. Notification Service
• External SMS/Email API (e.g., Twilio or SendGrid)
• Frontend → (1) Auth0 Login/Token Request
• Frontend (with JWT) → (2) API Requests → Backend Controllers
• Controllers → Services → Repositories → MongoDB
• Scheduled job or background task in Backend monitors check-in timestamps → (3) Notification Service
• Notification Service → Emergency Contacts (SMS or Email)
Architectural patterns and design principles
• Separation of concerns: Controllers vs. Services vs. Repositories
• API client abstraction on frontend (apiClient + typed endpoints)
• State management with Zustand + React Query for server state
• Schema validation with Zod at both ends
• JWT-based authentication via Auth0
• Internal layering of the backend (Controllers → Services → Repositories → DB)
• Data objects (User, CheckIn) next to the DB or repository
• Authentication flow: Auth0 ↔ Browser ↔ Backend (middleware)
• Technology choices (React, Express, MongoDB, Auth0, Twilio/SendGrid)