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
- π Home
- π¬ GraphQL Schema Overview
- π» Clients
- π Versioning
- π Changelogs