# par4m/orb architecture

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

- Interactive diagram: https://gitdiagram.com/par4m/orb
- Repository: https://github.com/par4m/orb

## Overview

##### Project type and purpose
- UC ORB is a full-stack web application: a discovery tool to browse and search open-source UC repositories.
- Frontend: Next.js (React) with TailwindCSS, delivering UI and routing.
- Backend: FastAPI serving REST endpoints over Uvicorn, reading from a JSON data file (and potentially a database).

##### File structure
- Top level:
- backend/ – FastAPI application
- frontend/ – Next.js application
- backend/app/
- routers/ – HTTP route handlers (`repositories.py`)
- services/ – business logic (`repository_service.py`)
- models/ – Pydantic models (`repository.py`)
- data/ – mock data source (`repositories.json`)
- main.py – app entry point
- frontend/src/app/
- page.tsx – home, about, repository listing, repository detail pages
- layout.tsx – root layout (header/footer)
- globals.css – global styles
- [id]/page.tsx – dynamic routing for repo detail
- Config files: requirements.txt, package.json, next.config.js, tailwind.config.js, vercel.json

##### Extract additional insights from README
- Endpoints: GET /api/repositories, /campuses, /languages, /topics, /{repo_id}
- Search & filter capabilities live in frontend calling backend APIs
- Future extensibility: real database, GitHub API integration, authentication

a. Main components
1. Client Browser
2. Next.js Frontend (Hosting/Vercel)
– App Router pages, React components, TailwindCSS styling
3. REST API Layer (Frontend → Backend via fetch)
4. FastAPI Backend (Uvicorn)
– Routers (controllers), Services (business logic), Models (data schemas)
5. Data Layer
– Mock JSON file (repositories.json) or future PostgreSQL DB
6. External Services (optional)
– GitHub API, Authentication provider
b. Relationships & data flow
- Browser issues HTTP(S) requests to Next.js for pages (SSR/SSG)
- React code in pages calls fetch(“/api/repositories”) to Next.js API proxy
- Next.js API routes (if used) or direct client-to-backend calls route to FastAPI
- FastAPI routers call service layer → read JSON or query DB → return Pydantic models
- Backend returns JSON → React state updates UI
c. Architectural patterns & principles
- Layered architecture in backend (Router → Service → Data)
- File-system–based routing in Next.js (App Router)
- Separation of concerns: UI, API, business logic, data persistence
- Potential for microservices or external API integration
d. Key technologies/frameworks
- Frontend: Next.js 14, React Hooks, TailwindCSS, native Fetch API
- Backend: FastAPI, Uvicorn, Pydantic, python-dotenv
- Data: JSON file (repositories.json), future PostgreSQL

##### Detail
- Sub-component: React pages, API routers, service modules, data files
- Keep it updatable: show placeholder for future database or external API modules

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Browser["Client Browser"]:::external

    %% Frontend Layer
    subgraph "Frontend (Next.js & React)"
        layout["Root Layout"]:::frontend
        home["Home Page (/)" ]:::frontend
        about["About Page (/about)"]:::frontend
        list["Repository Listing (/repositories)"]:::frontend
        detail["Repository Detail ([id])"]:::frontend
        css["global.css"]:::frontend
        stylesDir["styles/globals.css"]:::frontend
        tailwind["tailwind.config.js"]:::frontend
        nextcfg["next.config.js"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (FastAPI & Uvicorn)"
        main["main.py"]:::backend
        routers["Routers (repositories.py)"]:::backend
        services["Services (repository_service.py)"]:::backend
        models["Models (repository.py)"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        json["repositories.json"]:::data
        postgres["PostgreSQL (future)"]:::data
    end

    %% External Services
    subgraph "External Services"
        github["GitHub API"]:::external
        auth["Auth Provider"]:::external
    end

    %% Connections
    Browser -->|"Request Page"| layout
    layout --> home
    layout --> about
    layout --> list
    layout --> detail

    list -->|"fetch GET /api/repositories"| routers
    detail -->|"fetch GET /api/repositories/{id}"| routers

    main --> routers
    routers -->|"calls Service"| services
    services -->|"reads JSON"| json
    services -->|"future query"| postgres
    services -->|"returns Pydantic model"| routers
    routers -->|"returns JSON"| list
    routers -->|"returns JSON"| detail

    %% Click Events
    click layout "https://github.com/par4m/orb/blob/main/frontend/src/app/layout.tsx"
    click home "https://github.com/par4m/orb/blob/main/frontend/src/app/page.tsx"
    click about "https://github.com/par4m/orb/blob/main/frontend/src/app/about/page.tsx"
    click list "https://github.com/par4m/orb/blob/main/frontend/src/app/repositories/page.tsx"
    click detail "https://github.com/par4m/orb/blob/main/frontend/src/app/repositories/[id]/page.tsx"
    click css "https://github.com/par4m/orb/blob/main/frontend/src/app/globals.css"
    click stylesDir "https://github.com/par4m/orb/blob/main/frontend/src/styles/globals.css"
    click tailwind "https://github.com/par4m/orb/blob/main/frontend/tailwind.config.js"
    click nextcfg "https://github.com/par4m/orb/blob/main/frontend/next.config.js"
    click main "https://github.com/par4m/orb/blob/main/backend/app/main.py"
    click routers "https://github.com/par4m/orb/blob/main/backend/app/routers/repositories.py"
    click services "https://github.com/par4m/orb/blob/main/backend/app/services/repository_service.py"
    click models "https://github.com/par4m/orb/blob/main/backend/app/models/repository.py"
    click json "https://github.com/par4m/orb/blob/main/backend/app/data/repositories.json"

    %% Styles
    classDef frontend fill:#b3cde3,stroke:#03396c,color:#03396c
    classDef backend fill:#fdbb84,stroke:#e34a33,color:#e34a33
    classDef data fill:#ccebc5,stroke:#228b22,color:#228b22
    classDef external fill:#d9d9d9,stroke:#636363,color:#363636
```
