HyperSaaS
BackendGetting Started

Project Structure

How the backend codebase is organized.

Directory Layout

backend/
├── backend/                  # Django application code
│   ├── core/                 # Base model, shared utilities
│   │   └── models.py         # BaseModel (created_at, updated_at)
│   ├── users/                # User management
│   │   ├── models.py         # Custom User model
│   │   ├── adapters.py       # Allauth adapters
│   │   ├── managers.py       # Custom UserManager
│   │   └── api/              # User API views & serializers
│   ├── workspaces/           # Multi-tenancy
│   │   ├── models.py         # Workspace, Team, Membership, Invitation
│   │   ├── roles.py          # Role constants (admin, member)
│   │   ├── permissions.py    # DRF permission classes
│   │   └── api/              # Workspace API views & serializers
│   ├── chat/                 # AI chat system
│   │   ├── models.py         # ChatSession, Message
│   │   ├── ai_models.py      # LLM provider handlers
│   │   ├── services.py       # Message processing & persistence
│   │   ├── pricing_config.py # Per-model token pricing
│   │   ├── tasks.py          # Celery tasks for async agents
│   │   ├── handlers/         # Pluggable agent framework
│   │   │   ├── base.py       # AgentMessage, BaseAgentHandler ABC
│   │   │   ├── langgraph/    # LangGraph implementation
│   │   │   └── pydantic_ai/  # PydanticAI implementation
│   │   ├── tools/            # Plain Python tool functions
│   │   └── api/              # Chat API views & serializers
│   ├── documents/            # Knowledge base & RAG
│   │   ├── models.py         # KnowledgeBase, Document, DocumentChunk
│   │   ├── tasks.py          # Celery ingestion pipeline
│   │   ├── retrieval.py      # Hybrid search (semantic + keyword + RRF)
│   │   ├── rag_tool.py       # RAG tool for LangGraph
│   │   ├── s3_utils.py       # S3 presigned URL helpers
│   │   └── api/              # Document API views & serializers
│   └── subscriptions/        # Stripe billing
│       ├── models.py         # StripeUser, Product, Price, Subscription
│       ├── stripe_api/       # Stripe client wrappers
│       ├── stripe_models/    # Stripe data classes
│       ├── stripe_webhooks/  # Webhook event handlers
│       └── api/              # Subscription API views
├── config/                   # Django configuration
│   ├── settings/
│   │   ├── base.py           # Shared settings
│   │   ├── local.py          # Development settings
│   │   ├── production.py     # Production settings
│   │   └── test.py           # Test settings
│   ├── urls.py               # Root URL configuration
│   ├── api_router.py         # REST API URL registration
│   ├── celery_app.py         # Celery configuration
│   └── wsgi.py / asgi.py     # Server entry points
├── compose/                  # Docker configurations
│   ├── local/                # Development Dockerfiles
│   └── production/           # Production Dockerfiles
├── requirements/             # Python dependencies
│   ├── base.txt              # Core dependencies
│   ├── local.txt             # Dev tools (debug toolbar, etc.)
│   └── production.txt        # Production extras (Docling, Sentry)
├── .envs/                    # Environment variable files
│   ├── .local/               # Local dev env vars
│   └── .production/          # Production env vars
└── docker-compose.local.yml  # Local Docker Compose

App Dependencies

core ← users ← workspaces ← chat ← documents
                                  ↖ subscriptions
  • core provides the BaseModel abstract class used by all other apps
  • users depends on core for base model
  • workspaces depends on users for ownership and membership
  • chat depends on workspaces for scoping and users for session ownership
  • documents depends on chat (for ChatSessionKnowledgeBase) and workspaces
  • subscriptions depends on users (for StripeUser) and is referenced by workspaces

On this page