# devansh3712/tsuki architecture

> Architecture diagram of the GitHub repository devansh3712/tsuki, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/devansh3712/tsuki
- Repository: https://github.com/devansh3712/tsuki

## Overview

##### Main Components Identification

a) Web Application Layer (FastAPI)
- Represented by the main.py and routers directory
- Major routes: auth, explore, feed, post, search, user

b) Template Layer
- Server-side rendering using HTML templates
- Static assets (CSS, JS, images)

c) Database Layer
- PostgreSQL database
- Represented by database.py and models.py

d) External Services
- Gmail API for verification emails
- Freeimage API for image storage

**[Client Browser] ←→ [FastAPI Application]**
- ↑               ↑    ↑    ↑

**[Static Assets]   [Templates] |  |**

- [PostgreSQL] |

- [External Services]
- Gmail API
- Freeimage API

##### Component Details

a) FastAPI Application (Core):
- auth.py (authentication & authorization)
- explore.py (content discovery)
- feed.py (user feed)
- post.py (post management)
- search.py (search functionality)
- user.py (user management)

b) Database Layer:
- PostgreSQL database
- Models.py connection
- Init.sql schema

c) Template Engine:
- Templates directory structure
- It to the main application

d) External Services Integration:
- Gmail API connection for email verification
- Freeimage API for image storage
- Clear API boundaries

##### Data Flow Indicators

- User request flow
- Authentication flow
- Database queries
- External API calls
- Template rendering
- Static asset serving

##### Additional Notes

- Keep the main application flow clear and centered
- Related components together
- Clear boundaries between different layers
- Environment configuration flow
- Modular structure of the routers

- Clear text labels
- Professional-looking exports

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Browser["Web Browser"]
    end

    subgraph "FastAPI Application"
        Main["Main Application"]:::main
        subgraph Routers
            Auth["Authentication Router"]:::router
            Explore["Explore Router"]:::router
            Feed["Feed Router"]:::router
            Post["Post Router"]:::router
            Search["Search Router"]:::router
            User["User Router"]:::router
        end
        OAuth["OAuth Handler"]:::auth
        Config["Configuration"]:::config
    end

    subgraph "Template Layer"
        BaseTemplate["Base Template"]:::template
        AuthView["Auth Views"]:::template
        FeedView["Feed View"]:::template
        ExploreView["Explore View"]:::template
        PostView["Post Views"]:::template
        UserView["User View"]:::template
    end

    subgraph "Static Assets"
        JS["JavaScript"]:::static
        CSS["Styles"]:::static
        Images["Images"]:::static
    end

    subgraph "Database Layer"
        DB[(PostgreSQL)]:::database
        Models["Data Models"]:::database
        Schema["Initial Schema"]:::database
        DBConn["Database Connection"]:::database
    end

    subgraph "External Services"
        Gmail["Gmail API"]:::external
        Freeimage["Freeimage API"]:::external
    end

    subgraph "Deployment"
        Heroku["Heroku"]:::deploy
        GithubActions["GitHub Actions"]:::deploy
    end

    %% Connections
    Browser <--> Main
    Main --> Auth & Explore & Feed & Post & Search & User
    Main --> OAuth
    Main --> Config
    
    Auth & Explore & Feed & Post & Search & User --> BaseTemplate
    BaseTemplate --> AuthView & FeedView & ExploreView & PostView & UserView
    
    Browser --> JS & CSS & Images
    
    Auth & Explore & Feed & Post & Search & User --> DBConn
    DBConn --> DB
    Models --> DB
    Schema --> DB
    
    Auth --> Gmail
    Post --> Freeimage
    
    GithubActions --> Heroku
    
    %% Click Events
    click Main "https://github.com/Devansh3712/tsuki/blob/main/tsuki/main.py"
    click Auth "https://github.com/Devansh3712/tsuki/blob/main/tsuki/routers/auth.py"
    click Explore "https://github.com/Devansh3712/tsuki/blob/main/tsuki/routers/explore.py"
    click Feed "https://github.com/Devansh3712/tsuki/blob/main/tsuki/routers/feed.py"
    click Post "https://github.com/Devansh3712/tsuki/blob/main/tsuki/routers/post.py"
    click Search "https://github.com/Devansh3712/tsuki/blob/main/tsuki/routers/search.py"
    click User "https://github.com/Devansh3712/tsuki/blob/main/tsuki/routers/user.py"
    click DBConn "https://github.com/Devansh3712/tsuki/blob/main/tsuki/database.py"
    click Models "https://github.com/Devansh3712/tsuki/blob/main/tsuki/models.py"
    click Schema "https://github.com/Devansh3712/tsuki/blob/main/tsuki/resources/init.sql"
    click BaseTemplate "https://github.com/Devansh3712/tsuki/blob/main/tsuki/templates/base.html"
    click AuthView "https://github.com/Devansh3712/tsuki/blob/main/tsuki/templates/auth.html"
    click FeedView "https://github.com/Devansh3712/tsuki/blob/main/tsuki/templates/feed.html"
    click ExploreView "https://github.com/Devansh3712/tsuki/blob/main/tsuki/templates/explore.html"
    click PostView "https://github.com/Devansh3712/tsuki/blob/main/tsuki/templates/post.html"
    click UserView "https://github.com/Devansh3712/tsuki/blob/main/tsuki/templates/user.html"
    click JS "https://github.com/Devansh3712/tsuki/blob/main/tsuki/static/main.js"
    click CSS "https://github.com/Devansh3712/tsuki/blob/main/tsuki/static/styles.css"
    click Images "https://github.com/Devansh3712/tsuki/tree/main/tsuki/static/images"
    click OAuth "https://github.com/Devansh3712/tsuki/blob/main/tsuki/oauth.py"
    click Config "https://github.com/Devansh3712/tsuki/blob/main/tsuki/config.py"
    click Heroku "https://github.com/Devansh3712/tsuki/tree/main/Procfile"
    click GithubActions "https://github.com/Devansh3712/tsuki/blob/main/.github/workflows/heroku.yml"

    %% Styles
    classDef main fill:#1E88E5,color:white
    classDef router fill:#42A5F5,color:white
    classDef auth fill:#9C27B0,color:white
    classDef config fill:#7986CB,color:white
    classDef template fill:#90A4AE,color:white
    classDef static fill:#78909C,color:white
    classDef database fill:#4CAF50,color:white
    classDef external fill:#FF9800,color:white
    classDef deploy fill:#795548,color:white
```
