Backend - peer-network/peer_backend GitHub Wiki

πŸ”§ Peer Network Backend

This page explains the architecture, responsibilities, and integration points of the peer_backend service β€” the core backend powering the Peer Network ecosystem.


πŸ› οΈ Tech Stack

Layer Tech
Language PHP 8.3
Framework Custom GraphQL Resolver Stack
DB PostgreSQL
Auth JWT-based token authentication
Blockchain Solana (via solana_client)

πŸ“¦ Responsibilities

The backend provides a GraphQL API that enables all user-facing operations:

βœ… User & Auth

  • Registration, login, logout, token refresh
  • Email verification and password reset
  • Profile management and updates

πŸ“ Content Management

  • Post creation, editing, deletion
  • Comment threading
  • Reporting, boosting, and moderation
  • Referral tracking (referralUuid)

πŸ’¬ Messaging

  • Private and group chat management
  • Participant and chatroom control

πŸͺ™ Wallet & Rewards

  • Balance tracking and token transfers
  • Reward logic based on interactions
  • Daily reward tracking and conversion
  • Referral-based earnings

πŸ” Integration Points

Integration Description
Mobile/Web Clients Consume the GraphQL API for all actions
Blockchain (Solana) Used for token minting/burning and balances
Referral System Tracked through registration and user profile
GraphQL Clients Compatible with Postman (suggested), Altair, GraphiQL

πŸ§ͺ Testing, CI & Development

Peer Network backend uses automated testing integrated with CI on every pull request.

βœ… Continuous Integration

  • CI is triggered automatically for each PR
  • Runs test suites and ensures no regression before merging
  • Postman-based API tests are included in the pipeline

βœ… API Testing

  • Core GraphQL API is tested using JavaScript + Postman
  • Covers key flows like registration, login, post actions, etc.

πŸ§ͺ Unit Testing

  • βœ… The entire wallet logic is covered by unit tests end-to-end
  • All components that could be isolated and mocked were tested thoroughly, thanks to how the wallet module was architected
  • Other modules (posts, transfers, referrals, etc.) currently have some logic tests, but they are not isolated and do not follow full unit test principles yet
  • Improving test coverage across the backend is a work in progress πŸ˜…

πŸ“ File Structure (Simplified)

/src
  β”œβ”€β”€ schema.graphl             # Authenticated schema
  β”œβ”€β”€ schemaguest.graphl        # Guest schema
  β”œβ”€β”€ admin_schema.graphl       # Admin-only schema
  β”œβ”€β”€ Resolver/                 # All GraphQL queries/mutations
  β”œβ”€β”€ Models/                   # User, Post, Wallet models
  β”œβ”€β”€ Services/                 # Business logic (WalletService, etc.)
  β”œβ”€β”€ Helpers/                  # Shared logic: validation, tokens

πŸ“¦ Versioning

We follow a semantic versioning strategy:

  • MAJOR β€” breaking architectural changes (e.g., token system redesign)
  • MINOR β€” new features (backend leads, frontends follow)
  • PATCH β€” local fixes that don’t require system-wide coordination

See full Backend Changelogs.


πŸ““ Related Pages