# vanessalin9/twitter-fullstack-2020 architecture

> Architecture diagram of the GitHub repository vanessalin9/twitter-fullstack-2020, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vanessalin9/twitter-fullstack-2020
- Repository: https://github.com/vanessalin9/twitter-fullstack-2020

## Overview

##### Project type and purpose
- This is a full-stack, server-rendered Twitter-like application built on Node.js/Express, using Sequelize ORM (MySQL), Handlebars templates for the front end, and Passport for authentication.
- It includes both a public user interface (tweet feed, replies, likes, private/public chat) and an admin interface under `/admin` for managing users and content.

##### File structure
- Top-level:
- app.js – entry point, Express setup
- config/ – environment, DB config, Passport, Handlebars helpers
- controllers/ – MVC controllers, including `controllers/api` for RESTful endpoints
- services/ – business logic layer, abstracts DB operations
- models/ – Sequelize models and `models/index.js`
- migrations/ & seeders/ – DB schema and initial data
- routes/ – Express routers (`routes/apis.js`, `routes/index.js`, `routes/routes.js`)
- public/ – static assets (CSS)
- views/ – Handlebars templates (partials, layouts, admin and user pages)
- test/ – unit and integration tests

##### README for additional insights
- Confirms MySQL as persistent store, Sequelize CLI for migrations/seeds
- `npm run dev` spins up a development server
- Testing uses NODE_ENV=test with a separate test database

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        PublicUI["Public UI (Browser)"]:::frontend
        AdminUI["Admin UI (Browser)"]:::frontend
    end

    %% Server Layer
    subgraph "Server Layer"
        subgraph "Express App"
            App["HTTP/Web Server\napp.js"]:::backend
        end
        subgraph "Configuration"
            DBConf["DB Config\nconfig/config.json"]:::config
            PassConf["Auth Config\nconfig/passport.js"]:::config
            HBHelpers["HB Helpers\nconfig/handlebars-helpers.js"]:::config
        end
        subgraph "Middleware"
            Env["dotenv"]:::config
            Auth["Passport.js"]:::config
        end
        subgraph "Routing Layer"
            Router["Express Routing\nroutes/index.js\nroutes/routes.js\nroutes/apis.js"]:::backend
        end
        subgraph "Controllers"
            UC["UserController\ncontrollers/userController.js"]:::backend
            TC["TweetController\ncontrollers/tweetController.js"]:::backend
            RC["ReplyController\ncontrollers/api/replyController.js"]:::backend
            MC["MessageController\ncontrollers/messageController.js"]:::backend
            SC["SubscribeController\ncontrollers/subscribeController.js"]:::backend
            AdminC["AdminController\ncontrollers/adminController.js"]:::backend
            APIUC["API UserController\ncontrollers/api/userController.js"]:::backend
            APITC["API TweetController\ncontrollers/api/tweetController.js"]:::backend
            APIMC["API MessageController\ncontrollers/api/messageController.js"]:::backend
        end
        subgraph "Services"
            US["UserService\nservices/userService.js"]:::backend
            TS["TweetService\nservices/tweetService.js"]:::backend
            MS["MessageService\nservices/messageService.js"]:::backend
        end
        subgraph "Data Layer"
            ORM["Sequelize Models\nmodels/index.js"]:::data
        end

        %% Layer connections
        DBConf --> App
        PassConf --> App
        HBHelpers --> App
        Env --> App
        Auth --> App
        App --> Router
        Router --> UC & TC & RC & MC & SC & AdminC & APIUC & APITC & APIMC
        UC & APIUC --> US
        TC & APITC --> TS
        MC & APIMC --> MS
        US & TS & MS --> ORM
    end

    %% Database
    subgraph "Database"
        DB["MySQL"]:::data
    end
    ORM -->|SQL Queries| DB
    DB -->|Results| ORM

    %% Views & Assets
    subgraph "Templating & Static"
        Views["Handlebars Views\nviews/layouts/main.hbs\nviews/partials/\nviews/\nviews/admin/"]:::frontend
        Static["Static Assets\npublic/stylesheets/showPage.css"]:::frontend
    end
    TC -->|render HTML| Views
    UC -->|render HTML| Views
    AdminC -->|render HTML| Views
    APIUC & APITC & APIMC -->|JSON| PublicUI
    PublicUI -.static assets.-> Static

    %% Dev Tools
    subgraph "Dev Tools"
        Migs["Migrations\nmigrations/"]:::dev
        Seeds["Seeders\nseeders/"]:::dev
        Tests["Tests\ntest/"]:::dev
    end
    Migs --> DB
    Seeds --> DB
    Tests --> App

    %% User interaction
    PublicUI -->|HTTP| App
    AdminUI -->|HTTP| App

    %% Click Events
    click App "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/app.js"
    click DBConf "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/config/config.json"
    click PassConf "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/config/passport.js"
    click HBHelpers "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/config/handlebars-helpers.js"
    click Router "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/routes/index.js"
    click Router "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/routes/routes.js"
    click Router "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/routes/apis.js"
    click UC "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/controllers/userController.js"
    click TC "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/controllers/tweetController.js"
    click RC "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/controllers/api/replyController.js"
    click MC "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/controllers/messageController.js"
    click SC "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/controllers/subscribeController.js"
    click AdminC "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/controllers/adminController.js"
    click APIUC "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/controllers/api/userController.js"
    click APITC "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/controllers/api/tweetController.js"
    click APIMC "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/controllers/api/messageController.js"
    click US "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/services/userService.js"
    click TS "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/services/tweetService.js"
    click MS "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/services/messageService.js"
    click ORM "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/models/index.js"
    click Migs "https://github.com/vanessalin9/twitter-fullstack-2020/tree/master/migrations/"
    click Seeds "https://github.com/vanessalin9/twitter-fullstack-2020/tree/master/seeders/"
    click Views "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/views/layouts/main.hbs"
    click Static "https://github.com/vanessalin9/twitter-fullstack-2020/blob/master/public/stylesheets/showPage.css"
    click Tests "https://github.com/vanessalin9/twitter-fullstack-2020/tree/master/test/"

    %% Styles
    classDef frontend fill:#c8f7c5,stroke:#333,stroke-width:1px;
    classDef backend fill:#add8e6,stroke:#333,stroke-width:1px;
    classDef data fill:#f9d6a8,stroke:#333,stroke-width:1px;
    classDef config fill:#d3d3d3,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5;
    classDef dev fill:#e1bee7,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5;
```
