# varphi-online/ua-navarch architecture

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

- Interactive diagram: https://gitdiagram.com/varphi-online/ua-navarch
- Repository: https://github.com/varphi-online/ua-navarch

## Overview

##### Main Components

A. Data Collection Layer
- Rust-based Scraper Service
- Parser Module
- Database Interface
- HTTP Client for UA Course Catalog

B. Web Application Layer
- SvelteKit Frontend/Backend
- API Routes
- Database Interface
- UI Components

**[Data Source Layer]**
- ↓
**[Processing Layer]**
- ↓
**[Application Layer]**

##### Detailed Component Breakdown

a. Data Source Layer:
- External UA Course Catalog (show as external system)

b. Processing Layer (Rust Scraper):
- Scraper component with three internal modules:
- Client Module (for HTTP requests)
- Parser Module (for data processing)
- Database Interface (for storage)
- Use a container symbol with internal compartments

c. Application Layer (SvelteKit):
- Frontend Components:
- Course Search
- Schedule Generator
- Weekly View
- Course/Section Cards
- Backend Services:
- API Routes (/api/search, /api/generate)
- Database Interface
- Routing System:
- Course Routes
- Schedule Routes

##### Connection and Data Flow

- Periodic data collection from UA Catalog → Scraper
- Scraper → Database
- API Routes ← → Database
- Frontend Components ← → API Routes

##### Technical Stack Indicators

Technology labels:
- Rust (Scraper)
- SvelteKit (Web Application)
- UI Components (Shadcn)
- Database (type determined by implementation)

##### Additional Details

Notes about:
- Cron job scheduling for scraper
- API endpoint purposes
- Component relationships
- State management flow

Remember to include the Docker container boundaries since the project uses Docker (as evidenced by the Dockerfile and compose.yml).

This system design should clearly show how the application fulfills its core purposes while maintaining a clear separation of concerns between the data collection, processing, and presentation layers.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef external fill:#B3E5FC,stroke:#0288D1
    classDef scraper fill:#C8E6C9,stroke:#388E3C
    classDef frontend fill:#FFE0B2,stroke:#F57C00
    classDef backend fill:#E1BEE7,stroke:#7B1FA2
    classDef database fill:#CFD8DC,stroke:#546E7A
    classDef api fill:#FFCDD2,stroke:#D32F2F

    %% External Systems
    UA["UA Course Catalog"]:::external

    %% Data Processing Layer
    subgraph Scraper["Rust Scraper Service"]
        Client["HTTP Client"]
        Parser["Parser Module"]
        ScraperDB["Database Interface"]
    end
    class Client,Parser,ScraperDB scraper

    %% Database
    DB[(Database)]:::database

    %% Web Application Layer
    subgraph WebApp["SvelteKit Application"]
        %% Frontend Components
        subgraph FrontendComponents["Frontend Components"]
            Search["Course Search"]
            Generator["Schedule Generator"]
            Weekly["Weekly View"]
            CourseCard["Course Card"]
            SectionCard["Section Card"]
        end

        %% Backend Components
        subgraph BackendComponents["Backend Components"]
            APIRoutes{{"API Routes"}}
            WebDB["Database Interface"]
            RouteHandlers["Route Handlers"]
        end

        %% UI Components
        UILib["UI Component Library"]
    end
    class Search,Generator,Weekly,CourseCard,SectionCard frontend
    class APIRoutes,WebDB,RouteHandlers backend
    class UILib frontend

    %% Relationships
    UA --> Client
    Client --> Parser
    Parser --> ScraperDB
    ScraperDB --> DB
    WebDB --> DB
    APIRoutes --> WebDB
    FrontendComponents --> APIRoutes
    FrontendComponents --> RouteHandlers
    UILib --> FrontendComponents

    %% Click Events
    click Client "https://github.com/varphi-online/UA-Navarch/blob/main/scraper/src/scraper/client.rs"
    click Parser "https://github.com/varphi-online/UA-Navarch/blob/main/scraper/src/parser/parser.rs"
    click ScraperDB "https://github.com/varphi-online/UA-Navarch/blob/main/scraper/src/parser/database.rs"
    click Search "https://github.com/varphi-online/UA-Navarch/blob/main/server/src/lib/SearchBar.svelte"
    click Generator "https://github.com/varphi-online/UA-Navarch/blob/main/server/src/lib/Generator.svelte"
    click Weekly "https://github.com/varphi-online/UA-Navarch/blob/main/server/src/lib/Week.svelte"
    click CourseCard "https://github.com/varphi-online/UA-Navarch/blob/main/server/src/lib/CourseCard.svelte"
    click SectionCard "https://github.com/varphi-online/UA-Navarch/blob/main/server/src/lib/SectionCard.svelte"
    click APIRoutes "https://github.com/varphi-online/UA-Navarch/tree/main/server/src/routes/api"
    click WebDB "https://github.com/varphi-online/UA-Navarch/blob/main/server/src/lib/server/database.ts"
    click RouteHandlers "https://github.com/varphi-online/UA-Navarch/tree/main/server/src/routes"
    click UILib "https://github.com/varphi-online/UA-Navarch/tree/main/server/src/lib/components/ui"
```
