# erikpeik/matcha architecture

> Architecture diagram of the GitHub repository erikpeik/matcha, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/erikpeik/matcha
- Repository: https://github.com/erikpeik/matcha

## Overview

##### Project Type and Purpose
- This is a full-stack, real-time web application (“Matcha” dating site) built with React/Redux on the frontend, Node.js/Express on the backend, PostgreSQL for persistence, and Socket.IO for live chat/notifications. Docker and Docker Compose orchestrate four services: client, server, database, and a seed/script helper.

##### File Structure Analysis
- Top-level:
- client/ – React single-page app (components, Redux store, services, static assets)
- server/ – Express app (index.js, Dockerfile, routes/, static image serving via Multer)
- db/ – SQL schema and seed scripts for PostgreSQL
- script/ – Standalone Dockerized script (create_users.js) for test-data or seeding
- docker-compose.yml – composes client, server, PostgreSQL, (and optionally script)
- Key patterns:
- Frontend: Redux for state, React Router for navigation, Axios + Socket.IO client for API and WebSocket
- Backend: Express routes per feature (auth, browsing, chat, profile, notifications), Socket.IO server, uses Multer for image uploads, Nodemailer for email
- Database: PostgreSQL functions (e.g., distance calculation), multiple tables initialized via SQL

##### README Insights
- Confirms real-time updates via Socket.IO, explains features (signup/verification, profile setup, browsing algorithm, chat rooms, notifications), lists tech stack.

- Browser/Client (React + Redux + Material UI)
- API Gateway/Backend Service (Node.js + Express + Socket.IO)
- Database (PostgreSQL)
- Seeding Script Service (script/create_users.js)
- External Services:
- SMTP Server (for email verification)
- Geolocation API (IPApi fallback)
1. Browser ↔ Express REST API (Axios): signup, login, profile, browsing, likes, notifications fetch
2. Browser ↔ Express WebSocket (Socket.IO): real-time chat rooms, notification channels
3. Express ↔ PostgreSQL: queries for users, profiles, tags, messages, notifications
4. Express → SMTP Service: send verification & fake-report emails
5. Express → IPApi: fetch coordinates if browser geolocation denied
6. Script Service → PostgreSQL or Express API: bulk-create or seed test users
7. Express → Static File Store: serve/upload user images via Multer
c. Architectural Patterns & Principles
- Micro-service/container architecture via Docker Compose
- Unidirectional data flow on frontend (React→Redux→React)
- REST for CRUD operations + WebSocket for events
- Separation of concerns: routing, business logic, data access
d. Key Technologies
- Frontend: React, Redux, React Router, Axios, Socket.IO client, Material UI
- Backend: Node.js, Express, Socket.IO server, Multer, Nodemailer
- Database: PostgreSQL
- Orchestration: Docker, Docker Compose

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Docker Compose Network"
        subgraph "Frontend Container"
            A1["React SPA"]:::frontend
            A2["Redux Store"]:::frontend
            A3["React Router"]:::frontend
            A4["API & WS Client Services"]:::frontend
        end

        subgraph "Backend Container"
            B1["Express API + Socket.IO"]:::backend
            subgraph "Routes"
                B2["signup.js"]:::backend
                B3["login_logout.js"]:::backend
                B4["resetpassword.js"]:::backend
                B5["profile.js"]:::backend
                B6["browsing.js"]:::backend
                B7["chat.js"]:::backend
                B8["chat_api.js"]:::backend
                B9["notification.js"]:::backend
            end
            B10["Static File Store (Multer)"]:::backend
        end

        C1[(PostgreSQL DB)]:::db
        C2["Seeding Script Service"]:::script
        C3[(SMTP Server)]:::external
        C4[(IPApi Geolocation)]:::external
    end

    A1 -->|"HTTP/HTTPS JSON"| B1
    A1 <-->|"WS/WSS JSON"| B1
    B1 -->|"SQL"| C1
    B1 -->|"SMTP"| C3
    B1 -->|"HTTP JSON"| C4
    C2 -->|"SQL"| C1
    C2 -->|"HTTP JSON"| B1
    B1 -->|"Multipart/Form-Data"| B10

    click A1 "https://github.com/erikpeik/matcha/blob/master/client/src/App.js"
    click A2 "https://github.com/erikpeik/matcha/blob/master/client/src/store.js"
    click A3 "https://github.com/erikpeik/matcha/blob/master/client/src/components/RedirectPage.js"
    click A4 "https://github.com/erikpeik/matcha/blob/master/client/src/services/chatService.js"
    click B1 "https://github.com/erikpeik/matcha/blob/master/server/index.js"
    click B2 "https://github.com/erikpeik/matcha/blob/master/server/routes/signup.js"
    click B3 "https://github.com/erikpeik/matcha/blob/master/server/routes/login_logout.js"
    click B4 "https://github.com/erikpeik/matcha/blob/master/server/routes/resetpassword.js"
    click B5 "https://github.com/erikpeik/matcha/blob/master/server/routes/profile.js"
    click B6 "https://github.com/erikpeik/matcha/blob/master/server/routes/browsing.js"
    click B7 "https://github.com/erikpeik/matcha/blob/master/server/routes/chat.js"
    click B8 "https://github.com/erikpeik/matcha/blob/master/server/routes/chat_api.js"
    click B9 "https://github.com/erikpeik/matcha/blob/master/server/routes/notification.js"
    click B10 "https://github.com/erikpeik/matcha/tree/master/server/images/"
    click C2 "https://github.com/erikpeik/matcha/blob/master/script/create_users.js"
    click D1 "https://github.com/erikpeik/matcha/blob/master/docker-compose.yml"

    classDef frontend fill:#D6EAF8,stroke:#1B4F72
    classDef backend fill:#D5F5E3,stroke:#196F3D
    classDef db fill:#FCF3CF,stroke:#9A7D0A
    classDef script fill:#EBDEF0,stroke:#6C3483
    classDef external fill:#D7DBDD,stroke:#616A6B
```
