Skip to content

Commit b827bd9

Browse files
committed
Initial structure with drizzle creating all the control for the MLOps process.
1 parent 684a562 commit b827bd9

26 files changed

+759
-1
lines changed

.github/workflows/ci-cd.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build-train:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Bun
17+
uses: oven-sh/setup-bun@v1
18+
with:
19+
bun-version: latest
20+
21+
- name: Install dependencies (workspaces)
22+
run: bun install
23+
24+
- name: Generate DB migrations
25+
run: bun --cwd api run db:generate
26+
27+
- name: Run DB migrations
28+
run: bun --cwd api run db:migrate
29+
30+
- name: Train model
31+
run: bun --cwd api run train
32+
33+
- name: Build web
34+
run: bun --cwd web run build
35+
36+
- name: Upload web artifact
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: web-dist
40+
path: web/dist
41+
42+
- name: Deploy (placeholder)
43+
if: ${{ secrets.FLY_API_TOKEN != '' }}
44+
run: |
45+
echo "FLY_API_TOKEN detected. Add deployment steps here (e.g., Fly.io)."

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,4 @@ dist
137137
# Vite logs files
138138
vite.config.js.timestamp-*
139139
vite.config.ts.timestamp-*
140+
bun.lock

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,27 @@
1-
# spamguard-mlops
1+
# spamguard-mlops
2+
3+
## Referências
4+
5+
- [Elysia](https://elysiajs.com/)
6+
- [Drizzle](https://drizzle-orm.com/)
7+
- [Mantine](https://mantine.dev/)
8+
- [Recharts](https://recharts.org/)
9+
- [Bun](https://bun.sh/)
10+
- [Fly.io](https://fly.io/)
11+
- [GitHub Actions](https://github.com/features/actions)
12+
13+
## Tools
14+
15+
- [DVC](https://github.com/iterative/dvc)
16+
- [MLflow](https://github.com/mlflow/mlflow)
17+
18+
## Fly.io
19+
20+
```bash
21+
fly auth login
22+
fly apps create spamguard-mlflow
23+
```
24+
25+
```bash
26+
fly deploy
27+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"_events":{},"_eventsCount":0,"classifier":{"classFeatures":{"spam":{"0":2,"1":2,"2":2,"3":2,"4":2,"5":2,"9":2,"10":2,"11":2,"12":2,"13":2,"18":2,"19":2,"20":2,"21":2,"22":2,"23":2},"ham":{"6":2,"7":2,"8":2,"14":2,"15":2,"16":2,"17":2,"24":2,"25":2,"26":2}},"classTotals":{"spam":4,"ham":4},"totalExamples":7,"smoothing":1},"docs":[{"label":"spam","text":["congratul","won","free","ticket","bahama","call"]},{"label":"ham","text":["hei","lunch","todai"]},{"label":"spam","text":["lowest","price","med","click","bui"]},{"label":"ham","text":["don't","forget","meet","pm"]},{"label":"spam","text":["select","prize","visit","http","//spam","exampl"]},{"label":"ham","text":["review","document","sent"]}],"features":{"congratul":1,"won":1,"free":1,"ticket":1,"bahama":1,"call":1,"hei":1,"lunch":1,"todai":1,"lowest":1,"price":1,"med":1,"click":1,"bui":1,"don't":1,"forget":1,"meet":1,"pm":1,"select":1,"prize":1,"visit":1,"http":1,"//spam":1,"exampl":1,"review":1,"document":1,"sent":1},"stemmer":{},"lastAdded":6}

api/drizzle.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
schema: './src/db/schema.js',
3+
out: './drizzle',
4+
dialect: 'sqlite',
5+
dbCredentials: {
6+
url: 'file:./main.db'
7+
}
8+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
CREATE TABLE `experiments` (
2+
`id` integer PRIMARY KEY NOT NULL,
3+
`name` text NOT NULL,
4+
`created_at` integer DEFAULT '"2025-08-18T22:03:43.749Z"' NOT NULL
5+
);
6+
--> statement-breakpoint
7+
CREATE TABLE `runs` (
8+
`id` integer PRIMARY KEY NOT NULL,
9+
`experiment_id` integer NOT NULL,
10+
`git_commit` text,
11+
`metrics` text,
12+
`model_artifact_path` text,
13+
`is_production` integer DEFAULT false,
14+
`created_at` integer DEFAULT '"2025-08-18T22:03:43.750Z"' NOT NULL,
15+
FOREIGN KEY (`experiment_id`) REFERENCES `experiments`(`id`) ON UPDATE no action ON DELETE no action
16+
);
17+
--> statement-breakpoint
18+
CREATE UNIQUE INDEX `experiments_name_unique` ON `experiments` (`name`);
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
{
2+
"version": "6",
3+
"dialect": "sqlite",
4+
"id": "67fe0b9e-b721-4d96-854e-02f5e6ad4e49",
5+
"prevId": "00000000-0000-0000-0000-000000000000",
6+
"tables": {
7+
"experiments": {
8+
"name": "experiments",
9+
"columns": {
10+
"id": {
11+
"name": "id",
12+
"type": "integer",
13+
"primaryKey": true,
14+
"notNull": true,
15+
"autoincrement": false
16+
},
17+
"name": {
18+
"name": "name",
19+
"type": "text",
20+
"primaryKey": false,
21+
"notNull": true,
22+
"autoincrement": false
23+
},
24+
"created_at": {
25+
"name": "created_at",
26+
"type": "integer",
27+
"primaryKey": false,
28+
"notNull": true,
29+
"autoincrement": false,
30+
"default": "'\"2025-08-18T22:03:43.749Z\"'"
31+
}
32+
},
33+
"indexes": {
34+
"experiments_name_unique": {
35+
"name": "experiments_name_unique",
36+
"columns": [
37+
"name"
38+
],
39+
"isUnique": true
40+
}
41+
},
42+
"foreignKeys": {},
43+
"compositePrimaryKeys": {},
44+
"uniqueConstraints": {}
45+
},
46+
"runs": {
47+
"name": "runs",
48+
"columns": {
49+
"id": {
50+
"name": "id",
51+
"type": "integer",
52+
"primaryKey": true,
53+
"notNull": true,
54+
"autoincrement": false
55+
},
56+
"experiment_id": {
57+
"name": "experiment_id",
58+
"type": "integer",
59+
"primaryKey": false,
60+
"notNull": true,
61+
"autoincrement": false
62+
},
63+
"git_commit": {
64+
"name": "git_commit",
65+
"type": "text",
66+
"primaryKey": false,
67+
"notNull": false,
68+
"autoincrement": false
69+
},
70+
"metrics": {
71+
"name": "metrics",
72+
"type": "text",
73+
"primaryKey": false,
74+
"notNull": false,
75+
"autoincrement": false
76+
},
77+
"model_artifact_path": {
78+
"name": "model_artifact_path",
79+
"type": "text",
80+
"primaryKey": false,
81+
"notNull": false,
82+
"autoincrement": false
83+
},
84+
"is_production": {
85+
"name": "is_production",
86+
"type": "integer",
87+
"primaryKey": false,
88+
"notNull": false,
89+
"autoincrement": false,
90+
"default": false
91+
},
92+
"created_at": {
93+
"name": "created_at",
94+
"type": "integer",
95+
"primaryKey": false,
96+
"notNull": true,
97+
"autoincrement": false,
98+
"default": "'\"2025-08-18T22:03:43.750Z\"'"
99+
}
100+
},
101+
"indexes": {},
102+
"foreignKeys": {
103+
"runs_experiment_id_experiments_id_fk": {
104+
"name": "runs_experiment_id_experiments_id_fk",
105+
"tableFrom": "runs",
106+
"tableTo": "experiments",
107+
"columnsFrom": [
108+
"experiment_id"
109+
],
110+
"columnsTo": [
111+
"id"
112+
],
113+
"onDelete": "no action",
114+
"onUpdate": "no action"
115+
}
116+
},
117+
"compositePrimaryKeys": {},
118+
"uniqueConstraints": {}
119+
}
120+
},
121+
"enums": {},
122+
"_meta": {
123+
"schemas": {},
124+
"tables": {},
125+
"columns": {}
126+
}
127+
}

api/drizzle/meta/_journal.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": "6",
3+
"dialect": "sqlite",
4+
"entries": [
5+
{
6+
"idx": 0,
7+
"version": "6",
8+
"when": 1755554623752,
9+
"tag": "0000_gifted_thunderball",
10+
"breakpoints": true
11+
}
12+
]
13+
}

api/main.db

24 KB
Binary file not shown.

api/package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "api",
3+
"dependencies": {
4+
"@elysiajs/cors": "^1.0.2",
5+
"drizzle-orm": "^0.30.10",
6+
"elysia": "^1.0.22",
7+
"natural": "^6.12.0"
8+
},
9+
"devDependencies": {
10+
"drizzle-kit": "^0.21.4"
11+
},
12+
"scripts": {
13+
"dev": "bun run --watch src/index.js",
14+
"start": "bun run src/index.js",
15+
"train": "bun run src/train.js",
16+
"db:generate": "drizzle-kit generate",
17+
"db:migrate": "bun run src/db/migrate.js"
18+
}
19+
}

0 commit comments

Comments
 (0)