# iamfortune/ai-roadmap-generator architecture

> Architecture diagram of the GitHub repository iamfortune/ai-roadmap-generator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iamfortune/ai-roadmap-generator
- Repository: https://github.com/iamfortune/ai-roadmap-generator

## Overview

##### Project type and purpose
- This is a full‑stack web application called “AI Roadmap Generator.”
- Frontend: A React (Vite) single‑page app served statically.
- Backend: A Platformatic AI‑warp service (built on Fastify) that handles GitHub OAuth2 authentication and AI prompt processing.

##### File structure
- Root: Dockerfile, docker‑compose.yml, platformatic.json – orchestration & service configuration.
- services/ai: Everything related to the AI service, including:
- platformatic.json + plugins – defines Fastify server with authentication and static file serving.
- AI.mjs, AI.openapi.json – core AI‑warp logic and OpenAPI spec.
- public/index.html + src/… – React application source.
- auth/github.js – GitHub OAuth handler.
- No database folders – the service is stateless (sessions maintained in memory or via cookies).

##### README for additional insights
- Technologies: Platformatic AI‑warp for AI + OAuth2, fastify‑static for serving React, GitHub OAuth2 for authentication.
- User flow: Authenticate with GitHub → enter a keyword → service sends prompt to AI provider → returns a generated roadmap → displayed in the React UI.

##### Elements
- Labels: “React SPA,” “Fastify Static,” “Platformatic AI‑warp API,” “GitHub OAuth,” “AI Provider.”
- Browser → Static Server (GET /index.html, JS bundles)
- Browser ↔ API Server (POST /generate, GET /auth/callback)
- API Server → GitHub OAuth (redirect/validate)
- API Server → AI Provider (HTTP POST prompt)

##### Detail
- Plugin (authentication.js, static.js) as subcomponents of the API Server.
- OpenAPI contract as the formal boundary between frontend and backend.
- Containerized deployment (Dockerfile/docker‑compose) as the outermost layer.
- Don’t overcomplicate: break the system into logical pieces (Client, Static Server, API Server, External Services).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Deployment Layer
    subgraph "Deployment & Orchestration"
        Dockerfile["Dockerfile"]:::infra
        Compose["docker-compose.yml"]:::infra
        RootPlat["platformatic.json (root)"]:::infra
    end

    %% Server Layer
    subgraph "Server Container"
        subgraph "Platformatic AI‑warp Service"
            Static["Fastify Static Plugin"]:::backend
            AuthPlugin["GitHub OAuth Plugin"]:::backend
            AIService["AI‑warp Core (AI.mjs)"]:::backend
            OpenAPI["OpenAPI Contract (AI.openapi.json)"]:::backend
        end
    end

    %% Client Layer
    subgraph "Client (Browser)"
        ReactSPA["React SPA"]:::frontend
    end

    %% External Services
    subgraph "External Services"
        GitHub["GitHub OAuth2"]:::external
        AIProvider["AI Provider"]:::external
    end

    %% Connections
    ReactSPA -->|"GET /index.html, bundles"| Static
    ReactSPA -->|"POST /generate"| AIService
    ReactSPA -->|"GET /auth/callback"| AuthPlugin

    AIService -->|"uses OpenAPI contract"| OpenAPI
    AIService -->|"forward prompt"| AIProvider
    AIService -->|"issue redirect/validate"| AuthPlugin

    AuthPlugin -->|"redirect to"| GitHub
    AuthPlugin -->|"OAuth callback"| GitHub

    %% Deployment to Server Container
    Dockerfile --> ServerContainer["Server Container"]
    Compose --> ServerContainer
    RootPlat --> ServerContainer

    %% Click Events
    click ReactSPA "https://github.com/iamfortune/ai-roadmap-generator/blob/main/services/ai/index.html"
    click Static "https://github.com/iamfortune/ai-roadmap-generator/blob/main/services/ai/plugins/static.js"
    click AuthPlugin "https://github.com/iamfortune/ai-roadmap-generator/blob/main/services/ai/plugins/authentication.js"
    click AIService "https://github.com/iamfortune/ai-roadmap-generator/blob/main/services/ai/AI.mjs"
    click OpenAPI "https://github.com/iamfortune/ai-roadmap-generator/blob/main/services/ai/AI.openapi.json"
    click GitHub "https://github.com/iamfortune/ai-roadmap-generator/blob/main/services/ai/auth/github.js"
    click Dockerfile "https://github.com/iamfortune/ai-roadmap-generator/tree/main/Dockerfile"
    click Compose "https://github.com/iamfortune/ai-roadmap-generator/blob/main/docker-compose.yml"
    click RootPlat "https://github.com/iamfortune/ai-roadmap-generator/blob/main/platformatic.json"

    %% Styles
    classDef frontend fill:#fdd,stroke:#000,stroke-width:1px
    classDef backend fill:#dfd,stroke:#000,stroke-width:1px
    classDef external fill:#ddf,stroke-dasharray: 5 5,stroke:#000,stroke-width:1px
    classDef infra fill:#ffd,stroke:#000,stroke-width:1px
```
