# luckyxjx/cipherschool-sqlstudo-assignment architecture

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

- Interactive diagram: https://gitdiagram.com/luckyxjx/cipherschool-sqlstudo-assignment
- Repository: https://github.com/luckyxjx/cipherschool-sqlstudo-assignment

## Overview

CipherSQLStudio is a browser-based SQL practice app. Learners browse assignments, inspect sample tables, edit and run SQL, compare results with expected output, and optionally request hints; attempts are saved under a session identity. The graph follows the documented API flow and sampled call sites. Assignment/progress persistence is MongoDB-backed, and query execution uses PostgreSQL. The seed-data path and several UI components are represented only where the README or indexed references support their role; unsampled internal links are omitted.

Main entry points: [`server/src/controllers/assignmentController.js`](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/controllers/assignmentController.js) (Request controller), [`client/src/pages/AssignmentAttemptPage.jsx`](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/client/src/pages/AssignmentAttemptPage.jsx) (Practice workspace), [`client/src/App.jsx`](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/client/src/App.jsx) (App routing), [`server/src/services/queryService.js`](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/services/queryService.js) (Query execution)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Learner interface"]
  node_app["App routing<br/>[App.jsx]"]
  node_list["Assignment list"]
  node_attempt["Practice workspace"]
  node_api_client["API client<br/>[api.js]"]
  node_editor["SQL editor<br/>[QueryEditor.jsx]"]
  node_results["Results table<br/>[ResultsTable.jsx]"]
  node_sample["Sample data viewer"]
  node_badge["Difficulty badge"]
end

subgraph group_api["Assignment API"]
  node_express["HTTP application<br/>[app.js]"]
  node_routes["Assignment routes"]
  node_controller["Request controller"]
  node_env["Environment config<br/>[env.js]"]
end

subgraph group_practice["Query practice"]
  node_safety["SQL safety<br/>[sqlSafety.js]"]
  node_query["Query execution<br/>[queryService.js]"]
  node_postgres[("PostgreSQL")]
  node_evaluation["Output evaluation<br/>[resultService.js]"]
  node_hints["Hint generation<br/>[hintService.js]"]
end

subgraph group_state["Assignment state"]
  node_assignment[("Assignment records<br/>[Assignment.js]")]
  node_progress[("Learner progress<br/>[UserProgress.js]")]
  node_mongo[("MongoDB")]
end

node_learner(("Learner"))
node_llm["OpenAI-compatible service"]

node_learner -->|"uses"| node_app
node_app -->|"loads data"| node_api_client
node_app -->|"renders"| node_list
node_app -->|"opens assignment"| node_attempt
node_list -->|"shows difficulty"| node_badge
node_attempt -->|"requests"| node_api_client
node_attempt -->|"renders"| node_editor
node_attempt -->|"renders"| node_results
node_attempt -->|"renders"| node_sample
node_api_client -->|"HTTP requests"| node_express
node_express -->|"mounts routes"| node_routes
node_routes -->|"dispatches"| node_controller
node_controller -->|"reads"| node_assignment
node_controller -->|"reads and saves"| node_progress
node_assignment -.->|"persists in"| node_mongo
node_progress -.->|"persists in"| node_mongo
node_controller -->|"executes SQL"| node_query
node_query -->|"validates SQL"| node_safety
node_query -->|"runs query"| node_postgres
node_controller -->|"checks output"| node_evaluation
node_controller -->|"requests hint"| node_hints
node_hints -.->|"asks for hint"| node_llm
node_express -->|"configures CORS"| node_env
node_hints -->|"reads settings"| node_env
node_query -->|"reads timeout"| node_env

