# g3saranath/smart-assignment-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/g3saranath/smart-assignment-tracker
- Repository: https://github.com/g3saranath/smart-assignment-tracker

## Overview

#### Purpose and entry points
Smart Assignment Tracker is a local, single-student assignment workflow: upload a document, normalize it, use Gemini to extract and solve questions, persist progress, and optionally email reminders. The backend REST server starts from `server/src/index.ts`; the React/Vite client starts at `client/src/main.tsx` and is composed primarily in `client/src/App.tsx`. Root scripts in `package.json` run both services.

#### Client interaction layer
The browser UI owns assignment upload, question completion toggles, on-demand solve actions, reminder settings, and rendering of progress and sources. API calls are isolated in `client/src/api.ts`, keeping `client/src/App.tsx` focused on state and presentation. Markdown/answer display and PDF export are separate presentation capabilities in `client/src/Markdown.tsx` and `client/src/exportPdf.ts`.

#### HTTP orchestration boundary
`server/src/index.ts` is the integration boundary between browser requests and domain services. It accepts multipart/document-oriented operations, invokes ingestion and AI workflows, reads/writes persisted records, calculates progress, and exposes notification actions. The client should not directly access Gemini, SMTP, filesystem document conversion, or SQLite.

#### Document ingestion and normalized context
`server/src/ingest.ts` converts uploaded PDF, DOCX, TXT, and Markdown inputs into Markdown/text. This creates the canonical document context consumed by the agent rather than making downstream stages format-aware. Document assets/retention concerns are separated in `server/src/assets.ts`; typed cross-stage models are defined in `server/src/types.ts`.

#### Gemini agent pipeline
`server/src/agent.ts` has two material AI stages:
1. Structured question extraction from normalized assignment content.
2. On-demand solution generation for an individual question using the assignment context plus Gemini Google Search grounding.

The server holds the Gemini API key and model configuration; the browser receives extracted questions, answer text, and source links—not provider credentials or raw provider coupling. Grounding metadata is transformed into displayable sources at this boundary. `server/src/questionContext.ts` prepares/selects the relevant document and question context passed to the solver.

#### Persistence and progress model
SQLite persistence is centralized in `server/src/store.ts`, backed by `server/data.sqlite` at runtime. It stores assignments, normalized content/metadata, question state, answers, and notification state across restarts. `server/src/progress.ts` derives completion counts, remaining work, due-date timing, and status from stored assignment/question records; UI progress indicators and reminder summaries should use these shared calculations.

#### Notifications and runtime infrastructure
`server/src/notify.ts` implements SMTP email delivery and an in-process scheduler. While the Node server is running, it periodically evaluates pending assignments and enforces a minimum reminder interval before sending progress summaries. SMTP credentials and Gemini settings come from environment configuration (`.env.example`); external dependencies are Google Gemini/Google Search grounding and a configured SMTP provider. The runtime is Node 18+ with Express, React 18/Vite, and better-sqlite3.

