# franklinomar23/pemsun architecture

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

- Interactive diagram: https://gitdiagram.com/franklinomar23/pemsun
- Repository: https://github.com/franklinomar23/pemsun

## Overview

##### Project type and purpose
- This is a single-page application (SPA) built with React and Vite.
- It serves static assets (HTML, CSS, JS, JSON) to the browser and provides interactive UI components (charts, lists, file upload).

##### File structure
- Top level:
- index.html – the SPA host page
- package.json / package-lock.json – NPM dependencies & scripts
- vite.config.js – dev/build server configuration
- public/ – static assets (favicon, manifest, etc.)
- src/ – all React app code
- src breakdown:
- App.jsx / main.jsx – entrypoint, React root instantiation
- components/ – UI components (Progress, Chart, SubjectList, UploadFile)
- page/ – page-level components (Home)
- data/ – JSON files (materias.json, medicina.json) treated as “backend” data sources
- hook/ – custom hook useMaterias.js for data loading & state
- utils/ – pure functions to transform data (progressUtil, materiaUtils)
- Config files:
- eslint.config.js – lint rules
- vite.config.js – plugin/react or plugin-react-swc for HMR

##### README for additional insights
- Minimal React + Vite template
- Uses one of two official React plugins for fast refresh
- Encourages TypeScript for production, but project is plain JS

##### Main components
a. Development environment
- Developer Workstation
- Vite Dev Server (with React plugin for HMR)
- ESLint process (code linting during dev)
b. Build/Production environment
- Vite Build (bundler)
- Static File Server (e.g., Nginx, GitHub Pages)
c. Client-side application
- Browser / JS runtime
- index.html → mounts React app
- React Core (App.jsx → component tree)
- Components:
– SubjectList/SubjectItem
– Progress (Progress.jsx)
– RemainingTimeChart (charts)
– UploadFile
- Data Sources (JSON files under src/data or public)
- Hooks & Utils for data fetching and manipulation

##### Relationships and data flow
- Developer edits code → Vite Dev Server recompiles + HMR → Browser updates
- On page load: index.html served → main.jsx bootstraps React into DOM
- React App calls useMaterias hook → reads JSON files via ES module import or fetch
- Data flows into utils → formatted → passed down to Presentation components (charts, lists)
- User actions (e.g., file upload) handled by UploadFile component → local state updates

##### Architectural patterns & design principles
- SPA architecture
- Component-based UI (React)
- Separation of concerns: data fetching (hook) vs. data transformation (utils) vs. presentation (components)
- Dev/Prod build pipeline (Vite) with fast-refresh plugin

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% Dev Tools
  subgraph "Dev Tools"
    direction TB
    Dev[/"Developer Workstation"/]:::dev
    ESLint["ESLint Process"]:::dev
    ViteDev["Vite Dev Server<br/>(React Plugin HMR)"]:::dev
  end

  %% Build & Deploy
  subgraph "Build & Deploy"
    direction TB
    ViteBuild["Vite Build<br/>(Bundler)"]:::build
    StaticServer["Static File Server<br/>(e.g., Nginx)"]:::build
  end

  %% Client Runtime
  subgraph "Client Runtime"
    direction TB
    Browser["Browser / JS Runtime"]:::runtime

    subgraph "Browser Components"
      direction TB
      HTML["index.html"]:::runtime
      ReactRoot["React Root"]:::runtime
      HookLayer["Hook Layer<br/>(useMaterias)"]:::runtime
      UtilsLayer["Utils Layer<br/>(materiaUtils, progressUtil)"]:::runtime
      ComponentLayer["Component Layer<br/>(Progress, Chart, List, Upload)"]:::runtime
      DataModules["Data Modules<br/>(JSON files)"]:::data
    end
  end

  %% Data Sources
  subgraph "JSON Data Sources"
    direction TB
    Materias["materias.json"]:::data
    Medicina["medicina.json"]:::data
  end

  %% Relationships
  Dev --> ViteDev
  Dev --> ESLint
  ViteDev --> Browser
  ViteBuild --> StaticServer
  StaticServer --> Browser

  Browser --> HTML
  HTML --> ReactRoot
  ReactRoot --> HookLayer
  HookLayer --> Materias
  HookLayer --> Medicina
  HookLayer --> UtilsLayer
  UtilsLayer --> ComponentLayer
  ComponentLayer --> ReactRoot

  %% Click Events
  click HTML "https://github.com/franklinomar23/pemsun/blob/main/index.html"
  click Dev "https://github.com/franklinomar23/pemsun/blob/main/package.json"
  click ESLint "https://github.com/franklinomar23/pemsun/blob/main/eslint.config.js"
  click ViteDev "https://github.com/franklinomar23/pemsun/blob/main/vite.config.js"
  click ViteBuild "https://github.com/franklinomar23/pemsun/blob/main/vite.config.js"
  click StaticServer "https://github.com/franklinomar23/pemsun/tree/main/public/"
  click ReactRoot "https://github.com/franklinomar23/pemsun/blob/main/src/App.jsx"
  click HookLayer "https://github.com/franklinomar23/pemsun/blob/main/src/hook/useMaterias.js"
  click UtilsLayer "https://github.com/franklinomar23/pemsun/blob/main/src/utils/materiaUtils.js"
  click UtilsLayer "https://github.com/franklinomar23/pemsun/blob/main/src/utils/progressUtil.js"
  click ComponentLayer "https://github.com/franklinomar23/pemsun/blob/main/src/components/Progress.jsx"
  click ComponentLayer "https://github.com/franklinomar23/pemsun/blob/main/src/components/RemainingTimeChart.jsx"
  click ComponentLayer "https://github.com/franklinomar23/pemsun/blob/main/src/components/SubjectList.jsx"
  click ComponentLayer "https://github.com/franklinomar23/pemsun/blob/main/src/components/SubjectItem.jsx"
  click ComponentLayer "https://github.com/franklinomar23/pemsun/blob/main/src/components/UploadFile.jsx"
  click Materias "https://github.com/franklinomar23/pemsun/blob/main/src/data/materias.json"
  click Medicina "https://github.com/franklinomar23/pemsun/blob/main/src/data/medicina.json"
  click ReactRoot "https://github.com/franklinomar23/pemsun/blob/main/src/main.jsx"

  %% Styles
  classDef dev fill:#ADD8E6,stroke:#333,stroke-width:1px
  classDef build fill:#90EE90,stroke:#333,stroke-width:1px
  classDef runtime fill:#FFFFE0,stroke:#333,stroke-width:1px
  classDef data fill:#FFA500,stroke:#333,stroke-width:1px
```
