S
API Service2026CompletedFeatured Project

Hackmate Server

HackMate Server Backend API server for HackMate - A terminal-based social network for developers and hackers. Tech Stack - Framework: Fastify (Node.js) - Database: MongoDB (with Mo...

RoleSole Developer
Classificationhigh
Client / ContextOpen Source Project
Development TimelineCompleted

Technical Architecture & Engineering Overview

Detailed system design and core implementation

The system is organized into three concentric layers. The API layer (src/api/controllers and src/api/routes) handles HTTP request routing, delegating to core services (core/services/*.service.ts) that encapsulate business rules such as authentication, matching, profile management, chat handling, network interactions, project lifecycle, group coordination, and notification processing. All services are pure TypeScript classes injected into controllers, enabling isolated unit testing.

The infrastructure layer (infrastructure/*) provides adapters for external resources: MongoDB models (infrastructure/database/models), Redis client configuration, and a dedicated Socket.IO service (infrastructure/socket/socket.service.ts). This layer abstracts persistence and real‑time messaging, allowing the core to remain agnostic of implementation details.

Data flow follows a clear path: client → Fastify → route → controller → service → repository/model → database. Validation occurs early using Zod schemas defined in shared/validators, guaranteeing type safety before business logic execution. Errors are funneled through a global error handler that normalizes validation errors, MongoDB duplicate key conflicts, JWT failures, and unexpected exceptions into consistent HTTP responses.

Security guardrails include Helmet for HTTP header hardening, CORS configuration, rate limiting via express-rate-limit (adapted for Fastify), and JWT verification middleware applied to all non‑auth routes. Passwords are hashed with Argon2, and OTP email verification leverages a centralized EmailService.

The build topology uses a standard TypeScript compilation pipeline (npm run build) producing JavaScript output consumed by src/start.ts. Development mode (npm run dev) employs hot‑reload, while production runs the compiled bundle with environment‑driven configuration. Health checks (GET /health) and a root status endpoint provide operational visibility.

System Diagrams & Flow Visualizations

Interactive Mermaid architecture & execution flows

Architectural Visualizer · System Architecture

Core System Features

Key capabilities & architectural features

FEATURE 01

Secure JWT + Argon2 authentication with email OTP verification

Secure JWT + Argon2 authentication with email OTP verification

FEATURE 02

User profile management with skills, bio, and social links

User profile management with skills, bio, and social links

FEATURE 03

Real‑time direct and group chat powered by Socket.IO

Real‑time direct and group chat powered by Socket.IO

FEATURE 04

Friend/network system with follow, request, accept, reject, and block actions

Friend/network system with follow, request, accept, reject, and block actions

FEATURE 05

Project posting, application workflow, and applicant management

Project posting, application workflow, and applicant management

FEATURE 06

Group creation, joining, invitation handling, and moderation

Group creation, joining, invitation handling, and moderation

FEATURE 07

Notification system with read/unread tracking and push via WebSocket

Notification system with read/unread tracking and push via WebSocket

FEATURE 08

Comprehensive admin panel for user, message, group, project, and activity management

Comprehensive admin panel for user, message, group, project, and activity management

FEATURE 09

Rate limiting, CORS, and Helmet security hardening

Rate limiting, CORS, and Helmet security hardening

FEATURE 010

Centralized Zod schema validation ensuring type‑safe request payloads

Centralized Zod schema validation ensuring type‑safe request payloads

Engineering Challenges & Solutions

Problem statements & resolution strategies

Challenge #1

Balancing RESTful API design with real‑time Socket.IO events required careful event naming and idempotency handling

Balancing RESTful API design with real‑time Socket.IO events required careful event naming and idempotency handling

Challenge #2

Managing MongoDB schema evolution without migrations introduced complexity in versioned data models

Managing MongoDB schema evolution without migrations introduced complexity in versioned data models

Challenge #3

Ensuring JWT token revocation for logout scenarios while maintaining statelessness

Ensuring JWT token revocation for logout scenarios while maintaining statelessness

Challenge #4

Configuring rate limiting that protects against abuse without degrading legitimate traffic

Configuring rate limiting that protects against abuse without degrading legitimate traffic

Challenge #5

Scaling Socket.IO connections in a serverless or containerized environment demands external session stores and load‑balancer sticky sessions

Scaling Socket.IO connections in a serverless or containerized environment demands external session stores and load‑balancer sticky sessions

API Reference & Endpoints

REST API surface & route documentation

METHODENDPOINT PATHDESCRIPTIONCOPY
GET/usersEndpoint defined in src/api/routes/admin.routes.ts
GET/users/:idEndpoint defined in src/api/routes/admin.routes.ts
DELETE/users/:idEndpoint defined in src/api/routes/admin.routes.ts
PUT/users/:idEndpoint defined in src/api/routes/admin.routes.ts
GET/statsEndpoint defined in src/api/routes/admin.routes.ts
GET/messagesEndpoint defined in src/api/routes/admin.routes.ts
GET/messages/user/:userIdEndpoint defined in src/api/routes/admin.routes.ts
DELETE/messages/:idEndpoint defined in src/api/routes/admin.routes.ts
GET/groupsEndpoint defined in src/api/routes/admin.routes.ts
GET/groups/:idEndpoint defined in src/api/routes/admin.routes.ts
DELETE/groups/:idEndpoint defined in src/api/routes/admin.routes.ts
GET/projectsEndpoint defined in src/api/routes/admin.routes.ts
GET/projects/:idEndpoint defined in src/api/routes/admin.routes.ts
DELETE/projects/:idEndpoint defined in src/api/routes/admin.routes.ts
GET/friend-requestsEndpoint defined in src/api/routes/admin.routes.ts
DELETE/friend-requests/:idEndpoint defined in src/api/routes/admin.routes.ts
GET/notificationsEndpoint defined in src/api/routes/admin.routes.ts
DELETE/notifications/:idEndpoint defined in src/api/routes/admin.routes.ts
GET/activityEndpoint defined in src/api/routes/admin.routes.ts
GET/searchEndpoint defined in src/api/routes/admin.routes.ts
GET/history/:userIdEndpoint defined in src/api/routes/chat.routes.ts
GET/history/group/:groupIdEndpoint defined in src/api/routes/chat.routes.ts
GET/conversationsEndpoint defined in src/api/routes/chat.routes.ts
POST/Endpoint defined in src/api/routes/group.routes.ts
GET/Endpoint defined in src/api/routes/group.routes.ts
GET/:idEndpoint defined in src/api/routes/group.routes.ts
POST/:id/joinEndpoint defined in src/api/routes/group.routes.ts
POST/:id/acceptEndpoint defined in src/api/routes/group.routes.ts
POST/:id/rejectEndpoint defined in src/api/routes/group.routes.ts
POST/:id/kickEndpoint defined in src/api/routes/group.routes.ts
POST/:id/leaveEndpoint defined in src/api/routes/group.routes.ts
POST/requestEndpoint defined in src/api/routes/network.routes.ts
GET/requestsEndpoint defined in src/api/routes/network.routes.ts
POST/acceptEndpoint defined in src/api/routes/network.routes.ts
POST/rejectEndpoint defined in src/api/routes/network.routes.ts
GET/friendsEndpoint defined in src/api/routes/network.routes.ts
POST/blockEndpoint defined in src/api/routes/network.routes.ts
DELETE/friend/:userIdEndpoint defined in src/api/routes/network.routes.ts
POST/:id/readEndpoint defined in src/api/routes/notification.routes.ts
POST/:id/applyEndpoint defined in src/api/routes/project.routes.ts
DELETE/:idEndpoint defined in src/api/routes/project.routes.ts
GET/healthEndpoint defined in src/app.ts

Key Code Modules & Architecture

Core file entrypoints and service responsibilities

ScriptsMODULE 01
scripts

Module component managing scripts source logic

SrcMODULE 02
src

Module component managing src source logic

ApiMODULE 03
src/api

Module component managing api source logic

ControllersMODULE 04
src/api/controllers

Module component managing controllers source logic

RoutesMODULE 05
src/api/routes

Module component managing routes source logic

ConfigMODULE 06
src/config

Module component managing config source logic

CoreMODULE 07
src/core

Module component managing core source logic

ServicesMODULE 08
src/core/services

Module component managing services source logic

ModelsMODULE 09
src/infrastructure/database/models

Module component managing models source logic

TypesMODULE 010
src/types

Module component managing types source logic

UtilsMODULE 011
src/shared/utils

Module component managing utils source logic

User Journey Pipeline

  1. 1User Access & Preset Selection: User opens client interface and configures request parameters or task workflow presets.
  2. 2Client Payload Dispatch: Front-end components (React) serialize input objects and send HTTP/WebSocket requests to `/users`.
  3. 3Middleware & Validation Check: API Gateway evaluates CORS headers, authorization tokens, and input validation schemas.
  4. 4Service & Inference Execution: Service controllers dispatch request frames to model inference engine (Local Engine) or storage layer.
  5. 5Response Delivery & State Synchronization: Serialized output payload is returned to the client and rendered in the visual workspace.

Execution Code Flow

  1. 1Client or caller initiates request to application entrypoint
  2. 2Backend router validates request parameters and applies middleware
  3. 3Database ORM/client executes storage query
  4. 4Application serializes JSON/audio/data response back to client

System FAQ & Technical Specifications

Frequently asked questions and core architecture details

Q: What technologies are used in Hackmate Server?

Hackmate Server is engineered using modern full-stack frameworks.

Q: What core engineering problem does Hackmate Server solve?

HackMate Server Backend API server for HackMate - A terminal-based social network for developers and hackers. Tech Stack - Framework: Fastify (Node.js) - Database: MongoDB (with Mo...

Q: How is 'Balancing RESTful API design with real‑time Socket.IO events required careful event naming and idempotency handling' resolved in Hackmate Server?

Resolved through specialized system architecture and resilient state handling.

Related Systems & Case Studies

Explore similar technical architectures and projects

View All Systems