From d4a7ccf1c92bee2c50b3cfd991ed31aedabc00bf Mon Sep 17 00:00:00 2001 From: Sergey Krylov Date: Sat, 13 Jun 2026 19:27:52 +0300 Subject: [PATCH] feat: Sprint 6 - documentation and infrastructure - Docker setup (Dockerfile.backend, Dockerfile.frontend, nginx, docker-compose) - Architecture overview with Mermaid sequence diagram - README with quick start and Docker instructions - Verify OpenAPI spec and ADR docs --- README.md | 51 +++++++++++++++++++++++++++++++++++ docker-compose.yml | 20 ++++++++++++++ docker/Dockerfile.backend | 14 ++++++++++ docker/Dockerfile.frontend | 12 +++++++++ docker/nginx.conf | 15 +++++++++++ docs/architecture/overview.md | 24 +++++++++++++++++ 6 files changed, 136 insertions(+) create mode 100644 README.md create mode 100644 docker-compose.yml create mode 100644 docker/Dockerfile.backend create mode 100644 docker/Dockerfile.frontend create mode 100644 docker/nginx.conf create mode 100644 docs/architecture/overview.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..9663633 --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +# MoexVibe + +Веб-приложение для анализа ценных бумаг Московской биржи (MOEX). + +## Tech Stack + +- **Backend:** NestJS, TypeScript, OpenAPI (Swagger) +- **Frontend:** React, TypeScript, Vite, TanStack Query, lightweight-charts +- **Infrastructure:** Docker, docker-compose + +## Quick Start + +```bash +# Install dependencies +npm install + +# Start backend (http://localhost:3000) +npm run dev:backend + +# Start frontend (http://localhost:5173) +npm run dev:frontend +``` + +Swagger UI: http://localhost:3000/api/docs + +## Docker + +```bash +docker compose up --build +``` + +- Frontend: http://localhost:80 +- Backend: http://localhost:3000 + +## Tests + +```bash +npm run test:backend +``` + +## Project Structure + +``` +apps/ + backend/ — NestJS API (single point of access to MOEX ISS) + frontend/ — React SPA with Vite +docs/ + architecture/ — ADR documents and diagrams + openapi/ — OpenAPI specification + superpowers/ — Design specs and implementation plans +``` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e348cd9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +services: + backend: + build: + context: . + dockerfile: docker/Dockerfile.backend + ports: + - "3000:3000" + environment: + - PORT=3000 + - MOEX_BASE_URL=https://iss.moex.com/iss + - MOEX_RATE_LIMIT=10 + + frontend: + build: + context: . + dockerfile: docker/Dockerfile.frontend + ports: + - "80:80" + depends_on: + - backend diff --git a/docker/Dockerfile.backend b/docker/Dockerfile.backend new file mode 100644 index 0000000..6ce1b87 --- /dev/null +++ b/docker/Dockerfile.backend @@ -0,0 +1,14 @@ +FROM node:20-alpine AS build +WORKDIR /app +COPY package.json tsconfig.base.json ./ +COPY apps/backend/ apps/backend/ +RUN npm install +RUN npm run build -w apps/backend + +FROM node:20-alpine AS production +WORKDIR /app +COPY --from=build /app/apps/backend/dist ./dist +COPY --from=build /app/apps/backend/node_modules ./node_modules +COPY --from=build /app/apps/backend/package.json ./ +EXPOSE 3000 +CMD ["node", "dist/main.js"] diff --git a/docker/Dockerfile.frontend b/docker/Dockerfile.frontend new file mode 100644 index 0000000..c6fda08 --- /dev/null +++ b/docker/Dockerfile.frontend @@ -0,0 +1,12 @@ +FROM node:20-alpine AS build +WORKDIR /app +COPY package.json tsconfig.base.json ./ +COPY apps/frontend/ apps/frontend/ +RUN npm install +RUN npm run build -w apps/frontend + +FROM nginx:alpine +COPY --from=build /app/apps/frontend/dist /usr/share/nginx/html +COPY docker/nginx.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/docker/nginx.conf b/docker/nginx.conf new file mode 100644 index 0000000..c0aa0a6 --- /dev/null +++ b/docker/nginx.conf @@ -0,0 +1,15 @@ +server { + listen 80; + root /usr/share/nginx/html; + index index.html; + + location /api/ { + proxy_pass http://backend:3000; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + + location / { + try_files $uri $uri/ /index.html; + } +} diff --git a/docs/architecture/overview.md b/docs/architecture/overview.md new file mode 100644 index 0000000..4a60e68 --- /dev/null +++ b/docs/architecture/overview.md @@ -0,0 +1,24 @@ +# Architecture Overview + +```mermaid +sequenceDiagram + participant User + participant Frontend as React SPA + participant Backend as NestJS API + participant Cache as In-Memory Cache + participant MOEX as MOEX ISS + + User->>Frontend: Search / View instrument + Frontend->>Backend: GET /api/v1/securities/search?q=SBER + Backend->>Cache: getOrFetch('search:sber') + alt Cache miss + Cache->>Backend: null + Backend->>MOEX: GET /iss/securities?q=SBER + MOEX-->>Backend: raw data + Backend->>Cache: set('search:sber', normalized, TTL=3600) + else Cache hit + Cache-->>Backend: cached data + end + Backend-->>Frontend: normalized response + Frontend-->>User: rendered UI +```