# aydev-fr/isen-api architecture

> Architecture diagram of the GitHub repository aydev-fr/isen-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aydev-fr/isen-api
- Repository: https://github.com/aydev-fr/isen-api

## Overview

##### Project Type and Purpose
- The project is a REST API written in Golang designed to scrape and expose information from Aurion’s ENT (note manager) as well as ISEN-related data (notations, absences, planning, etc.).
- The README explains that the service takes user credentials or tokens, scrapes the corresponding web interfaces (Aurion, ISEN), then processes and sends the data back via REST endpoints. This makes it a middleware/scraping API with RESTful endpoints.
- It is a backend-focused API service intended either for public consumption (with caution regarding sensitive credentials) or self-hosting.

##### Analysis of the File Structure
- Top-Level Files:
- Files such as Dockerfile, docker-compose.yaml, Caddyfile, and certificates indicate containerized deployment and perhaps the use of a reverse proxy (Caddy) to manage HTTPS.
- CHANGELOG.md, LICENSE, and README indicate a well-documented open-source project.
- Source Files and Directories:
- main.go: Entry point for the Go application.
- pkg/ directory: The core logic is modularized inside:
- pkg/api: Contains API routing (routers.go), caching (cache.go), and variants (e.g., fake.go) which suggests different implementation strategies or testing endpoints.
- pkg/aurion: Houses scrapping logic for Aurion such as login, navigation, schedule extraction, sidebar management, and table/view state processing.
- pkg/isen: Contains functionality related to ISEN such as absences, notations, personal info, and planning.
- Documentation:
- The docs folder contains API documentation (Swagger JSON/YAML) indicating that the API’s contract is formally documented.
- CI/CD & Security:

a. Main Components:
- API Gateway / Entry Point: Represented by main.go that starts the server and establishes the API endpoints.
- REST API Layer: Illustrate pkg/api, highlighting:
◦ API routing (routers.go): Handling incoming requests to endpoints like /v1/token, /v1/notations, /v1/absences, /v1/agenda.
◦ Caching mechanism (cache.go) that may improve performance.
- Scraping/Processing Modules:
◦ pkg/aurion: Responsible for logging in and scraping data from Aurion’s ENT (e.g., login, schedule, navigation).
◦ pkg/isen: Handles ISEN-specific scrapping tasks such as retrieving absences, notations, personal info, and planning.
- External Clients: Clients making HTTP requests to the REST API (as shown in README usage examples).
- Deployment & Infrastructure:
◦ Docker and Docker Compose: Containerization of the API.
◦ Caddy (via Caddyfile): Web server/reverse proxy for secure, production-grade HTTPS routing.
◦ Certificates: For ensuring secure connections.

b. Relationships and Interactions:
- Within the API Gateway, show routing decisions: incoming requests based on endpoints are directed to the appropriate handling functions.
- That the API layer calls the underlying scrapers in pkg/aurion and pkg/isen to fulfill the requests.
- Optionally, include CI/CD pipelines (GitHub workflows) as supporting infrastructure for automatic builds, testing, and deployment (especially if it’s important in the deployment environment).

c. Architectural Patterns and Technologies:
- Modular organization, with clear separation between the API interface (pkg/api) and business logic (pkg/aurion and pkg/isen).
- Point out the use of the REST architectural style.
- Use of containerization (Docker) and a reverse proxy (Caddy) for deployment.
- External dependencies such as Goquery for scraping and possibly additional libraries (Golang standard libraries).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Clients
    subgraph "External Clients"
        CLIENT["External Client"]:::client
    end

    %% API Gateway / Entry Point Layer
    API["API Gateway (main.go)"]:::api
    click API "https://github.com/aydev-fr/isen-api/blob/main/main.go"

    %% REST API Layer
    subgraph "REST API Layer"
        ROUTERS["API Routing (routers.go)"]:::api
        click ROUTERS "https://github.com/aydev-fr/isen-api/blob/main/pkg/api/routers.go"
        CACHE["Caching (cache.go)"]:::api
        click CACHE "https://github.com/aydev-fr/isen-api/blob/main/pkg/api/cache.go"
        FAKE["Fake Endpoints (fake.go)"]:::api
        click FAKE "https://github.com/aydev-fr/isen-api/blob/main/pkg/api/fake.go"
    end

    %% Scraping/Processing Modules
    subgraph "Scraping Modules"
        AURION["Aurion Scraper Module (pkg/aurion)"]:::scraper
        click AURION "https://github.com/aydev-fr/isen-api/tree/main/pkg/aurion"
        ISEN["ISEN Data Processor (pkg/isen)"]:::scraper
        click ISEN "https://github.com/aydev-fr/isen-api/tree/main/pkg/isen"
    end

    %% Deployment & Infrastructure
    subgraph "Deployment & Infrastructure"
        DOCKER["Dockerfile"]:::infra
        click DOCKER "https://github.com/aydev-fr/isen-api/tree/main/Dockerfile"
        DOCKERC["Docker Compose (docker-compose.yaml)"]:::infra
        click DOCKERC "https://github.com/aydev-fr/isen-api/blob/main/docker-compose.yaml"
        CADDY["Caddy Reverse Proxy (Caddyfile)"]:::infra
        click CADDY "https://github.com/aydev-fr/isen-api/tree/main/Caddyfile"
        CERT["Certificates"]:::infra
        click CERT "https://github.com/aydev-fr/isen-api/tree/main/certificates"
    end

    %% CI/CD Pipeline
    CI["CI/CD Pipeline (.github/workflows)"]:::ci
    click CI "https://github.com/aydev-fr/isen-api/tree/main/.github/workflows"

    %% Connections
    CLIENT -->|"HTTPRequests"| API
    API -->|"Routes"| ROUTERS
    %% Caching interaction: caching enhances API responses
    ROUTERS <-->|"Caches"| CACHE

    %% API Layer calling Scraping Modules 
    ROUTERS -->|"CallsAurion"| AURION
    ROUTERS -->|"CallsISEN"| ISEN

    %% Return scraped data flows back to API Routing
    AURION -->|"ReturnsData"| ROUTERS
    ISEN -->|"ReturnsData"| ROUTERS

    %% Deployment & Infrastructure integration with API
    API -->|"DeployedVia"| DOCKER
    API -->|"ManagedBy"| DOCKERC
    API -->|"SecuredBy"| CADDY
    API -->|"Uses"| CERT

    %% CI/CD linked to deployment updates
    API -.->|"UpdatesTriggered"| CI
    DOCKERC -.->|"BuildTriggers"| CI

    %% Styles
    classDef api fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef scraper fill:#aed6f1,stroke:#2e86c1,stroke-width:2px;
    classDef infra fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef client fill:#f5cba7,stroke:#b9770e,stroke-width:2px;
    classDef ci fill:#fadbd8,stroke:#c0392b,stroke-width:2px;
```
