# rj-cloud-sg/posthaven architecture

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

- Interactive diagram: https://gitdiagram.com/rj-cloud-sg/posthaven
- Repository: https://github.com/rj-cloud-sg/posthaven

## Overview

This is a FastAPI blog application: visitors browse rendered post pages or use the API to list and manage posts and accounts. The main app routes requests to post and user APIs; handlers validate input, apply authentication where required, and access persisted users, posts, and reset tokens. Account workflows include password reset email and profile-image processing. The source excerpts show these backend relationships; README content is absent, so additional capabilities are not inferred.

Main entry points: [`routers/users.py`](https://github.com/rj-cloud-sg/posthaven/blob/main/routers/users.py) (User API), [`main.py`](https://github.com/rj-cloud-sg/posthaven/blob/main/main.py) (Web app and pages), [`routers/posts.py`](https://github.com/rj-cloud-sg/posthaven/blob/main/routers/posts.py) (Post API), [`auth.py`](https://github.com/rj-cloud-sg/posthaven/blob/main/auth.py) (Authentication and tokens)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Web app and pages<br/>[main.py]"]
  node_templates["Page templates"]
  node_static["Browser assets"]
end

subgraph group_domain["Blog and accounts"]
  node_post_api["Post API<br/>[posts.py]"]
  node_user_api["User API<br/>[users.py]"]
  node_schemas["Request and response schemas<br/>[schemas.py]"]
  node_auth["Authentication and tokens<br/>[auth.py]"]
  node_models["Blog and account models<br/>[models.py]"]
end

subgraph group_platform["Persistence and configuration"]
  node_database[("Async database sessions<br/>[database.py]")]
  node_config["Application settings<br/>[config.py]"]
end

subgraph group_integrations["Account integrations"]
  node_image["Profile image processing<br/>[image_utils.py]"]
  node_email["Password reset email<br/>[email_utils.py]"]
end

node_visitor(("Visitor"))
node_smtp{{"SMTP service"}}

node_visitor -->|"sends requests"| node_app
node_app -->|"registers routes"| node_post_api
node_app -->|"registers routes"| node_user_api
node_app -->|"queries pages"| node_database
node_app -->|"queries posts"| node_models
node_app -->|"renders pages"| node_templates
node_visitor -.->|"loads assets"| node_static
node_post_api -->|"reads and writes"| node_database
node_post_api -->|"queries posts"| node_models
node_post_api -->|"requires identity"| node_auth
node_post_api -->|"validates and returns"| node_schemas
node_user_api -->|"reads and writes"| node_database
node_user_api -->|"queries accounts"| node_models
node_user_api -->|"uses token helpers"| node_auth
node_user_api -->|"validates and returns"| node_schemas
node_user_api -->|"sends reset email"| node_email
node_user_api -->|"processes images"| node_image
node_auth -->|"looks up users"| node_database
node_auth -->|"loads user model"| node_models
node_auth -->|"uses token settings"| node_config
node_models -->|"declares mappings"| node_database
node_email -->|"uses mail settings"| node_config
node_email -->|"sends messages"| node_smtp

click node_app "https://github.com/rj-cloud-sg/posthaven/blob/main/main.py"
click node_templates "https://github.com/rj-cloud-sg/posthaven/tree/main/templates"
click node_static "https://github.com/rj-cloud-sg/posthaven/tree/main/static"
click node_post_api "https://github.com/rj-cloud-sg/posthaven/blob/main/routers/posts.py"
click node_user_api "https://github.com/rj-cloud-sg/posthaven/blob/main/routers/users.py"
click node_schemas "https://github.com/rj-cloud-sg/posthaven/blob/main/schemas.py"
click node_auth "https://github.com/rj-cloud-sg/posthaven/blob/main/auth.py"
click node_models "https://github.com/rj-cloud-sg/posthaven/blob/main/models.py"
click node_database "https://github.com/rj-cloud-sg/posthaven/blob/main/database.py"
click node_config "https://github.com/rj-cloud-sg/posthaven/blob/main/config.py"
click node_image "https://github.com/rj-cloud-sg/posthaven/blob/main/image_utils.py"
click node_email "https://github.com/rj-cloud-sg/posthaven/blob/main/email_utils.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_templates,node_static toneBlue
class node_post_api,node_user_api,node_schemas,node_auth,node_models toneAmber
class node_database,node_config toneMint
class node_image,node_email toneRose
class node_visitor,node_smtp toneIndigo
```

## Components

### Web application

- [Web app and pages](https://github.com/rj-cloud-sg/posthaven/blob/main/main.py): `main.py`
- [Page templates](https://github.com/rj-cloud-sg/posthaven/tree/main/templates): `templates`
- [Browser assets](https://github.com/rj-cloud-sg/posthaven/tree/main/static): `static`

### Blog and accounts

- [Post API](https://github.com/rj-cloud-sg/posthaven/blob/main/routers/posts.py): `routers/posts.py`
- [User API](https://github.com/rj-cloud-sg/posthaven/blob/main/routers/users.py): `routers/users.py`
- [Request and response schemas](https://github.com/rj-cloud-sg/posthaven/blob/main/schemas.py): `schemas.py`
- [Authentication and tokens](https://github.com/rj-cloud-sg/posthaven/blob/main/auth.py): `auth.py`
- [Blog and account models](https://github.com/rj-cloud-sg/posthaven/blob/main/models.py): `models.py`

### Persistence and configuration

- [Async database sessions](https://github.com/rj-cloud-sg/posthaven/blob/main/database.py): `database.py`
- [Application settings](https://github.com/rj-cloud-sg/posthaven/blob/main/config.py): `config.py`

### Account integrations

- [Profile image processing](https://github.com/rj-cloud-sg/posthaven/blob/main/image_utils.py): `image_utils.py`
- [Password reset email](https://github.com/rj-cloud-sg/posthaven/blob/main/email_utils.py): `email_utils.py`

### Other components

- **Visitor**
- **SMTP service**

## Connections

- Visitor → Web app and pages: sends requests (evidence: `main.py`)
- Web app and pages → Post API: registers routes (evidence: `main.py`)
- Web app and pages → User API: registers routes (evidence: `main.py`)
- Web app and pages → Async database sessions: queries pages (evidence: `main.py`)
- Web app and pages → Blog and account models: queries posts (evidence: `main.py`)
- Web app and pages → Page templates: renders pages (evidence: `main.py`)
- Visitor → Browser assets: loads assets
- Post API → Async database sessions: reads and writes (evidence: `routers/posts.py`)
- Post API → Blog and account models: queries posts (evidence: `routers/posts.py`)
- Post API → Authentication and tokens: requires identity (evidence: `routers/posts.py`)
- Post API → Request and response schemas: validates and returns (evidence: `routers/posts.py`)
- User API → Async database sessions: reads and writes (evidence: `routers/users.py`)
- User API → Blog and account models: queries accounts (evidence: `routers/users.py`)
- User API → Authentication and tokens: uses token helpers (evidence: `routers/users.py`)
- User API → Request and response schemas: validates and returns (evidence: `routers/users.py`)
- User API → Password reset email: sends reset email (evidence: `routers/users.py`)
- User API → Profile image processing: processes images (evidence: `routers/users.py`)
- Authentication and tokens → Async database sessions: looks up users (evidence: `auth.py`)
- Authentication and tokens → Blog and account models: loads user model (evidence: `auth.py`)
- Authentication and tokens → Application settings: uses token settings (evidence: `auth.py`)
- Blog and account models → Async database sessions: declares mappings (evidence: `models.py`)
- Password reset email → Application settings: uses mail settings (evidence: `email_utils.py`)
- Password reset email → SMTP service: sends messages (evidence: `email_utils.py`)
