How florianrappl/typescript-fullstack-sample works
Project Type and Purpose
• This is a minimal “universal” (isomorphic) full-stack web application sample built with TypeScript, Node.js, and React.
• It demonstrates client-side rendering (CSR), server-side rendering (SSR), hydration, and a shared global state container without external state libraries like Redux.
File-Structure Analysis
• Top-level files:
• package.json / package-lock.json: npm scripts and dependencies
• Dockerfile, .gitignore, .editorconfig, prettier.config.js: environment/configuration
• webpack.config.js: orchestrates building both client and server bundles
• tsconfig.json, tsconfig.client.json, tsconfig.server.json: TypeScript configuration for different targets
• src/client: entry point for the browser bundle (createView.tsx, index.ts)
• src/server: Node.js server logic (index.ts), SSR renderer (renderIndex.ts), asset retrieval (retrieveAsset.ts), server-side view creator (createView.tsx)
• src/common: shared React components, pages, actions, types, and global state container
README Insights
• Confirms it is a sample showing universal rendering, hydration, and shared state
• Notes excluded topics (live reload, styling, Redux) to keep the example focused and minimal
Main Architectural Components
a. Client Application (Browser)
• React entry point (client/index.ts)
• View creator (client/createView.tsx) that hydrates the server-rendered markup
• Bundle produced by webpack for browser consumption
b. Server Application (Node.js)
• HTTP server (server/index.ts) that handles incoming requests
• SSR engine (server/renderIndex.ts) using the shared React App to output HTML
• Static asset handler (server/retrieveAsset.ts) serving JS/CSS bundles from disk
• Bundle produced by webpack for Node.js execution
c. Shared Library (Isomorphic Code)
• src/common/App.tsx: top-level React component used in both environments
• Pages (HomePage, TodoPage, etc.) and UI components (CenterInfo)
• Global state container (actions.ts, state.ts) and TypeScript types
d. Build System
• webpack.config.js defines two targets: “client” (browser) and “server” (Node)
• TypeScript compilers: separate configs for client and server to manage module resolution and JSX emitting
Relationships and Data Flow
1. Developer runs “npm run build” → webpack outputs:
– client.bundle.js (for browsers)
– server.bundle.js (for Node.js SSR)
2. Developer runs “npm start” → Node.js loads server.bundle.js and listens on port 3000
3. Browser requests “/” → Node server.renderIndex() uses the shared App to generate HTML + initial state → responds with HTML embedding client.bundle.js and serialized state
4. Browser downloads client.bundle.js → client.createView() hydrates the server-rendered markup, bootstraps the shared global state container, and enables CSR thereafter
5. Further client interactions update the shared state container; if needed, the client can also call new server endpoints (not implemented in this sample, but typical in a full-featured app)
Architectural Patterns and Principles
• Universal (isomorphic) rendering for optimal SEO and faster first paint
• Clear separation of concerns:
• Server concerns (HTTP handling, SSR)
• Client concerns (hydration, UI interactions)
• Shared concerns (React components, state management)
• Single global state store without Redux, demonstrating a lightweight custom solution
• Build-time and run-time separation via webpack and tsconfig targets