# sefaria/sefaria-project architecture

> Architecture diagram of the GitHub repository sefaria/sefaria-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sefaria/sefaria-project
- Repository: https://github.com/sefaria/sefaria-project

## Overview

##### Core Components
- Frontend Layer
- React-based web application (static/js folder)
- Mobile interface (static/mobile folder)
- Content delivery components (static/*)

- Backend Layer
- Django web framework (sefaria/* folders)
- API services (api/* folder)
- Authentication system (sefaria/gauth)
- Text processing engine (sefaria/helper)

- Data Layer
- MongoDB for text storage
- PostgreSQL for user data
- Elasticsearch for search functionality
- Redis for caching

##### Key Services (represented as distinct components)
- Text Service
- Text retrieval and manipulation
- Version management
- Commentary linking system

- Search Service
- Full-text search
- Reference lookup
- Advanced filtering

- User Service
- Authentication
- Profile management
- User activity tracking

- Content Management
- Sheet creation and management
- Collections handling
- Version control

##### Infrastructure Components
- Cloud Services
- Google Cloud Platform
- CloudFlare CDN
- Cloud Storage

- Monitoring & Logging
- Prometheus integration
- Varnish caching layer
- System monitoring

##### Integration Points
- API endpoints and data flow
- Cache interaction patterns
- Database access patterns
- External service integration

##### Deployment Architecture
- Kubernetes clusters (helm-chart/*)
- Load balancers
- Cache layers
- Backup systems

Visual Elements:
- Rectangles: Core services
- Hexagons: External services

- Blue: Frontend components
- Green: Backend services
- Yellow: Databases
- Gray: Infrastructure
- Red: Critical paths

- Component types
- Environment boundaries

Special Considerations:

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef infrastructure fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef critical fill:#e74c3c,stroke:#c0392b,color:white
    
    %% Frontend Layer
    subgraph Frontend
        ReactWeb["React Web App"]
        Mobile["Mobile Interface"]
        ContentDel["Content Delivery"]
    end
    
    %% Backend Layer
    subgraph Backend
        Django["Django Framework"]
        API["API Services"]
        Auth["Authentication"]
        TextProc["Text Processing"]
    end
    
    %% Data Layer
    subgraph Data
        Mongo[(MongoDB)]
        Postgres[(PostgreSQL)]
        Elastic[(Elasticsearch)]
        Redis[(Redis Cache)]
    end
    
    %% Key Services
    subgraph Services
        TextService["Text Service"]
        SearchService["Search Service"]
        UserService["User Service"]
        ContentMgmt["Content Management"]
    end
    
    %% Infrastructure
    subgraph Infrastructure
        K8s["Kubernetes"]
        Monitor["Monitoring"]
        CDN["CloudFlare CDN"]
        LoadBal["Load Balancer"]
    end
    
    %% Connections
    ReactWeb --> API
    Mobile --> API
    ContentDel --> CDN
    
    API --> TextService
    API --> SearchService
    API --> UserService
    API --> ContentMgmt
    
    TextService --> Mongo
    SearchService --> Elastic
    UserService --> Postgres
    ContentMgmt --> Mongo
    
    Django --> Redis
    TextProc --> Mongo
    Auth --> Postgres
    
    LoadBal --> Django
    K8s --> Monitor
    
    %% Click Events
    click ReactWeb "https://github.com/Sefaria/Sefaria-Project/tree/master/static/js/"
    click Mobile "https://github.com/Sefaria/Sefaria-Project/tree/master/static/mobile/"
    click ContentDel "https://github.com/Sefaria/Sefaria-Project/tree/master/static/css/"
    click Django "https://github.com/Sefaria/Sefaria-Project/tree/master/sefaria/"
    click API "https://github.com/Sefaria/Sefaria-Project/tree/master/api/"
    click Auth "https://github.com/Sefaria/Sefaria-Project/tree/master/sefaria/gauth/"
    click TextProc "https://github.com/Sefaria/Sefaria-Project/tree/master/sefaria/helper/"
    click TextService "https://github.com/Sefaria/Sefaria-Project/tree/master/reader/"
    click SearchService "https://github.com/Sefaria/Sefaria-Project/blob/master/sefaria/search.py"
    click UserService "https://github.com/Sefaria/Sefaria-Project/blob/master/sefaria/model/user_profile.py"
    click ContentMgmt "https://github.com/Sefaria/Sefaria-Project/tree/master/sourcesheets/"
    click K8s "https://github.com/Sefaria/Sefaria-Project/tree/master/helm-chart/"
    click Monitor "https://github.com/Sefaria/Sefaria-Project/tree/master/build/monitor/"
    
    %% Style Applications
    class ReactWeb,Mobile,ContentDel frontend
    class Django,API,Auth,TextProc backend
    class Mongo,Postgres,Elastic,Redis database
    class K8s,Monitor,CDN,LoadBal infrastructure
    class TextService,SearchService,UserService,ContentMgmt backend

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Component"]:::backend
        DB["Database"]:::database
        Infra["Infrastructure"]:::infrastructure
    end
```
