Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gangster committed Feb 7, 2024
0 parents commit 97b72f3
Show file tree
Hide file tree
Showing 73 changed files with 11,745 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
docs
42 changes: 42 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript", "plugin:prettier/recommended"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript", "plugin:prettier/recommended"],
"rules": {}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"jest": true
},
"rules": {}
}
]
}
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI

on:
push:
branches:
- main
pull_request:

permissions:
actions: read
contents: read

jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

# Connect your workspace on nx.app and uncomment this to enable task distribution.
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "build" targets have been requested
# - run: npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="build"

# Cache node_modules
- uses: actions/setup-node@v3
with:
node-version: 21
cache: 'npm'
- run: npm ci
- uses: nrwl/nx-set-shas@v4

# - run: npx nx-cloud record -- nx format:check
# - run: npx nx affected -t lint test
- run: npx nx run-many -t lint test
44 changes: 44 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
dist
tmp
/out-tsc

# dependencies
node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db

.nx/cache

# docs
**/docs/*
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Add files here to ignore them from prettier formatting
/dist
/coverage
/.nx/cache
**/docs/*
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 120,
"tabWidth": 2
}
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- [General Questions](general-questions/)
- [Merge String Function](packages/merge-string/)
- [Code](packages/merge-string/src/lib/index.js)
- [Tests](packages/merge-string/src/lib/index.test.js)
- [API Integration](packages/mls-ingest/)
- [Entry point](packages/mls-ingest/src/lib/crm/properties/index.ts)
- ["Integration" tests](packages/mls-ingest/src/lib/crm/properties/index.test.ts)
- [Data Modeling](data-modeling/)
88 changes: 88 additions & 0 deletions data-modeling/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@

### Summary

This solution outlines a database schema designed to track assignments of employees to customer deals in various roles, with flexibility for future expansion of roles. The schema includes three tables: `deal`, `employee`, and `assignment`, with the latter serving as a junction table to manage the many-to-many relationships between deals and employees while capturing the roles assigned.

## Tables
```mermaid
erDiagram
DEAL ||--o{ ASSIGNMENT : has
EMPLOYEE ||--o{ ASSIGNMENT : has
DEAL {
int id PK "A unique primary key"
timestamp created_at "Timestamp of record creation"
timestamp updated_at "Timestamp of the last update"
varchar(128) v "A string up to 128 characters"
decimal w "A decimal number, e.g., 1.02"
}
EMPLOYEE {
int id PK "A unique primary key"
timestamp created_at "Timestamp of record creation"
timestamp updated_at "Timestamp of the last update"
char(15) x "A string of exactly 15 characters"
int y "An integer, defaults to 10"
}
ASSIGNMENT {
int id PK "A unique primary key for the assignment"
int deal_id FK "Foreign key to DEAL(id)"
int employee_id FK "Foreign key to EMPLOYEE(id)"
varchar(100) role "Role name up to 100 characters"
timestamp assigned_at "Timestamp when the assignment started"
timestamp ended_at "Timestamp when the assignment ended, nullable"
}
```

#### Composite Keys and Additional Indexes

- **Composite Unique Key** in `assignment`: A composite unique key on (`deal_id`, `employee_id`, `role`, `assigned_at`) to prevent duplicate role assignments at the same time.
- **Indexes**:
- Primary keys (`id` columns) in `deal` and `employee` tables are automatically indexed.
- Additional indexes on `deal_id` and `employee_id` in the `assignment` table improve join operation performance.
- An index on `role` in the `assignment` table could enhance filtering operations by role.

### Queries
#### Retrieve All Assignments for a Given Deal
To see all assignments for a specific deal, ordered by when the assignment started:

```sql
SELECT a.deal_id, a.employee_id, e.x as employee_name, a.role, a.assigned_at, a.ended_at
FROM assignment a
JOIN employee e ON a.employee_id = e.id
WHERE a.deal_id = ? -- Replace '?' with a specific deal ID
ORDER BY a.assigned_at ASC;
```

#### Find Current and Historical Roles for an Employee
To see all deals and roles an employee is currently assigned to, as well as their historical assignments:
```sql
SELECT a.employee_id, a.deal_id, a.role, a.assigned_at, a.ended_at
FROM assignment a
WHERE a.employee_id = ? -- Replace '?' with a specific employee ID
ORDER BY a.assigned_at DESC;
```

#### Adding a New Role to an Employee for a Deal
To assign a new role to an employee for a specific deal:
```sql
INSERT INTO assignment (deal_id, employee_id, role, assigned_at, created_at, updated_at)
VALUES (?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
-- Replace '?' with specific deal_id, employee_id, and 'role' with the new role's name
```

#### Retrieve All Roles Assigned to a Deal
```sql
SELECT DISTINCT a.role
FROM assignment a
WHERE a.deal_id = ? -- Replace '?' with a specific deal ID
ORDER BY a.role;
```

#### Update Assignment End Date
To mark an assignment as ended for an employee:

```sql
UPDATE assignment
SET ended_at = CURRENT_TIMESTAMP, updated_at = CURRENT_TIMESTAMP
WHERE employee_id = ? AND deal_id = ? AND role = ? AND ended_at IS NULL;
-- Replace '?' with specific employee_id, deal_id, and 'role'
```
22 changes: 22 additions & 0 deletions data-modeling/REQUIREMENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#### Database modeling and design problem

##### Explanation

We will provide some information about a business problem including some inputs and outputs and some simplified data shapes. We'd like you to read through the problem and come up with a design that will solve the problem by modifying or adding to the existing structures. You may express your design in a diagram like an ERD or in plain but specific descriptive language. Be sure to indicate any notable constraints, keys or other limitations on the entities or attributes.

##### Assumptions and Given data Structures

When a customer does business with us we store that fact in our database as a `deal` record. During the course of servicing that customer's deal we would like our employees to be assigned to a customer's deal. We keep record of our employees in our database as an `employee` record.

When employees are assigned to a deal it is in a specific role. The roles are: `customer success specialist`, `loan officer`, `loan advisor`, `deal specialist`. That assignment is unique for that employee and deal, however, employees can be assigned to the same deal in multiple roles at the same time. Employees can be assigned to mulitple deals as well.

* Assume that there is a table called `deal` and it contains a unique primary key `id` a timestamp `created` date and a timestamp for `updated` date and some additional fields `v` a string that can range from 1 to 128 chars which will always be provided, and `w` a number like 1.02 which will always be provided. Each record in the `deal` table represents a unique customer `deal`.
* Asuume that there is a table called `employee` and it contains a unique primary key `id` a timestamp `created` date and a timestamp for `updated` date and some additional fields, `x` a 15 character long string which will always be provided, `y` an integer that defaults to 10. Each record in the `employee` table represents a unique `employee`.

**Question**

We would like to store these assignments and use them for reporting and our internal website. We want to be sure that for a deal we can see all assignments that have ever been made. We would like to be able to order them based on when an assignment occured and ended (if ever). We'd like to be able to see from an employee's perspective how many deals and in what roles they are currently assigned as well as what roles they've been assigned historically.

**One note**: We expect that we will add additional types of roles in the future. The common name we use for roles will never exceed 100 characters

Please describe the model you arrive at including the existing tables and the additions or modifications to the database you would make to best achieve the stated goals.
7 changes: 7 additions & 0 deletions general-questions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### What's something you have built or done that you are most proud of and why?
I developed an automated system that provisioned temporary testing environments for our application with each new pull request and deployed a fresh version of the application with each new commit. This system, known as an ephemeral, review, or preview environment, deployed a test version of our app with data closely mimicking our production setup. It also took care to automatically destroy all resources once a pull request was either closed or merged. I am proud of the impact this project had, as it directly addressed the challenge of limited access to statically deployed test environments within our team, significantly improving our development process and workflow.

### What is a tech problem or area that you are excited about? If you could drop everything and spend your time solving or working in this space what would it be?
This is an incomplete list, but anything having to do with software design, distributed systems, microservices, cloud-native architectures, automation, delivery optimization, data integration, API development, production-related challenges (all the -abilities), developer experience, etc.

If I could drop everything and spend my time on whatever I wanted, I'd spend that time building an AI co-pilot that assists engineers in generating all the code, configuration, infrastructure, security policies, etc., required to deploy their applications in cost-effective, production-grade environments. Can't be that hard, right?
3 changes: 3 additions & 0 deletions jest.preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const nxPreset = require('@nx/jest/preset').default;

module.exports = { ...nxPreset };
53 changes: 53 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"namedInputs": {
"default": [
"{projectRoot}/**/*",
"sharedGlobals"
],
"production": [
"default",
"!{projectRoot}/.eslintrc.json",
"!{projectRoot}/eslint.config.js",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/src/test-setup.[jt]s",
"!{projectRoot}/test-setup.[jt]s"
],
"sharedGlobals": []
},
"nxCloudAccessToken": "ZDFhNGQ2NTMtMWMyNy00Yjg5LWJlZjctNTM2ZjQ5ZmQ1OTVifHJlYWQtd3JpdGU=",
"targetDefaults": {
"@nx/esbuild:esbuild": {
"cache": true,
"dependsOn": [
"^build"
],
"inputs": [
"production",
"^production"
]
},
"build": {
"inputs": [
"production",
"^production"
]
}
},
"plugins": [
{
"plugin": "@nx/eslint/plugin",
"options": {
"targetName": "lint"
}
},
{
"plugin": "@nx/jest/plugin",
"options": {
"targetName": "test"
}
}
]
}
Loading

0 comments on commit 97b72f3

Please sign in to comment.