How rn1k/next-template works
Main Components
• Client Side (Next.js Frontend):
• Pages – Found under src/pages (e.g., _app.tsx, _document.tsx, index.tsx, sample.tsx)
• Containers – In src/containers (e.g., SampleContainer) which often organize stateful components.
• Components – In src/components (e.g., SampleComponent) which handle presentational UI elements.
• State Management:
• Redux – With reducers (under src/reducers) and actions (in src/actions) coordinating state changes.
• Sagas – Handling asynchronous flows in src/sagas.
• Store – Created in src/store.ts which ties together the reducers and sagas.
• Server Side (Custom Express Server):
• Found in src/server.js, responsible for launching the Next.js application with a custom Express server.
• Utility and Development Tools:
• Storybook – Configuration in .storybook and stories directories for UI component isolation.
• Testing – Jest configuration files (jest.config.js, jest.setup.js) for running unit tests.
• Configuration & Linting – Files such as tsconfig.json, tslint.json, Prettier and editor configs for code quality and consistency.
Representing Relationships and Interactions
• How the custom server (Express) acts as the entry point, initiating the Next.js application.
• Separation between frontend (UI components/pages/containers) and backend (custom server).
• Role of third-party libraries such as next-redux-wrapper, which integrates Redux with Next.js lifecycle methods.
• Incorporate developmental workflows—for instance, Storybook to test isolated UI states and Jest for unit testing.
Architectural Patterns and Design Principles
• MVC/Separation of Concerns: The division into pages (views), containers (controllers connecting state), and components (reusable UI elements).
• Middleware Pattern in Redux-Saga: Handling side effects and asynchronous actions.
• Custom Server Setup: How Next.js is enhanced with a custom Express server, enabling further backend customization.
• Code Quality Focus: Incorporation of ESLint/TSLint, Prettier, and TypeScript ensures maintainability and type safety.