# suran2022/porten architecture

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

- Interactive diagram: https://gitdiagram.com/suran2022/porten
- Repository: https://github.com/suran2022/porten

## Overview

Porten is a cross-platform community and messaging product for transgender users. Users authenticate, connect with friends or groups, exchange text and media in real time, and can also record emotion diaries, explore knowledge and support resources, share music, and manage profiles. The React client presents these workflows and keeps chat state; its API layer communicates with FastAPI, whose domain services operate on MySQL-backed models. WebSocket delivery supports live messaging. README-listed capabilities are included, but detailed wiring for several unsampled feature modules is not inferred.

Main entry points: [`backend/app/main.py`](https://github.com/suran2022/porten/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/database.py`](https://github.com/suran2022/porten/blob/main/backend/app/database.py) (Database sessions), [`frontend/src/pages/HomePage.tsx`](https://github.com/suran2022/porten/blob/main/frontend/src/pages/HomePage.tsx) (Community workspace), [`frontend/src/lib/api.ts`](https://github.com/suran2022/porten/blob/main/frontend/src/lib/api.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["Application routes<br/>[App.tsx]"]
  node_authui["Login and registration<br/>[LoginPage.tsx]"]
  node_homeui["Community workspace<br/>[HomePage.tsx]"]
  node_chatui["Chat interface<br/>[ChatPage.tsx]"]
  node_profileui["Profile and settings<br/>[ProfilePage.tsx]"]
  node_knowledgeui["Knowledge and sharing<br/>[KnowledgeView.tsx]"]
  node_resourcesui["Resource center<br/>[ResourceView.tsx]"]
  node_diaryui["Emotion diary"]
  node_musicui["Music sharing<br/>[MusicView.tsx]"]
  node_authstate["Authentication state<br/>[authStore.ts]"]
  node_chatstate["Chat state<br/>[chatStore.ts]"]
  node_messages["Message state<br/>[messageStore.ts]"]
  node_api_client["API client<br/>[api.ts]"]
  node_localcache[("Local message cache")]
end

subgraph group_api["API and identity"]
  node_backend["FastAPI application<br/>[main.py]"]
  node_authroutes["Authentication routes<br/>[auth.py]"]
  node_account["Account services<br/>[user_service.py]"]
  node_wsroute["WebSocket endpoint<br/>[websocket.py]"]
end

subgraph group_community["Community services"]
  node_contactroutes["Contacts and requests<br/>[contacts.py]"]
  node_groups["Group services<br/>[group_service.py]"]
  node_conversation["Conversation services"]
  node_message["Message services<br/>[message_service.py]"]
  node_search["Global search<br/>[search_service.py]"]
end

subgraph group_support["Wellbeing and resources"]
  node_diary["Diary services"]
  node_assistant["Assistant articles"]
  node_notifications["Notifications"]
  node_systemmessages["System messages"]
  node_email["Email delivery<br/>[email_service.py]"]
end

subgraph group_data["Persistence and delivery"]
  node_dbsession["Database sessions<br/>[database.py]"]
  node_models["Domain models"]
  node_mysql[("MySQL database")]
  node_wsmanager["Connection manager"]
end

node_user(("Community member"))
node_smtp(("SMTP service"))

node_user -->|"opens"| node_app
node_app -->|"routes unauthenticated"| node_authui
node_app -->|"protects route"| node_homeui
node_authui -->|"submits auth"| node_api_client
node_homeui -->|"hosts chat"| node_chatui
node_homeui -->|"hosts profile"| node_profileui
node_homeui -->|"hosts knowledge"| node_knowledgeui
node_homeui -->|"hosts resources"| node_resourcesui
node_homeui -->|"hosts diary"| node_diaryui
node_homeui -->|"hosts music"| node_musicui
node_chatui -->|"uses state"| node_chatstate
node_chatui -->|"uses state"| node_messages
node_profileui -->|"requests data"| node_api_client
node_knowledgeui -.->|"requests data"| node_api_client
node_resourcesui -.->|"requests data"| node_api_client
node_diaryui -->|"requests data"| node_api_client
node_musicui -.->|"shares links"| node_api_client
node_messages -->|"caches messages"| node_localcache
node_api_client -->|"HTTP requests"| node_backend
node_authstate -->|"authenticates requests"| node_api_client
node_backend -->|"dispatches auth"| node_authroutes
node_backend -->|"dispatches contacts"| node_contactroutes
node_backend -->|"dispatches group routes"| node_groups
node_backend -->|"dispatches conversation routes"| node_conversation
node_backend -->|"dispatches message routes"| node_message
node_backend -->|"dispatches search routes"| node_search
node_backend -->|"dispatches diary routes"| node_diary
node_backend -->|"dispatches assistant routes"| node_assistant
node_backend -->|"dispatches notification routes"| node_notifications
node_backend -->|"dispatches system routes"| node_systemmessages
node_backend -->|"registers websocket"| node_wsroute
node_authroutes -->|"calls"| node_account
node_authroutes -->|"sends codes"| node_email
node_email -->|"sends mail"| node_smtp
node_groups -->|"creates conversations"| node_conversation
node_groups -->|"broadcasts system messages"| node_message
node_message -->|"pushes messages"| node_wsmanager
node_wsroute -->|"manages connections"| node_wsmanager
node_wsmanager -->|"delivers live events"| node_user
node_dbsession -->|"opens sessions"| node_mysql
node_authroutes -->|"uses session"| node_dbsession
node_groups -->|"uses session"| node_dbsession
node_conversation -->|"uses session"| node_dbsession
node_message -->|"uses session"| node_dbsession
node_search -->|"queries"| node_dbsession
node_diary -->|"uses session"| node_dbsession
node_assistant -->|"uses session"| node_dbsession
node_notifications -->|"uses session"| node_dbsession

click node_app "https://github.com/suran2022/porten/blob/main/frontend/src/App.tsx"
click node_authui "https://github.com/suran2022/porten/blob/main/frontend/src/pages/LoginPage.tsx"
click node_homeui "https://github.com/suran2022/porten/blob/main/frontend/src/pages/HomePage.tsx"
click node_chatui "https://github.com/suran2022/porten/blob/main/frontend/src/components/home/ChatPage.tsx"
click node_profileui "https://github.com/suran2022/porten/blob/main/frontend/src/components/profile/ProfilePage.tsx"
click node_knowledgeui "https://github.com/suran2022/porten/blob/main/frontend/src/components/knowledge/KnowledgeView.tsx"
click node_resourcesui "https://github.com/suran2022/porten/blob/main/frontend/src/components/resource/ResourceView.tsx"
click node_diaryui "https://github.com/suran2022/porten/blob/main/frontend/src/components/home/EmotionDiaryPage.tsx"
click node_musicui "https://github.com/suran2022/porten/blob/main/frontend/src/components/music/MusicView.tsx"
click node_authstate "https://github.com/suran2022/porten/blob/main/frontend/src/store/authStore.ts"
click node_chatstate "https://github.com/suran2022/porten/blob/main/frontend/src/store/chatStore.ts"
click node_messages "https://github.com/suran2022/porten/blob/main/frontend/src/store/messageStore.ts"
click node_api_client "https://github.com/suran2022/porten/blob/main/frontend/src/lib/api.ts"
click node_localcache "https://github.com/suran2022/porten/blob/main/frontend/src/lib/localMessageStore.ts"
click node_backend "https://github.com/suran2022/porten/blob/main/backend/app/main.py"
click node_authroutes "https://github.com/suran2022/porten/blob/main/backend/app/routers/auth.py"
click node_account "https://github.com/suran2022/porten/blob/main/backend/app/services/user_service.py"
click node_contactroutes "https://github.com/suran2022/porten/blob/main/backend/app/routers/contacts.py"
click node_groups "https://github.com/suran2022/porten/blob/main/backend/app/services/group_service.py"
click node_conversation "https://github.com/suran2022/porten/blob/main/backend/app/services/conversation_service.py"
click node_message "https://github.com/suran2022/porten/blob/main/backend/app/services/message_service.py"
click node_search "https://github.com/suran2022/porten/blob/main/backend/app/services/search_service.py"
click node_diary "https://github.com/suran2022/porten/blob/main/backend/app/services/emotion_diary_service.py"
click node_assistant "https://github.com/suran2022/porten/blob/main/backend/app/services/assistant_article_service.py"
click node_notifications "https://github.com/suran2022/porten/blob/main/backend/app/services/notification_service.py"
click node_systemmessages "https://github.com/suran2022/porten/blob/main/backend/app/services/system_message_service.py"
click node_email "https://github.com/suran2022/porten/blob/main/backend/app/services/email_service.py"
click node_dbsession "https://github.com/suran2022/porten/blob/main/backend/app/database.py"
click node_models "https://github.com/suran2022/porten/tree/main/backend/app/models"
click node_wsroute "https://github.com/suran2022/porten/blob/main/backend/app/routers/websocket.py"
click node_wsmanager "https://github.com/suran2022/porten/blob/main/backend/app/services/websocket_manager.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_authui,node_homeui,node_chatui,node_profileui,node_knowledgeui,node_resourcesui,node_diaryui,node_musicui,node_authstate,node_chatstate,node_messages,node_api_client,node_localcache toneBlue
class node_backend,node_authroutes,node_account,node_wsroute toneAmber
class node_contactroutes,node_groups,node_conversation,node_message,node_search toneMint
class node_diary,node_assistant,node_notifications,node_systemmessages,node_email toneRose
class node_dbsession,node_models,node_mysql,node_wsmanager,node_user,node_smtp toneIndigo
```

## Components

### Web client

- [Application routes](https://github.com/suran2022/porten/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Login and registration](https://github.com/suran2022/porten/blob/main/frontend/src/pages/LoginPage.tsx): `frontend/src/pages/LoginPage.tsx`
- [Community workspace](https://github.com/suran2022/porten/blob/main/frontend/src/pages/HomePage.tsx): `frontend/src/pages/HomePage.tsx`
- [Chat interface](https://github.com/suran2022/porten/blob/main/frontend/src/components/home/ChatPage.tsx): `frontend/src/components/home/ChatPage.tsx`
- [Profile and settings](https://github.com/suran2022/porten/blob/main/frontend/src/components/profile/ProfilePage.tsx): `frontend/src/components/profile/ProfilePage.tsx`
- [Knowledge and sharing](https://github.com/suran2022/porten/blob/main/frontend/src/components/knowledge/KnowledgeView.tsx): `frontend/src/components/knowledge/KnowledgeView.tsx`
- [Resource center](https://github.com/suran2022/porten/blob/main/frontend/src/components/resource/ResourceView.tsx): `frontend/src/components/resource/ResourceView.tsx`
- [Emotion diary](https://github.com/suran2022/porten/blob/main/frontend/src/components/home/EmotionDiaryPage.tsx): `frontend/src/components/home/EmotionDiaryPage.tsx`
- [Music sharing](https://github.com/suran2022/porten/blob/main/frontend/src/components/music/MusicView.tsx): `frontend/src/components/music/MusicView.tsx`
- [Authentication state](https://github.com/suran2022/porten/blob/main/frontend/src/store/authStore.ts): `frontend/src/store/authStore.ts`
- [Chat state](https://github.com/suran2022/porten/blob/main/frontend/src/store/chatStore.ts): `frontend/src/store/chatStore.ts`
- [Message state](https://github.com/suran2022/porten/blob/main/frontend/src/store/messageStore.ts): `frontend/src/store/messageStore.ts`
- [API client](https://github.com/suran2022/porten/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`
- [Local message cache](https://github.com/suran2022/porten/blob/main/frontend/src/lib/localMessageStore.ts): `frontend/src/lib/localMessageStore.ts`

### API and identity

- [FastAPI application](https://github.com/suran2022/porten/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication routes](https://github.com/suran2022/porten/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [Account services](https://github.com/suran2022/porten/blob/main/backend/app/services/user_service.py): `backend/app/services/user_service.py`
- [WebSocket endpoint](https://github.com/suran2022/porten/blob/main/backend/app/routers/websocket.py): `backend/app/routers/websocket.py`

### Community services

- [Contacts and requests](https://github.com/suran2022/porten/blob/main/backend/app/routers/contacts.py): `backend/app/routers/contacts.py`
- [Group services](https://github.com/suran2022/porten/blob/main/backend/app/services/group_service.py): `backend/app/services/group_service.py`
- [Conversation services](https://github.com/suran2022/porten/blob/main/backend/app/services/conversation_service.py): `backend/app/services/conversation_service.py`
- [Message services](https://github.com/suran2022/porten/blob/main/backend/app/services/message_service.py): `backend/app/services/message_service.py`
- [Global search](https://github.com/suran2022/porten/blob/main/backend/app/services/search_service.py): `backend/app/services/search_service.py`

### Wellbeing and resources

- [Diary services](https://github.com/suran2022/porten/blob/main/backend/app/services/emotion_diary_service.py): `backend/app/services/emotion_diary_service.py`
- [Assistant articles](https://github.com/suran2022/porten/blob/main/backend/app/services/assistant_article_service.py): `backend/app/services/assistant_article_service.py`
- [Notifications](https://github.com/suran2022/porten/blob/main/backend/app/services/notification_service.py): `backend/app/services/notification_service.py`
- [System messages](https://github.com/suran2022/porten/blob/main/backend/app/services/system_message_service.py): `backend/app/services/system_message_service.py`
- [Email delivery](https://github.com/suran2022/porten/blob/main/backend/app/services/email_service.py): `backend/app/services/email_service.py`

### Persistence and delivery

- [Database sessions](https://github.com/suran2022/porten/blob/main/backend/app/database.py): `backend/app/database.py`
- [Domain models](https://github.com/suran2022/porten/tree/main/backend/app/models): `backend/app/models`
- **MySQL database**
- [Connection manager](https://github.com/suran2022/porten/blob/main/backend/app/services/websocket_manager.py): `backend/app/services/websocket_manager.py`

### Other components

- **Community member**
- **SMTP service**

## Connections

- Community member → Application routes: opens
- Application routes → Login and registration: routes unauthenticated
- Application routes → Community workspace: protects route
- Login and registration → API client: submits auth
- Community workspace → Chat interface: hosts chat
- Community workspace → Profile and settings: hosts profile
- Community workspace → Knowledge and sharing: hosts knowledge
- Community workspace → Resource center: hosts resources
- Community workspace → Emotion diary: hosts diary
- Community workspace → Music sharing: hosts music
- Chat interface → Chat state: uses state
- Chat interface → Message state: uses state
- Profile and settings → API client: requests data
- Knowledge and sharing → API client: requests data
- Resource center → API client: requests data
- Emotion diary → API client: requests data
- Music sharing → API client: shares links
- Message state → Local message cache: caches messages
- API client → FastAPI application: HTTP requests
- Authentication state → API client: authenticates requests
- FastAPI application → Authentication routes: dispatches auth
- FastAPI application → Contacts and requests: dispatches contacts
- FastAPI application → Group services: dispatches group routes
- FastAPI application → Conversation services: dispatches conversation routes
- FastAPI application → Message services: dispatches message routes
- FastAPI application → Global search: dispatches search routes
- FastAPI application → Diary services: dispatches diary routes
- FastAPI application → Assistant articles: dispatches assistant routes
- FastAPI application → Notifications: dispatches notification routes
- FastAPI application → System messages: dispatches system routes
- FastAPI application → WebSocket endpoint: registers websocket
- Authentication routes → Account services: calls
- Authentication routes → Email delivery: sends codes
- Email delivery → SMTP service: sends mail
- Group services → Conversation services: creates conversations
- Group services → Message services: broadcasts system messages
- Message services → Connection manager: pushes messages
- WebSocket endpoint → Connection manager: manages connections
- Connection manager → Community member: delivers live events
- Database sessions → MySQL database: opens sessions
- Authentication routes → Database sessions: uses session
- Group services → Database sessions: uses session
- Conversation services → Database sessions: uses session
- Message services → Database sessions: uses session
- Global search → Database sessions: queries
- Diary services → Database sessions: uses session
- Assistant articles → Database sessions: uses session
- Notifications → Database sessions: uses session
