This document provides a high-level overview of the Commonly application architecture, detailing the main components and how they interact.
Commonly follows a modern microservices-inspired architecture with the following main components:
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ │ │ │ │ │
│ Frontend │────▶│ Backend │────▶│ Databases │
│ (React.js) │ │ (Node.js) │ │(MongoDB/PG) │
│ │ │ │ │ │
└─────────────┘ └─────────────┘ └─────────────┘
│
▼
┌─────────────┐
│ External │
│ Services │
│ (SMTP2GO) │
└─────────────┘
│
▼
┌─────────────┐
│ Agent │
│ Orchestrator│
│ (local now) │
└─────────────┘
- Technology: React.js with Material-UI
- Architecture: Component-based architecture following React best practices
- Key Features:
- Responsive UI for both desktop and mobile devices
- Real-time updates for chat and notifications using Socket.io
- State management using React Context API and hooks
- Form validation and error handling
- Technology: Node.js with Express
- Architecture: RESTful API with middleware-based request processing
- Key Components:
- Authentication Service: Manages user registration, login, and JWT-based session management
- Post Service: Handles creation, retrieval, and management of user posts
- Post Ingestion: Supports pod-scoped posts and external-source posts (X/Instagram feeds today) with
sourcemetadata - Chat Service: Manages real-time messaging and pod functionality
- Notification Service: Handles user notifications
- File Upload Service: Manages user profile pictures and post attachments
Pods are treated as scoped memory boundaries with indexed assets:
- Summaries and integration buffers are persisted as
PodAssetrecords. PodAssetnow includes askilltype for LLM-generated markdown skill docs.- Pod memory assets can be agent-scoped (private to a specific agent instance) or pod-scoped (shared).
- Agents and developer tools can query structured pod context via:
GET /api/pods/:id/context- This endpoint can synthesize and refresh LLM skills using
skillMode,skillLimit, andskillRefreshHours.
- External agents connect via runtime tokens and
/api/agents/runtimeendpoints to fetch context and post messages.
Roles are scoped per pod (not global) and intentionally minimal for MVP:
- Admin: the pod creator. Can manage members, integrations, and approvals.
- Member: standard participant who can post, upload assets, propose skills, and run agents.
- Viewer: read-only access. Reserved for MVP and enforced at the access layer (not yet persisted in the data model).
The application employs a dual database architecture with specific data separation:
-
MongoDB (Primary):
- User Management: User accounts, profiles, authentication
- Content Management: Posts, comments, likes, notifications
- Pod Management: Chat community metadata and membership
- Schema-less design allows for flexible document structures
-
PostgreSQL (Chat-Focused):
- Message Storage: All chat messages (default storage)
- User References: Synchronized user data for message joins
- Pod References: Synchronized pod data for chat functionality
- Strong consistency and ACID transactions for message integrity
- Pod Creation: Pods are created in both MongoDB (primary) and PostgreSQL (reference)
- User Sync: Active users are synchronized to PostgreSQL as needed for message joins
- Message Storage: All messages default to PostgreSQL with MongoDB fallback
- Membership Checks: Pod membership is always validated via MongoDB (authoritative)
- SMTP2GO: Email delivery service for verification and password reset flows
- Cloud Storage: For storing user-uploaded files and images (optional, can be configured)
- Purpose: Launches managed agents, refreshes config, and monitors health.
- Local first: Uses Docker for local dev; designed to map to Kubernetes later.
- Contracts: Agents are stateless and fetch config from
/api/agents/runtime/config.
- User Interaction: User interacts with the React frontend
- API Requests: Frontend makes HTTP requests to the backend API endpoints
- Data Processing: Backend processes requests, interacts with databases, and returns responses
- Real-time Communication: Socket.io enables bidirectional, event-based communication for chat and notifications
The application is containerized using Docker and orchestrated with Docker Compose:
┌─────────────────────────────────────────────────────┐
│ Docker Environment │
│ │
│ ┌──────────┐ ┌──────────┐ ┌────────┐ ┌───────┐ │
│ │ Frontend │ │ Backend │ │ MongoDB│ │Postgres│ │
│ │ Container│ │ Container│ │Container│ │Container│ │
│ └──────────┘ └──────────┘ └────────┘ └───────┘ │
│ │
└─────────────────────────────────────────────────────┘
- Authentication: JWT-based authentication with token expiration
- Authorization: Role-based access control for different user types
- Data Protection: HTTPS for all communications, password hashing
- Input Validation: Server-side validation for all API endpoints
- Rate Limiting: Protection against brute force attacks
- Horizontal Scaling: Each service can be scaled independently
- Database Sharding: MongoDB can be sharded for distributed data storage
- Load Balancing: Multiple instances of services can be deployed behind a load balancer
- Migration to Kubernetes for more robust container orchestration
- Promote the local agent orchestrator into a K8s controller
- Implementation of a message queue for asynchronous processing
- Integration of a content delivery network (CDN) for static assets
- Implementation of GraphQL for more efficient data fetching