# tpals0409/algosu architecture

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

- Interactive diagram: https://gitdiagram.com/tpals0409/algosu
- Repository: https://github.com/tpals0409/algosu

## Overview

AlgoSu is an algorithm-study management service: members organize studies and problems, submit code, then track asynchronous GitHub persistence and AI analysis to review results. The map follows the documented frontend-to-Gateway boundary and the submission Saga’s background workflow, including status notifications. It also preserves study, problem, review, and identity capabilities. README architecture statements support the service and infrastructure links; sampled source excerpts further verify Saga publishing, review proxying, and AI service calls. Other frontend and service internals are represented at their documented subsystem paths.

Main entry points: [`services/gateway/src`](https://github.com/tpals0409/algosu/tree/main/services/gateway/src) (API Gateway), [`frontend/src/app`](https://github.com/tpals0409/algosu/tree/main/frontend/src/app) (Next.js App), [`services/submission/src/submission/submission.service.ts`](https://github.com/tpals0409/algosu/blob/main/services/submission/src/submission/submission.service.ts) (Submission Service), [`services/submission/src/saga/saga-orchestrator.service.ts`](https://github.com/tpals0409/algosu/blob/main/services/submission/src/saga/saga-orchestrator.service.ts) (Submission Saga)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_product["Product UI"]
  node_frontend["Next.js App"]
  node_studyui["Study Workspace"]
  node_submitui["Submission Views"]
  node_reviewui["Review Views"]
end

subgraph group_edge["API Gateway"]
  node_gateway["API Gateway"]
  node_oauth["OAuth and Sessions<br/>[oauth.service.ts]"]
end

subgraph group_domains["Domain Services"]
  node_identity["Identity and Studies"]
  node_problem["Problem Management<br/>[problem.service.ts]"]
  node_submission["Submission Service"]
  node_review["Code Reviews<br/>[review.service.ts]"]
end

subgraph group_async["Async Processing"]
  node_saga["Submission Saga"]
  node_githubworker["GitHub Worker<br/>[worker.ts]"]
  node_aiworker["AI Analysis<br/>[main.py]"]
end

subgraph group_state["Data and Events"]
  node_queue["RabbitMQ"]
  node_identitydb[("Identity DB")]
  node_problemdb[("Problem DB")]
  node_submissiondb[("Submission DB")]
  node_redis[("Redis Status")]
end

node_member(("Study Member"))
node_github["GitHub"]
node_claude["Claude API"]

node_member -->|"uses"| node_frontend
node_frontend -->|"calls API"| node_gateway
node_frontend -.->|"opens"| node_studyui
node_frontend -.->|"opens"| node_submitui
node_frontend -.->|"opens"| node_reviewui
node_gateway -.->|"handles login"| node_oauth
node_gateway -->|"routes requests"| node_identity
node_gateway -->|"routes requests"| node_problem
node_gateway -->|"routes requests"| node_submission
node_gateway -->|"proxies reviews"| node_review
node_gateway -->|"reads events"| node_redis
node_identity -->|"stores data"| node_identitydb
node_problem -->|"stores data"| node_problemdb
node_submission -->|"stores submissions"| node_submissiondb
node_submission -.->|"starts workflow"| node_saga
node_saga -->|"publishes jobs"| node_queue
node_queue -->|"dispatches jobs"| node_githubworker
node_queue -->|"dispatches jobs"| node_aiworker
node_githubworker -->|"commits code"| node_github
node_aiworker -->|"requests analysis"| node_claude
node_aiworker -->|"fetches submissions"| node_submission
node_saga -->|"updates status"| node_redis
node_redis -->|"streams events"| node_gateway
node_gateway -->|"sends SSE"| node_frontend
node_review -->|"reads submissions"| node_submissiondb
node_studyui -.->|"loads study data"| node_gateway
node_submitui -.->|"submits code"| node_gateway
node_reviewui -.->|"loads reviews"| node_gateway

click node_frontend "https://github.com/tpals0409/algosu/tree/main/frontend/src/app"
click node_studyui "https://github.com/tpals0409/algosu/tree/main/frontend/src/app/%5Blocale%5D/studies"
click node_submitui "https://github.com/tpals0409/algosu/tree/main/frontend/src/app/%5Blocale%5D/submit"
click node_reviewui "https://github.com/tpals0409/algosu/tree/main/frontend/src/app/%5Blocale%5D/reviews"
click node_gateway "https://github.com/tpals0409/algosu/tree/main/services/gateway/src"
click node_oauth "https://github.com/tpals0409/algosu/blob/main/services/gateway/src/auth/oauth/oauth.service.ts"
click node_identity "https://github.com/tpals0409/algosu/tree/main/services/identity/src"
click node_problem "https://github.com/tpals0409/algosu/blob/main/services/problem/src/problem/problem.service.ts"
click node_submission "https://github.com/tpals0409/algosu/blob/main/services/submission/src/submission/submission.service.ts"
click node_review "https://github.com/tpals0409/algosu/blob/main/services/submission/src/review/review.service.ts"
click node_saga "https://github.com/tpals0409/algosu/blob/main/services/submission/src/saga/saga-orchestrator.service.ts"
click node_githubworker "https://github.com/tpals0409/algosu/blob/main/services/github-worker/src/worker.ts"
click node_aiworker "https://github.com/tpals0409/algosu/blob/main/services/ai-analysis/src/main.py"

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_frontend,node_studyui,node_submitui,node_reviewui toneBlue
class node_gateway,node_oauth toneAmber
class node_identity,node_problem,node_submission,node_review,node_claude toneMint
class node_saga,node_githubworker,node_aiworker toneRose
class node_queue,node_identitydb,node_problemdb,node_submissiondb,node_redis,node_member,node_github toneIndigo
```

## Components

### Product UI

- [Next.js App](https://github.com/tpals0409/algosu/tree/main/frontend/src/app): `frontend/src/app`
- [Study Workspace](https://github.com/tpals0409/algosu/tree/main/frontend/src/app/%5Blocale%5D/studies): `frontend/src/app/[locale]/studies`
- [Submission Views](https://github.com/tpals0409/algosu/tree/main/frontend/src/app/%5Blocale%5D/submit): `frontend/src/app/[locale]/submit`
- [Review Views](https://github.com/tpals0409/algosu/tree/main/frontend/src/app/%5Blocale%5D/reviews): `frontend/src/app/[locale]/reviews`

### API Gateway

- [API Gateway](https://github.com/tpals0409/algosu/tree/main/services/gateway/src): `services/gateway/src`
- [OAuth and Sessions](https://github.com/tpals0409/algosu/blob/main/services/gateway/src/auth/oauth/oauth.service.ts): `services/gateway/src/auth/oauth/oauth.service.ts`

### Domain Services

- [Identity and Studies](https://github.com/tpals0409/algosu/tree/main/services/identity/src): `services/identity/src`
- [Problem Management](https://github.com/tpals0409/algosu/blob/main/services/problem/src/problem/problem.service.ts): `services/problem/src/problem/problem.service.ts`
- [Submission Service](https://github.com/tpals0409/algosu/blob/main/services/submission/src/submission/submission.service.ts): `services/submission/src/submission/submission.service.ts`
- [Code Reviews](https://github.com/tpals0409/algosu/blob/main/services/submission/src/review/review.service.ts): `services/submission/src/review/review.service.ts`

### Async Processing

- [Submission Saga](https://github.com/tpals0409/algosu/blob/main/services/submission/src/saga/saga-orchestrator.service.ts): `services/submission/src/saga/saga-orchestrator.service.ts`
- [GitHub Worker](https://github.com/tpals0409/algosu/blob/main/services/github-worker/src/worker.ts): `services/github-worker/src/worker.ts`
- [AI Analysis](https://github.com/tpals0409/algosu/blob/main/services/ai-analysis/src/main.py): `services/ai-analysis/src/main.py`

### Data and Events

- **RabbitMQ**
- **Identity DB**
- **Problem DB**
- **Submission DB**
- **Redis Status**

### Other components

- **Study Member**
- **GitHub**
- **Claude API**

## Connections

- Study Member → Next.js App: uses (evidence: `README.md`)
- Next.js App → API Gateway: calls API (evidence: `README.md`)
- Next.js App → Study Workspace: opens
- Next.js App → Submission Views: opens
- Next.js App → Review Views: opens
- API Gateway → OAuth and Sessions: handles login (evidence: `services/gateway/src/auth/oauth/oauth.service.ts`)
- API Gateway → Identity and Studies: routes requests (evidence: `README.md`)
- API Gateway → Problem Management: routes requests (evidence: `README.md`)
- API Gateway → Submission Service: routes requests (evidence: `README.md`)
- API Gateway → Code Reviews: proxies reviews (evidence: `services/gateway/src/review/review.controller.ts`)
- API Gateway → Redis Status: reads events (evidence: `README.md`)
- Identity and Studies → Identity DB: stores data (evidence: `README.md`)
- Problem Management → Problem DB: stores data (evidence: `README.md`)
- Submission Service → Submission DB: stores submissions (evidence: `README.md`)
- Submission Service → Submission Saga: starts workflow
- Submission Saga → RabbitMQ: publishes jobs (evidence: `services/submission/src/saga/saga-orchestrator.service.ts`)
- RabbitMQ → GitHub Worker: dispatches jobs (evidence: `README.md`)
- RabbitMQ → AI Analysis: dispatches jobs (evidence: `README.md`)
- GitHub Worker → GitHub: commits code (evidence: `README.md`)
- AI Analysis → Claude API: requests analysis (evidence: `README.md`)
- AI Analysis → Submission Service: fetches submissions (evidence: `services/ai-analysis/src/main.py`)
- Submission Saga → Redis Status: updates status (evidence: `README.md`)
- Redis Status → API Gateway: streams events (evidence: `README.md`)
- API Gateway → Next.js App: sends SSE (evidence: `README.md`)
- Code Reviews → Submission DB: reads submissions (evidence: `services/submission/src/review/review.service.ts`)
- Study Workspace → API Gateway: loads study data
- Submission Views → API Gateway: submits code
- Review Views → API Gateway: loads reviews
