How artiebears13/2024-2-vk-edu-frontend-a-medvedev works
Project type and purpose
• This repository is an educational monorepo (“2024-2-VK-EDU-Frontend-A-Medvedev”) containing three distinct front-end React/Vite or Webpack projects (exam, react-chat, simple-chat) plus a Node.js exercise (homework1).
• Each folder is a self-contained demo or assignment illustrating common front-end features: translation form (exam), real-time chat via Centrifugo (react-chat), vanilla JS chat (simple-chat), and algorithmic utilities (homework1).
File structure
• Top-level: .github (CI/CD), .husky (git hooks), root package.json (possibly for shared tooling), pull_request_template.md.
• exam: a TypeScript React/Vite translation app with Redux Toolkit, SCSS, and a call to an external translation API.
• react-chat: a full-blown React/Vite chat app using REST endpoints + Centrifugo WebSocket, Redux slices + middleware, SCSS modules, context, hooks.
• simple-chat: a lighter Webpack-based vanilla JS chat demo, SCSS for styling, a mock layer.
• homework1: Node.js scripts and Jest tests for pure-function exercises.
Readme insights
• Short description “Учебный проект” confirms this is a learning sandbox, no single unified service—each folder is its own mini-service.
a. Monorepo management layer
– CI/CD (.github/workflows), shared lint/pre-commit (.husky), shared package scripts.
b. Exam app
– Browser UI (React components → App.tsx)
– Redux store (translationSlice)
– TranslationService (utils/translate.ts) → external Translation API
– Assets & SCSS modules
c. React-chat app
– Browser UI (React components + pages)
– State management
• Redux store (chatSlice, messageSlice, userSlice)
• Middlewares: centrifugoMiddleware (WebSocket), notificationMiddleware
– API layer (src/api + src/apiTS)
• REST endpoints for users, chats, messages
• Centrifugo for real-time push
– Context/ErrorContext, custom hooks, mock layer for tests
– SCSS modules
d. Simple-chat app
– Browser UI (vanilla JS modules + SCSS)
– Mock WebSocket/REST service (in mocks)
– Webpack bundler
e. Homework1
– Node.js functions and test harness (Jest)
Relationships and interactions
• Monorepo root coordinates CI, lint, format across all sub-projects.
• Each subfolder is built & deployed independently:
• exam & react-chat use Vite → hot reload, dev server → production build
• simple-chat uses Webpack
• homework1 runs via Node/Jest CLI
• At runtime:
• exam → sends HTTP requests to Translation API → updates Redux store → re-renders UI
• react-chat → on load: REST “login/register” calls → store user → open WebSocket (Centrifugo) via middleware → dispatch inbound events → update UI → send outbound messages via REST or WS
• simple-chat → directly opens WebSocket / HTTP mocks → updates DOM
Architectural patterns & design principles
• exam: unidirectional data flow (React + Redux Toolkit), component isolation, SCSS modularization
• react-chat: Flux architecture (Redux slices + middleware), separation of concerns between API adapters & business logic, context for cross-cutting concerns (errors), custom hooks
• simple-chat: modular JS, MVC-like separation between view (chatWindow, chatList) and data (mocks)
• homework1: pure functions + test-driven design