# ybz777/four-years architecture

> Architecture diagram of the GitHub repository ybz777/four-years, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ybz777/four-years
- Repository: https://github.com/ybz777/four-years

## Overview

Four Years is a browser-based, single-player college-life simulation. A player starts or resumes a life, configures a freshman character, then makes choices through academic, social, personal, financial, and career events as the game advances across four years to graduation and an ending. The React screens present scenes and choices; the game engine coordinates event selection, consequences, term progression, and outcomes. The README documents persistent saves and multiple career and graduate-school outcomes. Some subsystem links below reflect README capabilities because their implementation was not sampled.

Main entry points: [`src/game/engine.ts`](https://github.com/ybz777/four-years/blob/main/src/game/engine.ts) (Game Engine), [`src/components/PlayScreen.tsx`](https://github.com/ybz777/four-years/blob/main/src/components/PlayScreen.tsx) (Gameplay Screen), [`src/App.tsx`](https://github.com/ybz777/four-years/blob/main/src/App.tsx) (App Flow), [`src/components/CreateScreen.tsx`](https://github.com/ybz777/four-years/blob/main/src/components/CreateScreen.tsx) (Life Creation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Player Experience"]
  node_app["App Flow<br/>[App.tsx]"]
  node_title["Title Screen<br/>[TitleScreen.tsx]"]
  node_creation["Life Creation<br/>[CreateScreen.tsx]"]
  node_play["Gameplay Screen<br/>[PlayScreen.tsx]"]
  node_endingview["Ending Screen<br/>[EndingScreen.tsx]"]
  node_save[("Persistent Save<br/>[save.ts]")]
end

subgraph group_simulation["Simulation Engine"]
  node_engine["Game Engine<br/>[engine.ts]"]
  node_calendar["Year Calendar<br/>[calendar.ts]"]
  node_rng["Random Generation<br/>[rng.ts]"]
  node_create["Life Drafts<br/>[create.ts]"]
end

subgraph group_domains["College Life Systems"]
  node_academics["Academic Progress<br/>[academics.ts]"]
  node_economy["Finances<br/>[economy.ts]"]
  node_housing["Housing<br/>[housing.ts]"]
  node_majors["Majors<br/>[majors.ts]"]
  node_backgrounds["Backgrounds<br/>[backgrounds.ts]"]
  node_traits["Character Traits<br/>[traits.ts]"]
end

subgraph group_content["Events and Outcomes"]
  node_events["Dynamic Events<br/>[index.ts]"]
  node_eventtypes["Event Choices<br/>[types.ts]"]
  node_finale["Life Outcomes<br/>[finale.ts]"]
end

subgraph group_presentation["Scene Presentation"]
  node_scene["Scene Layout<br/>[Painting.tsx]"]
  node_figures["Character Figures<br/>[Figures.tsx]"]
  node_looks["Portrait Looks<br/>[looks.ts]"]
  node_audio["Scene Audio<br/>[cues.ts]"]
  node_presentation["Scene Details<br/>[presentation.ts]"]
  node_locations["Locations and Weather<br/>[locations.ts]"]
end

node_player(("Player"))

node_player -->|"starts or resumes"| node_app
node_app -->|"shows"| node_title
node_app -->|"opens"| node_creation
node_app -->|"opens"| node_play
node_app -->|"rolls draft"| node_create
node_app -->|"starts game"| node_engine
node_app -->|"loads and saves"| node_save
node_play -->|"advances life"| node_engine
node_play -->|"saves changes"| node_save
node_play -->|"shows ending"| node_endingview
node_play -->|"renders scene"| node_scene
node_play -->|"renders figures"| node_figures
node_play -->|"plays cues"| node_audio
node_engine -->|"converts time"| node_calendar
node_engine -->|"resolves terms"| node_academics
node_engine -->|"applies costs"| node_economy
node_engine -->|"assigns housing"| node_housing
node_engine -->|"selects events"| node_events
node_engine -->|"uses event outcomes"| node_eventtypes
node_engine -->|"builds ending"| node_finale
node_engine -->|"reads background"| node_backgrounds
node_engine -->|"loads traits"| node_traits
node_engine -->|"creates random stream"| node_rng
node_engine -->|"gets draft attributes"| node_create
node_creation -->|"offers majors"| node_majors
node_creation -->|"offers backgrounds"| node_backgrounds
node_creation -->|"offers traits"| node_traits
node_creation -->|"previews portrait"| node_scene
node_figures -->|"uses looks"| node_looks
node_scene -->|"reads location names"| node_locations
node_play -->|"shows calendar"| node_calendar
node_play -->|"formats scene details"| node_presentation
node_play -->|"uses location data"| node_locations
node_title -->|"renders artwork"| node_scene
node_endingview -->|"renders artwork"| node_scene
node_endingview -->|"formats ending text"| node_presentation

click node_app "https://github.com/ybz777/four-years/blob/main/src/App.tsx"
click node_title "https://github.com/ybz777/four-years/blob/main/src/components/TitleScreen.tsx"
click node_creation "https://github.com/ybz777/four-years/blob/main/src/components/CreateScreen.tsx"
click node_play "https://github.com/ybz777/four-years/blob/main/src/components/PlayScreen.tsx"
click node_endingview "https://github.com/ybz777/four-years/blob/main/src/components/EndingScreen.tsx"
click node_save "https://github.com/ybz777/four-years/blob/main/src/game/save.ts"
click node_engine "https://github.com/ybz777/four-years/blob/main/src/game/engine.ts"
click node_calendar "https://github.com/ybz777/four-years/blob/main/src/game/calendar.ts"
click node_academics "https://github.com/ybz777/four-years/blob/main/src/game/academics.ts"
click node_economy "https://github.com/ybz777/four-years/blob/main/src/game/economy.ts"
click node_housing "https://github.com/ybz777/four-years/blob/main/src/game/housing.ts"
click node_majors "https://github.com/ybz777/four-years/blob/main/src/game/majors.ts"
click node_backgrounds "https://github.com/ybz777/four-years/blob/main/src/game/backgrounds.ts"
click node_traits "https://github.com/ybz777/four-years/blob/main/src/game/traits.ts"
click node_events "https://github.com/ybz777/four-years/blob/main/src/game/events/index.ts"
click node_eventtypes "https://github.com/ybz777/four-years/blob/main/src/game/events/types.ts"
click node_finale "https://github.com/ybz777/four-years/blob/main/src/game/finale.ts"
click node_scene "https://github.com/ybz777/four-years/blob/main/src/components/Painting.tsx"
click node_figures "https://github.com/ybz777/four-years/blob/main/src/components/Figures.tsx"
click node_looks "https://github.com/ybz777/four-years/blob/main/src/art/looks.ts"
click node_audio "https://github.com/ybz777/four-years/blob/main/src/audio/cues.ts"
click node_presentation "https://github.com/ybz777/four-years/blob/main/src/game/presentation.ts"
click node_locations "https://github.com/ybz777/four-years/blob/main/src/game/locations.ts"
click node_rng "https://github.com/ybz777/four-years/blob/main/src/game/rng.ts"
click node_create "https://github.com/ybz777/four-years/blob/main/src/game/create.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_title,node_creation,node_play,node_endingview,node_save toneBlue
class node_engine,node_calendar,node_rng,node_create toneAmber
class node_academics,node_economy,node_housing,node_majors,node_backgrounds,node_traits toneMint
class node_events,node_eventtypes,node_finale toneRose
class node_scene,node_figures,node_looks,node_audio,node_presentation,node_locations,node_player toneIndigo
```

## Components

### Player Experience

- [App Flow](https://github.com/ybz777/four-years/blob/main/src/App.tsx): `src/App.tsx`
- [Title Screen](https://github.com/ybz777/four-years/blob/main/src/components/TitleScreen.tsx): `src/components/TitleScreen.tsx`
- [Life Creation](https://github.com/ybz777/four-years/blob/main/src/components/CreateScreen.tsx): `src/components/CreateScreen.tsx`
- [Gameplay Screen](https://github.com/ybz777/four-years/blob/main/src/components/PlayScreen.tsx): `src/components/PlayScreen.tsx`
- [Ending Screen](https://github.com/ybz777/four-years/blob/main/src/components/EndingScreen.tsx): `src/components/EndingScreen.tsx`
- [Persistent Save](https://github.com/ybz777/four-years/blob/main/src/game/save.ts): `src/game/save.ts`

### Simulation Engine

- [Game Engine](https://github.com/ybz777/four-years/blob/main/src/game/engine.ts): `src/game/engine.ts`
- [Year Calendar](https://github.com/ybz777/four-years/blob/main/src/game/calendar.ts): `src/game/calendar.ts`
- [Random Generation](https://github.com/ybz777/four-years/blob/main/src/game/rng.ts): `src/game/rng.ts`
- [Life Drafts](https://github.com/ybz777/four-years/blob/main/src/game/create.ts): `src/game/create.ts`

### College Life Systems

- [Academic Progress](https://github.com/ybz777/four-years/blob/main/src/game/academics.ts): `src/game/academics.ts`
- [Finances](https://github.com/ybz777/four-years/blob/main/src/game/economy.ts): `src/game/economy.ts`
- [Housing](https://github.com/ybz777/four-years/blob/main/src/game/housing.ts): `src/game/housing.ts`
- [Majors](https://github.com/ybz777/four-years/blob/main/src/game/majors.ts): `src/game/majors.ts`
- [Backgrounds](https://github.com/ybz777/four-years/blob/main/src/game/backgrounds.ts): `src/game/backgrounds.ts`
- [Character Traits](https://github.com/ybz777/four-years/blob/main/src/game/traits.ts): `src/game/traits.ts`

### Events and Outcomes

- [Dynamic Events](https://github.com/ybz777/four-years/blob/main/src/game/events/index.ts): `src/game/events/index.ts`
- [Event Choices](https://github.com/ybz777/four-years/blob/main/src/game/events/types.ts): `src/game/events/types.ts`
- [Life Outcomes](https://github.com/ybz777/four-years/blob/main/src/game/finale.ts): `src/game/finale.ts`

### Scene Presentation

- [Scene Layout](https://github.com/ybz777/four-years/blob/main/src/components/Painting.tsx): `src/components/Painting.tsx`
- [Character Figures](https://github.com/ybz777/four-years/blob/main/src/components/Figures.tsx): `src/components/Figures.tsx`
- [Portrait Looks](https://github.com/ybz777/four-years/blob/main/src/art/looks.ts): `src/art/looks.ts`
- [Scene Audio](https://github.com/ybz777/four-years/blob/main/src/audio/cues.ts): `src/audio/cues.ts`
- [Scene Details](https://github.com/ybz777/four-years/blob/main/src/game/presentation.ts): `src/game/presentation.ts`
- [Locations and Weather](https://github.com/ybz777/four-years/blob/main/src/game/locations.ts): `src/game/locations.ts`

### Other components

- **Player**

## Connections

- Player → App Flow: starts or resumes (evidence: `src/App.tsx`)
- App Flow → Title Screen: shows (evidence: `src/App.tsx`)
- App Flow → Life Creation: opens (evidence: `src/App.tsx`)
- App Flow → Gameplay Screen: opens (evidence: `src/App.tsx`)
- App Flow → Life Drafts: rolls draft (evidence: `src/App.tsx`)
- App Flow → Game Engine: starts game (evidence: `src/App.tsx`)
- App Flow → Persistent Save: loads and saves (evidence: `src/App.tsx`)
- Gameplay Screen → Game Engine: advances life (evidence: `src/components/PlayScreen.tsx`)
- Gameplay Screen → Persistent Save: saves changes (evidence: `src/components/PlayScreen.tsx`)
- Gameplay Screen → Ending Screen: shows ending (evidence: `src/components/PlayScreen.tsx`)
- Gameplay Screen → Scene Layout: renders scene (evidence: `src/components/PlayScreen.tsx`)
- Gameplay Screen → Character Figures: renders figures (evidence: `src/components/PlayScreen.tsx`)
- Gameplay Screen → Scene Audio: plays cues (evidence: `src/components/PlayScreen.tsx`)
- Game Engine → Year Calendar: converts time (evidence: `src/game/engine.ts`)
- Game Engine → Academic Progress: resolves terms (evidence: `src/game/engine.ts`)
- Game Engine → Finances: applies costs (evidence: `src/game/engine.ts`)
- Game Engine → Housing: assigns housing (evidence: `src/game/engine.ts`)
- Game Engine → Dynamic Events: selects events (evidence: `src/game/engine.ts`)
- Game Engine → Event Choices: uses event outcomes (evidence: `src/game/engine.ts`)
- Game Engine → Life Outcomes: builds ending (evidence: `src/game/engine.ts`)
- Game Engine → Backgrounds: reads background (evidence: `src/game/engine.ts`)
- Game Engine → Character Traits: loads traits (evidence: `src/game/engine.ts`)
- Game Engine → Random Generation: creates random stream (evidence: `src/game/engine.ts`)
- Game Engine → Life Drafts: gets draft attributes (evidence: `src/game/engine.ts`)
- Life Creation → Majors: offers majors (evidence: `src/components/CreateScreen.tsx`)
- Life Creation → Backgrounds: offers backgrounds (evidence: `src/components/CreateScreen.tsx`)
- Life Creation → Character Traits: offers traits (evidence: `src/components/CreateScreen.tsx`)
- Life Creation → Scene Layout: previews portrait (evidence: `src/components/CreateScreen.tsx`)
- Character Figures → Portrait Looks: uses looks (evidence: `src/components/Figures.tsx`)
- Scene Layout → Locations and Weather: reads location names (evidence: `src/components/Painting.tsx`)
- Gameplay Screen → Year Calendar: shows calendar (evidence: `src/components/PlayScreen.tsx`)
- Gameplay Screen → Scene Details: formats scene details (evidence: `src/components/PlayScreen.tsx`)
- Gameplay Screen → Locations and Weather: uses location data (evidence: `src/components/PlayScreen.tsx`)
- Title Screen → Scene Layout: renders artwork (evidence: `src/components/TitleScreen.tsx`)
- Ending Screen → Scene Layout: renders artwork (evidence: `src/components/EndingScreen.tsx`)
- Ending Screen → Scene Details: formats ending text (evidence: `src/components/EndingScreen.tsx`)
