How parpa-123/collab-hub works
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: urls.py Django API · dispatcher.py Events · repositories/models.py Repositories · PullRequest/models.py Pull Requests
Components 21
Deployment
Public entrypoint and runtime orchestration
Frontend
React SPA and client-side state
- React SPA · Vite/React/TypeScript browser client
frontend/src/main.tsx - Client State · Auth, theme, and toast cross-cutting UI state
frontend/src/Context/userContext.tsx - API Client · Token-aware HTTP client used by the SPA
frontend/src/axios/connect.ts - Repo Views · Repository browsing, branches, files, issues, and pull requests
frontend/src/components/Repo.tsx - Profiles & Dashboard · User profile and dashboard surfaces
frontend/src/components/Dashboard.tsx
Backend
Django API and domain apps
- Django API · Project wiring, routing, settings, Celery, and events
backend/config/urls.py - Accounts · Users, OAuth/social login, JWT, and auth middleware
backend/accounts/models.py - Repositories · Repository CRUD, membership, visibility, and permissions
backend/repositories/models.py - Version Control · Branches, commits, blobs, trees, and diff services
backend/branches/models.py - Pull Requests · PR lifecycle, review state, merge eligibility, and precomputed diffs
backend/PullRequest/models.py - Comments · Shared threaded comments and inline diff comments across objects
backend/comments/models.py - Issues · Repository-scoped issues, labels, and assignees
backend/issues/models.py - Activity · Repository-visible activity stream derived from domain changes
backend/activity/models.py - Notifications · Unread user notifications and delivery side effects
backend/notifications/models.py - Events · Lightweight dispatcher for decoupled side effects
backend/config/events/dispatcher.py - Celery Jobs · Background tasks for diffs, notifications, and follow-up work
backend/PullRequest/tasks.py
CLI
Command-line client surface
- CLI · Git-like command-line client for repository workflows
cli/main.py
Connections 32
- 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