Main entry points: [`server/src/index.ts`](https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/index.ts) (REST server), [`server/src/store.ts`](https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/store.ts) (SQLite store), [`server/src/agent.ts`](https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/agent.ts) (Gemini agent), [`server/src/notify.ts`](https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/notify.ts) (Reminder scheduler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser client"]
  node_client_main["Vite entry<br/>React entry<br/>[main.tsx]"]
  node_client_app["Assignment UI<br/>React application<br/>[App.tsx]"]
  node_client_api["API client<br/>HTTP adapter<br/>[api.ts]"]
  node_markdown_view["Answer renderer<br/>Markdown presentation<br/>[Markdown.tsx]"]
  node_pdf_export["PDF export<br/>presentation export<br/>[exportPdf.ts]"]
end

subgraph group_server["Node server"]
  node_server_entry{{"REST server<br/>Express integration boundary<br/>[index.ts]"}}
  node_ingest["Document ingestion<br/>normalization service<br/>[ingest.ts]"]
  node_assets["Document assets<br/>asset retention<br/>[assets.ts]"]
  node_agent{{"Gemini agent<br/>AI workflow<br/>[agent.ts]"}}
  node_question_context["Question context<br/>context selector<br/>[questionContext.ts]"]
  node_store[("SQLite store<br/>persistence service<br/>[store.ts]")]
  node_progress["Progress model<br/>derived state<br/>[progress.ts]"]
  node_notify["Reminder scheduler<br/>SMTP notification service<br/>[notify.ts]"]
  node_models["Shared models<br/>TypeScript contracts<br/>[types.ts]"]
  node_sqlite_file[("Assignment database<br/>SQLite runtime file")]
end

subgraph group_external["Runtime dependencies"]
  node_gemini(("Gemini + Search grounding<br/>AI provider"))
  node_smtp(("SMTP provider<br/>email provider"))
  node_environment["Environment settings<br/>credentials configuration<br/>[.env.example]"]
end

node_root_scripts["Root scripts<br/>service launcher<br/>[package.json]"]

node_root_scripts -->|"starts"| node_client_main
node_root_scripts -->|"starts"| node_server_entry
node_client_main -->|"mounts"| node_client_app
node_client_app -->|"uses"| node_client_api
node_client_app -->|"renders answers"| node_markdown_view
node_client_app -->|"exports"| node_pdf_export
node_client_api -->|"REST requests"| node_server_entry
node_server_entry -->|"uploads"| node_ingest
node_ingest -->|"retains documents"| node_assets
node_ingest -->|"normalized context"| node_agent
node_server_entry -->|"extracts and solves"| node_agent
node_question_context -->|"solver context"| node_agent
node_store -->|"assignment records"| node_question_context
node_agent -->|"generation and grounding"| node_gemini
node_server_entry -->|"reads and writes"| node_store
node_store -->|"persists"| node_sqlite_file
node_store -->|"assignment state"| node_progress
node_progress -->|"status summaries"| node_server_entry
node_notify -->|"evaluates pending work"| node_store
node_notify -->|"builds summaries"| node_progress
node_server_entry -->|"notification actions"| node_notify
node_notify -->|"sends email"| node_smtp
node_environment -.->|"Gemini settings"| node_agent
node_environment -.->|"SMTP settings"| node_notify
node_models -.->|"contracts"| node_ingest
node_models -.->|"contracts"| node_agent
node_models -.->|"contracts"| node_store

click node_client_main "https://github.com/g3saranath/smart-assignment-tracker/blob/main/client/src/main.tsx"
click node_client_app "https://github.com/g3saranath/smart-assignment-tracker/blob/main/client/src/App.tsx"
click node_client_api "https://github.com/g3saranath/smart-assignment-tracker/blob/main/client/src/api.ts"
click node_markdown_view "https://github.com/g3saranath/smart-assignment-tracker/blob/main/client/src/Markdown.tsx"
click node_pdf_export "https://github.com/g3saranath/smart-assignment-tracker/blob/main/client/src/exportPdf.ts"
click node_server_entry "https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/index.ts"
click node_ingest "https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/ingest.ts"
click node_assets "https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/assets.ts"
click node_agent "https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/agent.ts"
click node_question_context "https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/questionContext.ts"
click node_store "https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/store.ts"
click node_progress "https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/progress.ts"
click node_notify "https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/notify.ts"
click node_models "https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/types.ts"
click node_environment "https://github.com/g3saranath/smart-assignment-tracker/blob/main/.env.example"
click node_root_scripts "https://github.com/g3saranath/smart-assignment-tracker/blob/main/package.json"

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_client_main,node_client_app,node_client_api,node_markdown_view,node_pdf_export toneBlue
class node_server_entry,node_ingest,node_assets,node_agent,node_question_context,node_store,node_progress,node_notify,node_models,node_sqlite_file toneAmber
class node_gemini,node_smtp,node_environment toneMint
class node_root_scripts toneNeutral
```

## Components

### Browser client

- [Vite entry](https://github.com/g3saranath/smart-assignment-tracker/blob/main/client/src/main.tsx): React entry · `client/src/main.tsx`
- [Assignment UI](https://github.com/g3saranath/smart-assignment-tracker/blob/main/client/src/App.tsx): React application · Owns upload, progress, solve, and reminder interactions. · `client/src/App.tsx`
- [API client](https://github.com/g3saranath/smart-assignment-tracker/blob/main/client/src/api.ts): HTTP adapter · `client/src/api.ts`
- [Answer renderer](https://github.com/g3saranath/smart-assignment-tracker/blob/main/client/src/Markdown.tsx): Markdown presentation · `client/src/Markdown.tsx`
- [PDF export](https://github.com/g3saranath/smart-assignment-tracker/blob/main/client/src/exportPdf.ts): presentation export · `client/src/exportPdf.ts`

### Node server

- [REST server](https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/index.ts): Express integration boundary · Coordinates browser requests with domain workflows. · `server/src/index.ts`
- [Document ingestion](https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/ingest.ts): normalization service · Converts PDF, DOCX, TXT, and Markdown into canonical text. · `server/src/ingest.ts`
- [Document assets](https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/assets.ts): asset retention · `server/src/assets.ts`
- [Gemini agent](https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/agent.ts): AI workflow · Extracts structured questions and generates grounded solutions. · `server/src/agent.ts`
- [Question context](https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/questionContext.ts): context selector · `server/src/questionContext.ts`
- [SQLite store](https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/store.ts): persistence service · Persists assignments, content, questions, answers, and notification state. · `server/src/store.ts`
- [Progress model](https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/progress.ts): derived state · Calculates completion, remaining work, due timing, and status. · `server/src/progress.ts`
- [Reminder scheduler](https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/notify.ts): SMTP notification service · Periodically sends rate-limited pending-assignment summaries. · `server/src/notify.ts`
- [Shared models](https://github.com/g3saranath/smart-assignment-tracker/blob/main/server/src/types.ts): TypeScript contracts · `server/src/types.ts`
- **Assignment database**: SQLite runtime file

### Runtime dependencies

- **Gemini + Search grounding**: AI provider
- **SMTP provider**: email provider
- [Environment settings](https://github.com/g3saranath/smart-assignment-tracker/blob/main/.env.example): credentials configuration · Supplies Gemini and SMTP credentials. · `.env.example`

### Other components

- [Root scripts](https://github.com/g3saranath/smart-assignment-tracker/blob/main/package.json): service launcher · Runs the client and server together. · `package.json`

## Connections

- Root scripts → Vite entry: starts
- Root scripts → REST server: starts
- Vite entry → Assignment UI: mounts
- Assignment UI → API client: uses
- Assignment UI → Answer renderer: renders answers
- Assignment UI → PDF export: exports
- API client → REST server: REST requests
- REST server → Document ingestion: uploads
- Document ingestion → Document assets: retains documents
- Document ingestion → Gemini agent: normalized context
- REST server → Gemini agent: extracts and solves
- Question context → Gemini agent: solver context
- SQLite store → Question context: assignment records
- Gemini agent → Gemini + Search grounding: generation and grounding
- REST server → SQLite store: reads and writes
- SQLite store → Assignment database: persists
- SQLite store → Progress model: assignment state
- Progress model → REST server: status summaries
- Reminder scheduler → SQLite store: evaluates pending work
- Reminder scheduler → Progress model: builds summaries
- REST server → Reminder scheduler: notification actions
- Reminder scheduler → SMTP provider: sends email
- Environment settings → Gemini agent: Gemini settings
- Environment settings → Reminder scheduler: SMTP settings
- Shared models → Document ingestion: contracts
- Shared models → Gemini agent: contracts
- Shared models → SQLite store: contracts
