# emerisscala/playlove-core architecture

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

- Interactive diagram: https://gitdiagram.com/emerisscala/playlove-core
- Repository: https://github.com/emerisscala/playlove-core

## Overview

#### Purpose and Runtime
This is an Express/Node.js server with EJS-rendered views and Sequelize-managed relational persistence. It appears to model a content/community and assessment domain: users, publications, lists/items, forum questions/answers/comments, reactions/reports, topics, tests, and user test results.

Primary startup paths are `app.js`, which configures the Express application, and `bin/www`, which runs the HTTP server.

#### HTTP Application Boundary
`app.js` is the composition root for middleware, static assets, view rendering, routing, and error handling. EJS templates are served from `views/`, while browser-accessible assets are exposed from `public/`.

Route entry points are currently limited to:
- `routes/index.js`
- `routes/users.js`

These routes are mounted by `app.js`; they form the request-to-render/controller boundary.

#### Server-rendered Presentation
The application uses EJS rather than a separate frontend runtime. Initial page and error rendering are represented by:
- `views/index.ejs`
- `views/error.ejs`
- `public/stylesheets/style.css`

This indicates a conventional server-rendered Express flow: HTTP request → route handler → EJS view or error response.

#### Persistence Layer
Sequelize is the ORM and schema lifecycle mechanism. Connection/environment settings are expected in:
- `config/config.json`
- `.sequelizerc`
- `database/models/index.js`

`database/models/index.js` is the likely model registry and association assembly point; application code should consume models through it rather than independently constructing ORM connections.

#### Core Domain: Identity and Content
User identity is the base entity, with publication and list/item content structures:
- `database/models/User.js`
- `database/models/Publication.js`
- `database/models/List.js`
- `database/models/Item.js`

Corresponding migrations establish the persisted schema, including `database/migrations/20190621164830-create-user.js` and the publication/list/item migration sequence. This domain likely supports user-authored or user-associated content.

#### Core Domain: Community Interaction
Forum and moderation/reaction entities define a discussion workflow:
- `database/models/Topics.js`
- `database/models/Forum_Question.js`
- `database/models/Answer.js`
- `database/models/Comment.js`
- `database/models/Kiss.js`
- `database/models/Report.js`

The implied control flow is topic/question creation → answers/comments → positive reaction (“Kiss”) or report/moderation action. Relationship cardinality and ownership should be verified in the model association definitions before extending this flow.

#### Core Domain: Assessment
Assessment is modeled separately from general discussion:
- `database/models/Test.js`
- `database/models/Test_Question.js`
- `database/models/Key.js`
- `database/models/User_Test.js`

The expected data flow is test definition → test questions and answer keys → a user test/attempt record. `User_Test` is the important join/state boundary between `User` and `Test`.

#### Schema Evolution and External Dependencies
Database schema is versioned through `database/migrations/`; seed data begins with `database/seeders/20190708051105-user.js`. Sequelize CLI configuration is rooted at `.sequelizerc`.

Material infrastructure is therefore Node.js/Express, EJS, Sequelize, and a SQL database selected by `config/config.json`. No external API, queue, cache, authentication provider, or deployment service is evidenced by the supplied repository tree.