click node_app "https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/client/src/App.jsx"
click node_list "https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/client/src/pages/AssignmentListPage.jsx"
click node_attempt "https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/client/src/pages/AssignmentAttemptPage.jsx"
click node_api_client "https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/client/src/services/api.js"
click node_editor "https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/client/src/ui/QueryEditor.jsx"
click node_results "https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/client/src/ui/ResultsTable.jsx"
click node_sample "https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/client/src/ui/SampleDataViewer.jsx"
click node_badge "https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/client/src/ui/DifficultyBadge.jsx"
click node_express "https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/app.js"
click node_routes "https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/routes/assignmentRoutes.js"
click node_controller "https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/controllers/assignmentController.js"
click node_env "https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/config/env.js"
click node_assignment "https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/models/Assignment.js"
click node_progress "https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/models/UserProgress.js"
click node_safety "https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/utils/sqlSafety.js"
click node_query "https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/services/queryService.js"
click node_evaluation "https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/services/resultService.js"
click node_hints "https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/services/hintService.js"

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_list,node_attempt,node_api_client,node_editor,node_results,node_sample,node_badge toneBlue
class node_express,node_routes,node_controller,node_env toneAmber
class node_safety,node_query,node_postgres,node_evaluation,node_hints toneMint
class node_assignment,node_progress,node_mongo toneRose
class node_learner,node_llm toneIndigo
```

## Components

### Learner interface

- [App routing](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Assignment list](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/client/src/pages/AssignmentListPage.jsx): `client/src/pages/AssignmentListPage.jsx`
- [Practice workspace](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/client/src/pages/AssignmentAttemptPage.jsx): `client/src/pages/AssignmentAttemptPage.jsx`
- [API client](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/client/src/services/api.js): `client/src/services/api.js`
- [SQL editor](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/client/src/ui/QueryEditor.jsx): `client/src/ui/QueryEditor.jsx`
- [Results table](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/client/src/ui/ResultsTable.jsx): `client/src/ui/ResultsTable.jsx`
- [Sample data viewer](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/client/src/ui/SampleDataViewer.jsx): `client/src/ui/SampleDataViewer.jsx`
- [Difficulty badge](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/client/src/ui/DifficultyBadge.jsx): `client/src/ui/DifficultyBadge.jsx`

### Assignment API

- [HTTP application](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/app.js): `server/src/app.js`
- [Assignment routes](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/routes/assignmentRoutes.js): `server/src/routes/assignmentRoutes.js`
- [Request controller](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/controllers/assignmentController.js): `server/src/controllers/assignmentController.js`
- [Environment config](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/config/env.js): `server/src/config/env.js`

### Query practice

- [SQL safety](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/utils/sqlSafety.js): `server/src/utils/sqlSafety.js`
- [Query execution](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/services/queryService.js): `server/src/services/queryService.js`
- **PostgreSQL**
- [Output evaluation](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/services/resultService.js): `server/src/services/resultService.js`
- [Hint generation](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/services/hintService.js): `server/src/services/hintService.js`

### Assignment state

- [Assignment records](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/models/Assignment.js): `server/src/models/Assignment.js`
- [Learner progress](https://github.com/luckyxjx/cipherschool-sqlstudo-assignment/blob/main/server/src/models/UserProgress.js): `server/src/models/UserProgress.js`
- **MongoDB**

### Other components

- **Learner**
- **OpenAI-compatible service**

## Connections

- Learner → App routing: uses (evidence: `README.md`)
- App routing → API client: loads data (evidence: `client/src/App.jsx`)
- App routing → Assignment list: renders (evidence: `client/src/App.jsx`)
- App routing → Practice workspace: opens assignment (evidence: `client/src/App.jsx`)
- Assignment list → Difficulty badge: shows difficulty (evidence: `client/src/pages/AssignmentListPage.jsx`)
- Practice workspace → API client: requests (evidence: `client/src/pages/AssignmentAttemptPage.jsx`)
- Practice workspace → SQL editor: renders (evidence: `client/src/pages/AssignmentAttemptPage.jsx`)
- Practice workspace → Results table: renders (evidence: `client/src/pages/AssignmentAttemptPage.jsx`)
- Practice workspace → Sample data viewer: renders (evidence: `client/src/pages/AssignmentAttemptPage.jsx`)
- API client → HTTP application: HTTP requests (evidence: `README.md`)
- HTTP application → Assignment routes: mounts routes (evidence: `server/src/app.js`)
- Assignment routes → Request controller: dispatches (evidence: `server/src/routes/assignmentRoutes.js`)
- Request controller → Assignment records: reads (evidence: `server/src/controllers/assignmentController.js`)
- Request controller → Learner progress: reads and saves (evidence: `server/src/controllers/assignmentController.js`)
- Assignment records → MongoDB: persists in
- Learner progress → MongoDB: persists in
- Request controller → Query execution: executes SQL (evidence: `server/src/controllers/assignmentController.js`)
- Query execution → SQL safety: validates SQL (evidence: `server/src/services/queryService.js`)
- Query execution → PostgreSQL: runs query (evidence: `server/src/services/queryService.js`)
- Request controller → Output evaluation: checks output (evidence: `server/src/controllers/assignmentController.js`)
- Request controller → Hint generation: requests hint (evidence: `server/src/controllers/assignmentController.js`)
- Hint generation → OpenAI-compatible service: asks for hint (evidence: `server/src/services/hintService.js`)
- HTTP application → Environment config: configures CORS (evidence: `server/src/app.js`)
- Hint generation → Environment config: reads settings (evidence: `server/src/services/hintService.js`)
- Query execution → Environment config: reads timeout (evidence: `server/src/services/queryService.js`)
