# inp-net/churros architecture

> Architecture diagram of the GitHub repository inp-net/churros, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/inp-net/churros
- Repository: https://github.com/inp-net/churros

## Overview

##### Main Components Architecture

**Frontend (SvelteKit Application)**
- Public Web Interface
- Admin Interface

**Backend (GraphQL API)**
- Authentication Service
- Core Services
- Integration Services

**Infrastructure**
- PostgreSQL Database
- Redis Cache
- File Storage

##### Key Services and Modules

**Core Services**
- Users & Authentication
- Groups & Organizations
- Events & Ticketing
- Document Management (La Frappe)
- Posts & Announcements
- Forms
- Notifications

**Integration Services**
- LDAP Integration
- Payment Processing
- Lydia
- PayPal
- Digital Wallets
- Apple Wallet
- Google Wallet
- External Services

##### Data Flow Relationships

Key interactions:

**User Request Flow**
- Client (SvelteKit) → API Gateway
- API Gateway → GraphQL API
- GraphQL API → Service Modules
- Service Modules → Database/Cache/Storage

**Authentication Flow**
- User Credentials → Auth Service
- Auth Service → LDAP Verification
- Token Generation → Client

##### Specific Implementation Details

Technical components:

**Frontend Implementation**
- SvelteKit Routes
- GraphQL Queries/Mutations
- PWA Capabilities

**Backend Implementation**
- Prisma ORM
- GraphQL Resolvers
- Module-based Architecture

##### Key Interactions to Highlight

- User authentication flow
- Event booking and ticket management
- Document sharing and management
- And organization hierarchy
- Notification system
- Payment processing flow

**Deployment Infrastructure**
- Kubernetes Clusters
- Database Instances
- Redis Cache
- Storage Solutions

##### Security Boundaries

Security zones:

**Security Layers**
- Public Zone (Frontend)
- API Gateway
- Application Zone
- Data Zone

## Diagram (Mermaid)

```mermaid
graph TB
    %% Core GraphQL Components
    GQL[GraphQL Server]:::core
    Schema[Schema Definition]:::core
    Resolver[Resolver Layer]:::core

    %% Module Groups
    subgraph Modules
        subgraph Users
            UsersM[Users Module]:::module
            AuthM[Authentication]:::module
            PermM[Permissions]:::module
        end

        subgraph Content
            PostsM[Posts Module]:::module
            DocsM[Documents Module]:::module
            PagesM[Pages Module]:::module
        end

        subgraph Events
            EventsM[Events Module]:::module
            TicketM[Ticketing Module]:::module
            BookM[Bookings Module]:::module
        end

        subgraph Groups
            GroupsM[Groups Module]:::module
            AssocM[Student Associations]:::module
            SchoolM[Schools Module]:::module
        end

        subgraph Forms
            FormsM[Forms Module]:::module
            RespM[Responses Module]:::module
        end

        subgraph Notifications
            NotifM[Notifications Module]:::module
            MailM[Mails Module]:::module
        end
    end

    %% Data Layer
    DB[(PostgreSQL)]:::database
    Redis[(Redis Cache)]:::database
    Storage[(File Storage)]:::database

    %% External Services
    LDAP{{LDAP}}:::external
    Payment{{Payment Systems}}:::external
    Wallet{{Digital Wallets}}:::external
    OAuth{{OAuth Providers}}:::external

    %% Infrastructure
    RateLimit[Rate Limiting]:::infra
    AuthMW[Auth Middleware]:::infra
    Logging[Logging System]:::infra
    Metrics[Metrics]:::infra

    %% Relationships
    GQL --> Schema
    Schema --> Resolver
    Resolver --> |Resolves| Modules
    
    %% Data Layer Connections
    Modules --> DB
    Modules --> Redis
    Modules --> Storage

    %% External Service Connections
    UsersM -.-> LDAP
    TicketM -.-> Payment
    EventsM -.-> Wallet
    AuthM -.-> OAuth

    %% Infrastructure Connections
    GQL --> RateLimit
    GQL --> AuthMW
    GQL --> Logging
    GQL --> Metrics

    %% Click Events
    click GQL "https://github.com/inp-net/churros/blob/main/packages/api/src/server/graphql.ts"
    click UsersM "https://github.com/inp-net/churros/tree/main/packages/api/src/modules/users/"
    click DocsM "https://github.com/inp-net/churros/tree/main/packages/api/src/modules/documents/"
    click EventsM "https://github.com/inp-net/churros/tree/main/packages/api/src/modules/events/"
    click TicketM "https://github.com/inp-net/churros/tree/main/packages/api/src/modules/ticketing/"
    click GroupsM "https://github.com/inp-net/churros/tree/main/packages/api/src/modules/groups/"
    click FormsM "https://github.com/inp-net/churros/tree/main/packages/api/src/modules/forms/"
    click NotifM "https://github.com/inp-net/churros/tree/main/packages/api/src/modules/notifications/"
    click Redis "https://github.com/inp-net/churros/blob/main/packages/api/src/lib/redis.ts"
    click Storage "https://github.com/inp-net/churros/blob/main/packages/api/src/lib/storage.ts"
    click LDAP "https://github.com/inp-net/churros/blob/main/packages/api/src/lib/ldap-school.ts"
    click Payment "https://github.com/inp-net/churros/tree/main/packages/api/src/modules/payments/"
    click Wallet "https://github.com/inp-net/churros/blob/main/packages/api/src/lib/apple-wallet.ts"
    click OAuth "https://github.com/inp-net/churros/blob/main/packages/api/src/server/auth/oauth2.ts"
    click RateLimit "https://github.com/inp-net/churros/blob/main/packages/api/src/lib/ratelimit.ts"
    click AuthMW "https://github.com/inp-net/churros/blob/main/packages/api/src/lib/auth.ts"
    click Logging "https://github.com/inp-net/churros/blob/main/packages/api/src/lib/logger.ts"
    click Metrics "https://github.com/inp-net/churros/blob/main/packages/api/src/lib/prometheus.ts"
    click DB "https://github.com/inp-net/churros/tree/main/packages/db/prisma/"

    %% Styling
    classDef core fill:#f9f,stroke:#333,stroke-width:2px
    classDef module fill:#bbf,stroke:#333
    classDef database fill:#dfd,stroke:#333
    classDef external fill:#fdd,stroke:#333
    classDef infra fill:#ddd,stroke:#333

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Modules]:::module
        L3[(Databases)]:::database
        L4{{External Services}}:::external
        L5[Infrastructure]:::infra
    end
```