Main entry points: [`database/models/index.js`](https://github.com/emerisscala/playlove-core/blob/master/database/models/index.js) (Model registry), [`app.js`](https://github.com/emerisscala/playlove-core/blob/master/app.js) (Express app), [`routes/index.js`](https://github.com/emerisscala/playlove-core/blob/master/routes/index.js) (Index routes), [`.sequelizerc`](https://github.com/emerisscala/playlove-core/blob/master/.sequelizerc) (Sequelize CLI root)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["HTTP runtime"]
  node_server{{"HTTP server<br/>Node entrypoint"}}
  node_app["Express app<br/>composition root<br/>[app.js]"]
  node_index_routes["Index routes<br/>Express router<br/>[index.js]"]
  node_user_routes["User routes<br/>Express router<br/>[users.js]"]
end

subgraph group_presentation["Server-rendered UI"]
  node_views["EJS views<br/>templates"]
  node_index_view["Index page<br/>EJS template<br/>[index.ejs]"]
  node_error_view["Error page<br/>EJS template<br/>[error.ejs]"]
  node_assets["Public assets<br/>static files"]
  node_styles["Site stylesheet<br/>CSS<br/>[style.css]"]
end

subgraph group_persistence["Persistence"]
  node_sequelize_config["Sequelize configuration<br/>ORM config<br/>[config.json]"]
  node_sequelize_rc["Sequelize CLI root<br/>CLI configuration<br/>[.sequelizerc]"]
  node_model_registry["Model registry<br/>Sequelize models<br/>[index.js]"]
  node_schema_migrations["Schema migrations<br/>Sequelize migrations"]
  node_user_seed["User seed<br/>Sequelize seed"]
  node_sql_database[("SQL database<br/>relational database")]
end

subgraph group_content["Content &amp; community"]
  node_identity_content["Identity &amp; content models<br/>Sequelize domain"]
  node_community["Community models<br/>Sequelize domain"]
  node_discussion_flow["Discussion workflow<br/>domain flow<br/>[Forum_Question.js]"]
end

subgraph group_assessment["Assessment"]
  node_assessment["Assessment models<br/>Sequelize domain"]
  node_user_test["User test record<br/>attempt join model<br/>[User_Test.js]"]
end

node_server -->|"runs"| node_app
node_app -->|"mounts"| node_index_routes
node_app -->|"mounts"| node_user_routes
node_app -->|"configures"| node_views
node_app -->|"serves"| node_assets
node_assets -->|"includes"| node_styles
node_index_routes -->|"renders"| node_index_view
node_app -->|"renders errors"| node_error_view
node_index_routes -->|"uses"| node_model_registry
node_user_routes -->|"uses"| node_model_registry
node_model_registry -->|"registers"| node_identity_content
node_model_registry -->|"registers"| node_community
node_model_registry -->|"registers"| node_assessment
node_model_registry -->|"persists through"| node_sql_database
node_sequelize_config -->|"configures"| node_model_registry
node_sequelize_rc -->|"locates"| node_sequelize_config
node_sequelize_rc -->|"locates"| node_schema_migrations
node_schema_migrations -->|"evolves schema"| node_sql_database
node_user_seed -.->|"seeds"| node_sql_database
node_identity_content -.->|"users participate in"| node_community
node_community -->|"implements"| node_discussion_flow
node_identity_content -->|"user owns"| node_user_test
node_assessment -->|"records attempt for test"| node_user_test

click node_server "https://github.com/emerisscala/playlove-core/blob/master/bin/www"
click node_app "https://github.com/emerisscala/playlove-core/blob/master/app.js"
click node_index_routes "https://github.com/emerisscala/playlove-core/blob/master/routes/index.js"
click node_user_routes "https://github.com/emerisscala/playlove-core/blob/master/routes/users.js"
click node_index_view "https://github.com/emerisscala/playlove-core/blob/master/views/index.ejs"
click node_error_view "https://github.com/emerisscala/playlove-core/blob/master/views/error.ejs"
click node_styles "https://github.com/emerisscala/playlove-core/blob/master/public/stylesheets/style.css"
click node_sequelize_config "https://github.com/emerisscala/playlove-core/blob/master/config/config.json"
click node_sequelize_rc "https://github.com/emerisscala/playlove-core/blob/master/.sequelizerc"
click node_model_registry "https://github.com/emerisscala/playlove-core/blob/master/database/models/index.js"
click node_user_seed "https://github.com/emerisscala/playlove-core/blob/master/database/seeders/20190708051105-user.js"
click node_discussion_flow "https://github.com/emerisscala/playlove-core/blob/master/database/models/Forum_Question.js"
click node_user_test "https://github.com/emerisscala/playlove-core/blob/master/database/models/User_Test.js"

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_server,node_app,node_index_routes,node_user_routes toneBlue
class node_views,node_index_view,node_error_view,node_assets,node_styles toneAmber
class node_sequelize_config,node_sequelize_rc,node_model_registry,node_schema_migrations,node_user_seed,node_sql_database toneMint
class node_identity_content,node_community,node_discussion_flow toneRose
class node_assessment,node_user_test toneIndigo
```

## Components

### HTTP runtime

- [HTTP server](https://github.com/emerisscala/playlove-core/blob/master/bin/www): Node entrypoint · Starts the Express listener. · `bin/www`
- [Express app](https://github.com/emerisscala/playlove-core/blob/master/app.js): composition root · Configures middleware, routes, views, static assets, and errors. · `app.js`
- [Index routes](https://github.com/emerisscala/playlove-core/blob/master/routes/index.js): Express router · `routes/index.js`
- [User routes](https://github.com/emerisscala/playlove-core/blob/master/routes/users.js): Express router · `routes/users.js`

### Server-rendered UI

- **EJS views**: templates · Renders pages and errors on the server.
- [Index page](https://github.com/emerisscala/playlove-core/blob/master/views/index.ejs): EJS template · `views/index.ejs`
- [Error page](https://github.com/emerisscala/playlove-core/blob/master/views/error.ejs): EJS template · `views/error.ejs`
- **Public assets**: static files
- [Site stylesheet](https://github.com/emerisscala/playlove-core/blob/master/public/stylesheets/style.css): CSS · `public/stylesheets/style.css`

### Persistence

- [Sequelize configuration](https://github.com/emerisscala/playlove-core/blob/master/config/config.json): ORM config · Selects database connection settings and CLI paths. · `config/config.json`
- [Sequelize CLI root](https://github.com/emerisscala/playlove-core/blob/master/.sequelizerc): CLI configuration · `.sequelizerc`
- [Model registry](https://github.com/emerisscala/playlove-core/blob/master/database/models/index.js): Sequelize models · Assembles models and their associations. · `database/models/index.js`
- **Schema migrations**: Sequelize migrations · Versioned relational schema evolution.
- [User seed](https://github.com/emerisscala/playlove-core/blob/master/database/seeders/20190708051105-user.js): Sequelize seed · `database/seeders/20190708051105-user.js`
- **SQL database**: relational database · Database engine is selected by Sequelize configuration.

### Content & community

- **Identity & content models**: Sequelize domain · User, Publication, List, and Item persistence.
- **Community models**: Sequelize domain · Topics, questions, answers, comments, reactions, and reports.
- [Discussion workflow](https://github.com/emerisscala/playlove-core/blob/master/database/models/Forum_Question.js): domain flow · Topics and questions receive answers, comments, reactions, or reports. · `database/models/Forum_Question.js`

### Assessment

- **Assessment models**: Sequelize domain · Tests, questions, answer keys, and user test records.
- [User test record](https://github.com/emerisscala/playlove-core/blob/master/database/models/User_Test.js): attempt join model · State boundary between a user and a test. · `database/models/User_Test.js`

## Connections

- HTTP server → Express app: runs
- Express app → Index routes: mounts
- Express app → User routes: mounts
- Express app → EJS views: configures
- Express app → Public assets: serves
- Public assets → Site stylesheet: includes
- Index routes → Index page: renders
- Express app → Error page: renders errors
- Index routes → Model registry: uses
- User routes → Model registry: uses
- Model registry → Identity & content models: registers
- Model registry → Community models: registers
- Model registry → Assessment models: registers
- Model registry → SQL database: persists through
- Sequelize configuration → Model registry: configures
- Sequelize CLI root → Sequelize configuration: locates
- Sequelize CLI root → Schema migrations: locates
- Schema migrations → SQL database: evolves schema
- User seed → SQL database: seeds
- Identity & content models → Community models: users participate in
- Community models → Discussion workflow: implements
- Identity & content models → User test record: user owns
- Assessment models → User test record: records attempt for test
