How trademebooks/trademebooks-web works
Project Type and Purpose
• This is a full-stack, single-page web application called trademebooks.com (TMB).
• Frontend: React/Redux SPA served from the Node.js server (or CDN in production).
• Backend: Node.js + Express REST API implementing domain-driven layers (controllers, services, repositories).
• Database: MongoDB (Atlas).
• External Services: OAuth providers (Facebook, Google, GitHub, LinkedIn, Twitter), SendGrid (email), Twilio (SMS).
• Deployment: Heroku, with CI/CD via CircleCI and GitHub Actions.
File Structure Highlights
• Top-level “client” and “api” folders separate frontend and backend.
• “api”:
• config: environment configuration, passport OAuth strategies.
• controllers ↔ routes: Express endpoints calling controllers.
• domain: DDD layers – models (Mongoose schemas), repositories (DB access), services (business logic), events, DTOs.
• middleware: auth, permissions, global handlers.
• utils: error handling, DB connection.
• tests & seeds: automated tests and seed scripts.
• “client”:
• src/components: React components organized by feature (auth, books, chat, account, UI layout).
• src/actions, src/reducers, src/store.js: Redux data flow.
• src/config: client env config.
• src/utils/api.js: centralized API client.
• setupProxy.js: local CORS/proxy config.
• tests co-located with components.
Key Insights from README
• Emphasizes social SSO, profile/bookstore, chat/messaging, auto-complete book metadata.
• Tech stack: ReactJS, Redux, Node.js, Express, MongoDB, Passport.js, SendGrid, Twilio, Heroku.
• Dev flow: local dev server on :3000 proxying API on :5000; Docker option for Mongo; CI with linting, tests, auto-deploy on master.
Components
a. Client-side (React/Redux SPA)
• UI Components (Pages, Forms, Chat UI, Bookstore pages)
• Redux Store & Thunks / Actions
• API Client (axios/fetch layer)
b. Server-side (Express API)
• HTTP Layer: Routes → Controllers
• Domain Layer: Controllers → Services → Repositories → MongoDB
• Middleware: Authentication, Authorization, Validation, Error Handling
• Passport.js (multiple OAuth strategies)
c. Database
• MongoDB Atlas cluster (collections: users, books, bookstores, chats, messages, sessions, passwords)
d. External Services
• OAuth Providers (Facebook, Google, GitHub, LinkedIn, Twitter)
• SendGrid (email templates: registration, password reset)
• Twilio (SMS notifications)
e. Infrastructure & DevOps
• Heroku (web dyno, environment configs)
• CI/CD: CircleCI & GitHub Actions
• Monitoring: Uptime Robot, Codecov
Relationships & Data Flows
• Browser → (HTTPS) → React App (served by Express or CDN)
• React Components dispatch Redux Actions → async API calls via api.js → Express REST Endpoints (e.g., POST /api/v1/auth/login)
• Express middleware (auth, validation) → Controllers
• Controller invokes Domain Service → Repository → MongoDB
• Domain Service may emit Events (e.g., userRegistered) → trigger email/SMS services
• External OAuth redirects: Browser ↔ OAuth Provider ↔ Express callback route → create session/JWT
• SendGrid/Twilio usage: Service layer calls external API
Architectural Patterns & Principles
• Layered architecture (HTTP → Controller → Service → Repository → DB)
• DDD (domain models, DTOs, events)
• Single-Page Application + API backend
• Externalization of cross-cutting concerns via middleware
• Feature-based modularization on client side
• CI/CD and environment-based configuration
2. Client on the left, Server in the center (top to bottom: HTTP, Controllers, Services, Repositories), DB on the right, External services above/below the Server.
6. Review with domain experts to ensure every significant module (e.g., passport strategies, DTOs, event bus) is represented.