# prodigresser/project-4 architecture

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

- Interactive diagram: https://gitdiagram.com/prodigresser/project-4
- Repository: https://github.com/prodigresser/project-4

## Overview

##### Project type and purpose
- This is a Full‑Stack video‑streaming web application (“HowToTube”) built with a React front end, a Python/Flask back end, and a PostgreSQL database.
- Users can sign up/login, post videos, comment (nested replies), follow other users, and filter videos by genres.

##### File structure
- Top level: configuration files (.babelrc, webpack.config.js, Pipfile, Procfile) and package manifests (package.json, Pipfile).
- backend/ directory:
– app.py (Flask app entrypoint)
– controllers/ (Flask route handlers for users, videos, comments)
– models/ (SQLAlchemy ORM models + join tables for many‑to‑many relations)
– serializers/ (Marshmallow schemas for JSON in/out)
– middleware/secure_route.py (authentication guard)
– environment/config.py (environment‑specific settings)
– seed.py (database seeding script)
- frontend/ directory:
– index.html, App.js, index.js (React bootstrap)
– src/components/ (UI components for pages: Login, Signup, Video view, User profile, Navbar, etc.)
– src/lib/authentication.js (token handling)
– src/styles/ (Sass files)

##### README for additional insights
- RESTful API design connecting React → Flask endpoints → PostgreSQL via SQLAlchemy.
- Authentication via JWT + secure_route decorator.
- Mobile‑first responsive design via Sass.
- Deployment target: Heroku.

##### Detail without over‑splitting
- Join tables as connectors between core tables in the DB zone.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend" 
        direction TB
        entryHtml["index.html"]:::frontend
        entryIndex["index.js"]:::frontend
        appJs["App.js"]:::frontend
        components["UI Components\n(src/components)"]:::frontend
        authLib["Auth Library\n(authentication.js)"]:::frontend
        styles["Styles\n(styles.scss)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend" 
        direction TB
        appPy["Flask App\n(app.py)"]:::api
        middleware["Auth Middleware\n(secure_route.py)"]:::api
        controllers["Controllers\n(user.py, vid_post.py)"]:::api
        serializers["Serializers\n(user.py, video.py,\ncomments.py, genre.py)"]:::api
        models["ORM Models\n(base.py, user.py, video.py,\ncomments.py, genre.py,\nuser_followers.py, user_genre.py,\nvideo_genres.py)"]:::data
        support["Support\n(config.py, seed.py)"]:::support
    end

    %% Database Layer
    subgraph "Database" 
        direction TB
        db["PostgreSQL\n(users, videos,\ncomments, join tables)"]:::data
    end

    %% Deployment Layer
    subgraph "Deployment & Build" 
        direction TB
        build["Build Tools\n(.babelrc, webpack.config.js)"]:::support
        package["Manifests\n(package.json, Pipfile)"]:::support
        procfile["Procfile\n(Heroku Dyno)"]:::deployment
    end

    %% Connections
    Browser["User Browser"]:::external
    Browser -->|"loads assets"| entryHtml
    Browser --> entryIndex
    Browser --> appJs

    entryJsBundle["bundle.js"]:::frontend
    entryIndex -->|"Webpack/Babel"| entryJsBundle
    appJs --> components
    components --> authLib
    components --> styles

    components -->|"HTTP/REST (JSON)"| appPy
    authLib --> appPy

    appPy --> middleware
    middleware --> controllers
    controllers --> serializers
    serializers --> models
    models -->|"SQL"| db
    serializers -->|"JSON Response"| components

    build -.-> entryJsBundle
    build -.-> appPy
    package -.-> appPy
    procfile -.-> appPy

    %% Click Events
    click entryHtml "https://github.com/prodigresser/project-4/blob/main/frontend/index.html"
    click entryIndex "https://github.com/prodigresser/project-4/blob/main/frontend/index.js"
    click appJs "https://github.com/prodigresser/project-4/blob/main/frontend/App.js"
    click components "https://github.com/prodigresser/project-4/tree/main/frontend/src/components"
    click authLib "https://github.com/prodigresser/project-4/blob/main/frontend/src/lib/authentication.js"
    click styles "https://github.com/prodigresser/project-4/blob/main/frontend/src/styles/styles.scss"
    click appPy "https://github.com/prodigresser/project-4/blob/main/backend/app.py"
    click middleware "https://github.com/prodigresser/project-4/blob/main/backend/middleware/secure_route.py"
    click controllers "https://github.com/prodigresser/project-4/blob/main/backend/controllers/user.py"
    click controllers "https://github.com/prodigresser/project-4/blob/main/backend/controllers/vid_post.py"
    click serializers "https://github.com/prodigresser/project-4/blob/main/backend/serializers/base.py"
    click serializers "https://github.com/prodigresser/project-4/blob/main/backend/serializers/user.py"
    click serializers "https://github.com/prodigresser/project-4/blob/main/backend/serializers/video.py"
    click serializers "https://github.com/prodigresser/project-4/blob/main/backend/serializers/comments.py"
    click serializers "https://github.com/prodigresser/project-4/blob/main/backend/serializers/genre.py"
    click models "https://github.com/prodigresser/project-4/blob/main/backend/models/base.py"
    click models "https://github.com/prodigresser/project-4/blob/main/backend/models/user.py"
    click models "https://github.com/prodigresser/project-4/blob/main/backend/models/video.py"
    click models "https://github.com/prodigresser/project-4/blob/main/backend/models/comments.py"
    click models "https://github.com/prodigresser/project-4/blob/main/backend/models/genre.py"
    click models "https://github.com/prodigresser/project-4/blob/main/backend/models/user_followers.py"
    click models "https://github.com/prodigresser/project-4/blob/main/backend/models/user_genre.py"
    click models "https://github.com/prodigresser/project-4/blob/main/backend/models/video_genres.py"
    click support "https://github.com/prodigresser/project-4/blob/main/backend/environment/config.py"
    click support "https://github.com/prodigresser/project-4/blob/main/backend/seed.py"
    click build "https://github.com/prodigresser/project-4/blob/main/.babelrc"
    click build "https://github.com/prodigresser/project-4/blob/main/webpack.config.js"
    click package "https://github.com/prodigresser/project-4/blob/main/package.json"
    click package "https://github.com/prodigresser/project-4/tree/main/Pipfile"
    click procfile "https://github.com/prodigresser/project-4/tree/main/Procfile"

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#036,stroke-width:1px
    classDef api fill:#C6F5D2,stroke:#036,stroke-width:1px
    classDef data fill:#FCD38F,stroke:#a66,stroke-width:1px
    classDef support fill:#E2E8F0,stroke:#555,stroke-width:1px,stroke-dasharray: 5 5
    classDef deployment fill:#F4E7C2,stroke:#b85,stroke-width:1px
    classDef external fill:#FFFFFF,stroke:#666,stroke-width:1px,stroke-dasharray: 2 2
```
