# parpa-123/collab-hub architecture

> Architecture diagram of the GitHub repository parpa-123/collab-hub, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/parpa-123/collab-hub
- Repository: https://github.com/parpa-123/collab-hub

## Overview

CollabHub is a monorepo with three main runtime surfaces: a React frontend, a Django REST backend, and a small Python CLI. The overall system is designed to behave like a lightweight GitHub clone, with the backend owning all persistent domain logic and the frontend acting as a thin interactive client.

The deployment boundary is simple and important for the architecture diagram: Nginx is the public entrypoint, serving the built SPA at `/`, forwarding `/api/` and `/admin/` into the Django app, and serving static assets. Django runs behind Gunicorn, with Redis used by Celery for asynchronous work. Docker Compose ties these services together for production-style single-node deployment.

The frontend is a Vite/React/TypeScript SPA. Its structure is feature-oriented rather than deeply layered: repository browsing, pull request review, issues, notifications, profiles, and dashboard views all live under `frontend/src/components`. Cross-cutting state is handled with React contexts for authentication, theme, and toasts. The frontend talks only to the backend API via an Axios client with token refresh logic.

The backend is a Django project split into domain apps rather than a single monolith module. The most important apps are `repositories`, `branches`, `storage`, `PullRequest`, `comments`, `issues`, `activity`, `notifications`, and `accounts`. `config` contains project-wide wiring: URL routing, settings, Celery integration, and a small event system used to decouple side effects.

`accounts` owns identity and access entrypoints. It contains the custom user model, OAuth/social login support, JWT integration, and middleware/adapters around authentication behavior. This subsystem is the trust boundary for the rest of the API: the other apps assume a validated user context and then apply repository-level permissions on top.

`repositories` is the core aggregate boundary. It manages repository CRUD, membership, visibility, file metadata, and permission enforcement. Other domain objects are usually scoped to a repository slug, so this app acts as the hub for most user-facing workflows and the main route namespace in the API.

Version-control behavior is split across `branches` and `storage`. `branches` models branches, commits, and branch ancestry, while `storage` provides content-addressable blob and tree services. That separation matters: `branches` describes version history, and `storage` describes how file contents and directory structures are stored and reused across commits. The backend’s diff-related services also live under `storage/services`, indicating that file comparison is treated as a reusable infrastructure concern.

Pull request workflow is concentrated in `PullRequest`. This app owns PR lifecycle, review state, merge eligibility, base commit tracking, and precomputed diffs. The readme and tree together indicate a two-phase diff model: a PR is created and then a Celery task computes its diff asynchronously, storing status so the UI can show pending/processing/completed/failed states.

Comments are a cross-cutting subsystem, but the data model is unified. The `comments` app uses Django content types so a single comment model can attach to pull requests, reviews, commits, and issues. It also supports threaded replies and inline diff comments via path/line/side metadata, which makes it a shared discussion layer rather than a feature-specific one.

Issues are handled in the `issues` app, with labels and assignee relationships scoped per repository. The design suggests issue state is fully backend-owned, with the frontend mostly rendering filtered lists and detail views. This subsystem ties directly into repository context and activity logging.

`activity` and `notifications` form the event-output layer. `activity` records repository-visible actions into a feed with actor, verb, and object references, while `notifications` creates user-facing alerts and unread state. Both appear to be driven by handlers/signals plus Celery tasks, so they react to changes made by other domain apps instead of being called directly from the UI.

The eventing boundary is explicit in `config/events` and in app-level `signals.py`/`handlers.py` files. That suggests a lightweight internal event bus used to dispatch side effects such as activity records, notifications, and diff or review-related follow-up work. This keeps domain mutations separated from secondary actions and is important when drawing data flow arrows.

The CLI is a separate client surface, not part of the web app. It provides git-like commands such as init, add, commit, pull, and push, and likely communicates with the backend API for repository workflows. Architecturally, it is another consumer of the same backend domain services as the browser, just with a command-line UX.

Persistent storage is backed by Django migrations across each app, with SQLite or PostgreSQL depending on environment. The readme also points out WhiteNoise/static handling and trigram indexes in places like accounts and repositories, which indicates the backend is optimized for self-hosted, small-instance deployment but still supports text search and readable slugs.

