# littleapple0228/guava architecture

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

- Interactive diagram: https://gitdiagram.com/littleapple0228/guava
- Repository: https://github.com/littleapple0228/guava

## Overview

This is a FastAPI submission-review platform for authors and editors. Users register or log in to obtain a bearer token; authors create and submit drafts, and editors review submissions by approving or returning them to editing. The application serves a static frontend and initializes the database and default accounts at startup. The excerpts show route registration, authorization dependencies, and database operations; they do not show frontend API calls, so no frontend-to-API relationship is asserted.

Main entry points: [`main.py`](https://github.com/littleapple0228/guava/blob/main/main.py) (FastAPI application), [`database.py`](https://github.com/littleapple0228/guava/blob/main/database.py) (Database session and engine), [`auth.py`](https://github.com/littleapple0228/guava/blob/main/auth.py) (Authentication and roles), [`routers/users.py`](https://github.com/littleapple0228/guava/blob/main/routers/users.py) (Account endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_application["Application"]
  node_app["FastAPI application<br/>[main.py]"]
  node_frontend["Static frontend<br/>[index.html]"]
end

subgraph group_identity["Identity"]
  node_accounts["Account endpoints<br/>[users.py]"]
  node_auth["Authentication and roles<br/>[auth.py]"]
end

subgraph group_workflow["Submission Workflow"]
  node_author["Author submissions<br/>[author.py]"]
  node_editor["Editor review<br/>[editor.py]"]
end

subgraph group_persistence["Domain and Persistence"]
  node_domain["User and submission models<br/>[models.py]"]
  node_database["Database session and engine<br/>[database.py]"]
  node_postgres[("PostgreSQL database")]
end

node_visitor(("Web user"))

node_visitor -.->|"uses"| node_app
node_app -->|"serves"| node_frontend
node_app -->|"registers routes"| node_accounts
node_app -->|"registers routes"| node_author
node_app -->|"registers routes"| node_editor
node_accounts -->|"creates tokens"| node_auth
node_auth -->|"loads session"| node_database
node_accounts -->|"queries and writes"| node_database
node_author -->|"requires author"| node_auth
node_editor -->|"requires editor"| node_auth
node_author -->|"reads and writes"| node_database
node_editor -->|"reads and writes"| node_database
node_accounts -->|"uses schemas"| node_domain
node_author -->|"uses submission models"| node_domain
node_editor -->|"uses submission models"| node_domain
node_auth -->|"loads user model"| node_domain
node_app -->|"initializes schema"| node_database
node_database -->|"connects to"| node_postgres

click node_app "https://github.com/littleapple0228/guava/blob/main/main.py"
click node_frontend "https://github.com/littleapple0228/guava/blob/main/static/index.html"
click node_accounts "https://github.com/littleapple0228/guava/blob/main/routers/users.py"
click node_auth "https://github.com/littleapple0228/guava/blob/main/auth.py"
click node_author "https://github.com/littleapple0228/guava/blob/main/routers/author.py"
click node_editor "https://github.com/littleapple0228/guava/blob/main/routers/editor.py"
click node_domain "https://github.com/littleapple0228/guava/blob/main/models.py"
click node_database "https://github.com/littleapple0228/guava/blob/main/database.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_app,node_frontend,node_visitor toneBlue
class node_accounts,node_auth toneAmber
class node_author,node_editor toneMint
class node_domain,node_database,node_postgres toneRose
```

## Components

### Application

- [FastAPI application](https://github.com/littleapple0228/guava/blob/main/main.py): `main.py`
- [Static frontend](https://github.com/littleapple0228/guava/blob/main/static/index.html): `static/index.html`

### Identity

- [Account endpoints](https://github.com/littleapple0228/guava/blob/main/routers/users.py): `routers/users.py`
- [Authentication and roles](https://github.com/littleapple0228/guava/blob/main/auth.py): `auth.py`

### Submission Workflow

- [Author submissions](https://github.com/littleapple0228/guava/blob/main/routers/author.py): `routers/author.py`
- [Editor review](https://github.com/littleapple0228/guava/blob/main/routers/editor.py): `routers/editor.py`

### Domain and Persistence

- [User and submission models](https://github.com/littleapple0228/guava/blob/main/models.py): `models.py`
- [Database session and engine](https://github.com/littleapple0228/guava/blob/main/database.py): `database.py`
- **PostgreSQL database**

### Other components

- **Web user**

## Connections

- Web user → FastAPI application: uses
- FastAPI application → Static frontend: serves (evidence: `main.py`)
- FastAPI application → Account endpoints: registers routes (evidence: `main.py`)
- FastAPI application → Author submissions: registers routes (evidence: `main.py`)
- FastAPI application → Editor review: registers routes (evidence: `main.py`)
- Account endpoints → Authentication and roles: creates tokens (evidence: `routers/users.py`)
- Authentication and roles → Database session and engine: loads session (evidence: `auth.py`)
- Account endpoints → Database session and engine: queries and writes (evidence: `routers/users.py`)
- Author submissions → Authentication and roles: requires author (evidence: `routers/author.py`)
- Editor review → Authentication and roles: requires editor (evidence: `routers/editor.py`)
- Author submissions → Database session and engine: reads and writes (evidence: `routers/author.py`)
- Editor review → Database session and engine: reads and writes (evidence: `routers/editor.py`)
- Account endpoints → User and submission models: uses schemas (evidence: `routers/users.py`)
- Author submissions → User and submission models: uses submission models (evidence: `routers/author.py`)
- Editor review → User and submission models: uses submission models (evidence: `routers/editor.py`)
- Authentication and roles → User and submission models: loads user model (evidence: `auth.py`)
- FastAPI application → Database session and engine: initializes schema (evidence: `main.py`)
- Database session and engine → PostgreSQL database: connects to (evidence: `database.py`)