In diagram form, the main data flow is: browser or CLI sends authenticated requests to Django; Django applies repository and account permissions; domain apps mutate repository/branch/PR/issue/comment state; signals/events trigger activity and notification side effects; Celery processes asynchronous jobs like diff computation and notification delivery; the frontend then reads the updated API state and renders repository-centric views.

Main entry points: [`backend/config/urls.py`](https://github.com/parpa-123/collab-hub/blob/main/backend/config/urls.py) (Django API), [`backend/config/events/dispatcher.py`](https://github.com/parpa-123/collab-hub/blob/main/backend/config/events/dispatcher.py) (Events), [`backend/repositories/models.py`](https://github.com/parpa-123/collab-hub/blob/main/backend/repositories/models.py) (Repositories), [`backend/PullRequest/models.py`](https://github.com/parpa-123/collab-hub/blob/main/backend/PullRequest/models.py) (Pull Requests)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_deployment["Deployment"]
  node_nginx["Nginx<br/>reverse proxy<br/>[nginx.conf]"]
  node_compose["Compose<br/>orchestration<br/>[docker-compose.yml]"]
  node_gunicorn["Gunicorn<br/>app server"]
  node_redis[("Redis<br/>broker/cache")]
end

subgraph group_frontend["Frontend"]
  node_spa["React SPA<br/>frontend app<br/>[main.tsx]"]
  node_client_state(("Client State<br/>react contexts<br/>[userContext.tsx]"))
  node_api_client["API Client<br/>axios client<br/>[connect.ts]"]
  node_repo_ui["Repo Views<br/>feature UI<br/>[Repo.tsx]"]
  node_profile_dash["Profiles & Dashboard<br/>feature UI<br/>[Dashboard.tsx]"]
end

subgraph group_backend["Backend"]
  node_django["Django API<br/>web backend<br/>[urls.py]"]
  node_accounts["Accounts<br/>identity<br/>[models.py]"]
  node_repositories["Repositories<br/>core domain<br/>[models.py]"]
  node_versioning["Version Control<br/>domain split<br/>[models.py]"]
  node_pulls["Pull Requests<br/>workflow<br/>[models.py]"]
  node_discussions["Comments<br/>discussion<br/>[models.py]"]
  node_issues["Issues<br/>tracker<br/>[models.py]"]
  node_feed["Activity<br/>event feed<br/>[models.py]"]
  node_alerts["Notifications<br/>alerts<br/>[models.py]"]
  node_events(("Events<br/>internal bus<br/>[dispatcher.py]"))
  node_celery["Celery Jobs<br/>async worker<br/>[tasks.py]"]
end

subgraph group_cli["CLI"]
  node_cli_app["CLI<br/>[main.py]"]
end

node_compose -->|"starts"| node_nginx
node_compose -->|"starts"| node_gunicorn
node_compose -->|"starts"| node_redis
node_nginx -->|"serves"| node_spa
node_nginx -->|"routes /api /admin"| node_gunicorn
node_spa -->|"uses"| node_client_state
node_spa -->|"calls"| node_api_client
node_api_client -->|"HTTP API"| node_django
node_cli_app -->|"HTTP API"| node_django
node_django -->|"authenticates"| node_accounts
node_django -->|"routes"| node_repositories
node_django -->|"routes"| node_versioning
node_django -->|"routes"| node_pulls
node_django -->|"routes"| node_discussions
node_django -->|"routes"| node_issues
node_django -->|"routes"| node_feed
node_django -->|"routes"| node_alerts
node_repositories -->|"scopes"| node_versioning
node_repositories -->|"scopes"| node_issues
node_repositories -->|"scopes"| node_pulls
node_pulls -->|"uses"| node_discussions
node_issues -->|"uses"| node_discussions
node_versioning -->|"queues diffs"| node_celery
node_pulls -->|"queues diff work"| node_celery
node_events -->|"triggers"| node_feed
node_events -->|"triggers"| node_alerts
node_accounts -->|"emits"| node_events
node_repositories -->|"emits"| node_events
node_pulls -->|"emits"| node_events
node_issues -->|"emits"| node_events
node_discussions -->|"emits"| node_events
node_celery -->|"brokers on"| node_redis

click node_nginx "https://github.com/parpa-123/collab-hub/blob/main/frontend/nginx.conf"
click node_compose "https://github.com/parpa-123/collab-hub/blob/main/docker-compose.yml"
click node_gunicorn "https://github.com/parpa-123/collab-hub/tree/main/backend/Dockerfile"
click node_spa "https://github.com/parpa-123/collab-hub/blob/main/frontend/src/main.tsx"
click node_client_state "https://github.com/parpa-123/collab-hub/blob/main/frontend/src/Context/userContext.tsx"
click node_api_client "https://github.com/parpa-123/collab-hub/blob/main/frontend/src/axios/connect.ts"
click node_repo_ui "https://github.com/parpa-123/collab-hub/blob/main/frontend/src/components/Repo.tsx"
click node_profile_dash "https://github.com/parpa-123/collab-hub/blob/main/frontend/src/components/Dashboard.tsx"
click node_django "https://github.com/parpa-123/collab-hub/blob/main/backend/config/urls.py"
click node_accounts "https://github.com/parpa-123/collab-hub/blob/main/backend/accounts/models.py"
click node_repositories "https://github.com/parpa-123/collab-hub/blob/main/backend/repositories/models.py"
click node_versioning "https://github.com/parpa-123/collab-hub/blob/main/backend/branches/models.py"
click node_pulls "https://github.com/parpa-123/collab-hub/blob/main/backend/PullRequest/models.py"
click node_discussions "https://github.com/parpa-123/collab-hub/blob/main/backend/comments/models.py"
click node_issues "https://github.com/parpa-123/collab-hub/blob/main/backend/issues/models.py"
click node_feed "https://github.com/parpa-123/collab-hub/blob/main/backend/activity/models.py"
click node_alerts "https://github.com/parpa-123/collab-hub/blob/main/backend/notifications/models.py"
click node_events "https://github.com/parpa-123/collab-hub/blob/main/backend/config/events/dispatcher.py"
click node_celery "https://github.com/parpa-123/collab-hub/blob/main/backend/PullRequest/tasks.py"
click node_cli_app "https://github.com/parpa-123/collab-hub/blob/main/cli/main.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_nginx,node_compose,node_gunicorn,node_redis toneBlue
class node_spa,node_client_state,node_api_client,node_repo_ui,node_profile_dash toneAmber
class node_django,node_accounts,node_repositories,node_versioning,node_pulls,node_discussions,node_issues,node_feed,node_alerts,node_events,node_celery toneMint
class node_cli_app toneRose
```

## Components

### Deployment

Public entrypoint and runtime orchestration

- [Nginx](https://github.com/parpa-123/collab-hub/blob/main/frontend/nginx.conf): reverse proxy · Public entrypoint serving SPA, static assets, and API/admin routing · `frontend/nginx.conf`
- [Compose](https://github.com/parpa-123/collab-hub/blob/main/docker-compose.yml): orchestration · Single-node service wiring for production-style deployment · `docker-compose.yml`
- [Gunicorn](https://github.com/parpa-123/collab-hub/tree/main/backend/Dockerfile): app server · WSGI process running the Django app · `backend/Dockerfile`
- **Redis**: broker/cache · Celery broker and async work backend

### Frontend

React SPA and client-side state

- [React SPA](https://github.com/parpa-123/collab-hub/blob/main/frontend/src/main.tsx): frontend app · Vite/React/TypeScript browser client · `frontend/src/main.tsx`
- [Client State](https://github.com/parpa-123/collab-hub/blob/main/frontend/src/Context/userContext.tsx): react contexts · Auth, theme, and toast cross-cutting UI state · `frontend/src/Context/userContext.tsx`
- [API Client](https://github.com/parpa-123/collab-hub/blob/main/frontend/src/axios/connect.ts): axios client · Token-aware HTTP client used by the SPA · `frontend/src/axios/connect.ts`
- [Repo Views](https://github.com/parpa-123/collab-hub/blob/main/frontend/src/components/Repo.tsx): feature UI · Repository browsing, branches, files, issues, and pull requests · `frontend/src/components/Repo.tsx`
- [Profiles & Dashboard](https://github.com/parpa-123/collab-hub/blob/main/frontend/src/components/Dashboard.tsx): feature UI · User profile and dashboard surfaces · `frontend/src/components/Dashboard.tsx`

### Backend

Django API and domain apps

- [Django API](https://github.com/parpa-123/collab-hub/blob/main/backend/config/urls.py): web backend · Project wiring, routing, settings, Celery, and events · `backend/config/urls.py`
- [Accounts](https://github.com/parpa-123/collab-hub/blob/main/backend/accounts/models.py): identity · Users, OAuth/social login, JWT, and auth middleware · `backend/accounts/models.py`
- [Repositories](https://github.com/parpa-123/collab-hub/blob/main/backend/repositories/models.py): core domain · Repository CRUD, membership, visibility, and permissions · `backend/repositories/models.py`
- [Version Control](https://github.com/parpa-123/collab-hub/blob/main/backend/branches/models.py): domain split · Branches, commits, blobs, trees, and diff services · `backend/branches/models.py`
- [Pull Requests](https://github.com/parpa-123/collab-hub/blob/main/backend/PullRequest/models.py): workflow · PR lifecycle, review state, merge eligibility, and precomputed diffs · `backend/PullRequest/models.py`
- [Comments](https://github.com/parpa-123/collab-hub/blob/main/backend/comments/models.py): discussion · Shared threaded comments and inline diff comments across objects · `backend/comments/models.py`
- [Issues](https://github.com/parpa-123/collab-hub/blob/main/backend/issues/models.py): tracker · Repository-scoped issues, labels, and assignees · `backend/issues/models.py`
- [Activity](https://github.com/parpa-123/collab-hub/blob/main/backend/activity/models.py): event feed · Repository-visible activity stream derived from domain changes · `backend/activity/models.py`
- [Notifications](https://github.com/parpa-123/collab-hub/blob/main/backend/notifications/models.py): alerts · Unread user notifications and delivery side effects · `backend/notifications/models.py`
- [Events](https://github.com/parpa-123/collab-hub/blob/main/backend/config/events/dispatcher.py): internal bus · Lightweight dispatcher for decoupled side effects · `backend/config/events/dispatcher.py`
- [Celery Jobs](https://github.com/parpa-123/collab-hub/blob/main/backend/PullRequest/tasks.py): async worker · Background tasks for diffs, notifications, and follow-up work · `backend/PullRequest/tasks.py`

### CLI

Command-line client surface

- [CLI](https://github.com/parpa-123/collab-hub/blob/main/cli/main.py): command client · Git-like command-line client for repository workflows · `cli/main.py`

## Connections

- Compose → Nginx: starts · Compose brings up the public entrypoint and related services
- Compose → Gunicorn: starts · Compose launches the Django application server
- Compose → Redis: starts · Compose provides Redis for asynchronous processing
- Nginx → React SPA: serves · Nginx serves the built SPA at the root path
- Nginx → Gunicorn: routes /api /admin · Nginx forwards application requests into Django
- React SPA → Client State: uses · UI state and cross-cutting context providers
- React SPA → API Client: calls · Browser client talks to the backend through Axios
- API Client → Django API: HTTP API · Authenticated REST requests go to Django
- CLI → Django API: HTTP API · Command-line workflows reuse the same backend services
- Django API → Accounts: authenticates · Project-wide auth and trust boundary
- Django API → Repositories: routes · Repository namespace is the hub for most API workflows
- Django API → Version Control: routes · Branch, commit, blob, and tree operations
- Django API → Pull Requests: routes · Pull request lifecycle endpoints
- Django API → Comments: routes · Comment and reply endpoints
- Django API → Issues: routes · Issue and label endpoints
- Django API → Activity: routes · Activity feed endpoints
- Django API → Notifications: routes · Notification endpoints
- Repositories → Version Control: scopes · Versioned content is always repository-bound
- Repositories → Issues: scopes · Issue ownership and labels are repository-scoped
- Repositories → Pull Requests: scopes · PRs are organized by repository context
- Pull Requests → Comments: uses · PR reviews and inline discussion threads share the comment model
- Issues → Comments: uses · Issues participate in the shared discussion layer
- Version Control → Celery Jobs: queues diffs · Diff computation is delegated to background jobs
- Pull Requests → Celery Jobs: queues diff work · PR creation triggers async diff calculation
- Events → Activity: triggers · Domain events create activity records
- Events → Notifications: triggers · Domain events create user notifications
- Accounts → Events: emits · Auth-related changes can dispatch internal events
- Repositories → Events: emits · Repository mutations publish side effects through the event bus
- Pull Requests → Events: emits · PR lifecycle changes feed downstream handlers
- Issues → Events: emits · Issue changes publish activity and alert events
- Comments → Events: emits · Comment creation can trigger feed and notification handling
- Celery Jobs → Redis: brokers on · Background jobs are queued through Redis
