Started BE structure / docker for FE dev
This commit is contained in:
+2
-3
@@ -1,11 +1,10 @@
|
|||||||
FROM golang:1.24.4-alpine3.22@sha256:68932fa6d4d4059845c8f40ad7e654e626f3ebd3706eef7846f319293ab5cb7a as base
|
FROM golang:1.24.4-alpine3.22@sha256:68932fa6d4d4059845c8f40ad7e654e626f3ebd3706eef7846f319293ab5cb7a AS base
|
||||||
|
|
||||||
# Set up workdir
|
# Set up workdir
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
# COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
COPY go.mod ./
|
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
# Copy code, and compile
|
# Copy code, and compile
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# ------ Dependencies stage ------
|
||||||
|
FROM oven/bun:1.2.18-alpine@sha256:a7df687a2f684ee2f7404e2592039e192d75d26a04f843e60d9fc342741187d0 AS deps
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
COPY package.json bun.lock ./
|
||||||
|
RUN bun install --frozen-lockfile
|
||||||
|
|
||||||
|
# ------ Development stage ------
|
||||||
|
FROM deps AS dev
|
||||||
|
|
||||||
|
# Run
|
||||||
|
CMD ["bun", "run", "dev"]
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
# Cover letter templater
|
||||||
|
|
||||||
|
Generates cover letters based on a template, and job listening using OpenAI.
|
||||||
|
|
||||||
|
## Stack
|
||||||
|
|
||||||
|
- Frontend:
|
||||||
|
- `Reactjs`
|
||||||
|
- `Tailwindcss`
|
||||||
|
- `Mantine` component library
|
||||||
|
- TanStack `Router` + `Query` + `Forms`
|
||||||
|
- Backend: `Golang`
|
||||||
|
- Database: `PostgreSQL`
|
||||||
|
- Deployment: `Docker`
|
||||||
|
|
||||||
|
## Backend
|
||||||
|
|
||||||
|
### Structure example (TODO: Replace with actual one)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
backend/
|
||||||
|
├── main.go # Entry point
|
||||||
|
├── api/ # Route handlers grouped by domain
|
||||||
|
│ ├── auth.go
|
||||||
|
│ └── coverletters.go
|
||||||
|
├── routes/ # HTTP route registration
|
||||||
|
│ └── routes.go
|
||||||
|
├── middleware/ # Custom middleware (logging, auth)
|
||||||
|
│ └── auth.go
|
||||||
|
├── models/ # Data models, structs, db access
|
||||||
|
│ ├── user.go
|
||||||
|
│ └── coverletter.go
|
||||||
|
├── services/ # Business logic (e.g. OpenAI integration)
|
||||||
|
│ ├── auth_service.go
|
||||||
|
│ └── coverletter_service.go
|
||||||
|
├── utils/ # Shared helpers/utilities
|
||||||
|
│ └── jwt.go
|
||||||
|
└── config/ # Env loading, settings
|
||||||
|
└── config.go
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Frontend
|
||||||
|
|
||||||
|
### Structure example
|
||||||
|
|
||||||
|
TODO: ADD STRUCTURE EXAMPLE
|
||||||
|
|
||||||
|
## Deployement
|
||||||
|
|
||||||
|
TODO: ADD DEPLOYMENT INSTRUCTIONS
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
TODO: ADD DEV INSTRUCTIONS
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import "os"
|
||||||
|
|
||||||
|
func defaultValue(val string, def string) string {
|
||||||
|
if val == "" {
|
||||||
|
return def
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
|
func LoadEnv() map[string]string {
|
||||||
|
// Create object where to store used variables
|
||||||
|
env := make(map[string]string, 1)
|
||||||
|
|
||||||
|
// Get env variables that will be used while server is running
|
||||||
|
env["port"] = defaultValue(os.Getenv("PORT"), "8080")
|
||||||
|
|
||||||
|
return env
|
||||||
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
module backend
|
module backend
|
||||||
|
|
||||||
go 1.24.4
|
go 1.24.4
|
||||||
|
|
||||||
|
require github.com/go-chi/chi/v5 v5.2.2
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
github.com/go-chi/chi/v5 v5.2.2 h1:CMwsvRVTbXVytCk1Wd72Zy1LAsAh9GxMmSNWLHCG618=
|
||||||
|
github.com/go-chi/chi/v5 v5.2.2/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops=
|
||||||
+14
-5
@@ -1,11 +1,20 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"backend/config"
|
||||||
|
"backend/routes"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
println("Hello, world!")
|
// Load env variables
|
||||||
|
env := config.LoadEnv()
|
||||||
|
|
||||||
for {
|
// Setup routes
|
||||||
time.Sleep(1 * time.Second)
|
routes := routes.SetupRoutes()
|
||||||
}
|
|
||||||
|
// Listen on port smth
|
||||||
|
log.Printf("Starting server on %s PORT\n", env["port"])
|
||||||
|
log.Fatal(http.ListenAndServe(":"+env["port"], routes))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package routes
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/go-chi/chi/v5"
|
||||||
|
"github.com/go-chi/chi/v5/middleware"
|
||||||
|
)
|
||||||
|
|
||||||
|
func SetupRoutes() http.Handler {
|
||||||
|
r := chi.NewRouter()
|
||||||
|
r.Use(middleware.Logger)
|
||||||
|
|
||||||
|
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Write([]byte("Hello World!"))
|
||||||
|
})
|
||||||
|
|
||||||
|
return r
|
||||||
|
}
|
||||||
@@ -5,7 +5,23 @@ services:
|
|||||||
dockerfile: ../Dockerfile.backend
|
dockerfile: ../Dockerfile.backend
|
||||||
|
|
||||||
container_name: cover-letter-backend
|
container_name: cover-letter-backend
|
||||||
|
environment:
|
||||||
|
- PORT=8080 # Internal container port
|
||||||
|
networks:
|
||||||
|
- cover-letter-network
|
||||||
|
frontend:
|
||||||
|
build:
|
||||||
|
context: ./frontend
|
||||||
|
dockerfile: ../Dockerfile.frontend
|
||||||
|
target: dev # Development stage
|
||||||
|
container_name: cover-letter-frontend
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- "./frontend:/app" # Mount frontend
|
||||||
|
- "/app/node_modules" # Ignore node_modules
|
||||||
|
|
||||||
|
ports:
|
||||||
|
- 3000:3000
|
||||||
networks:
|
networks:
|
||||||
- cover-letter-network
|
- cover-letter-network
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
node_modules/*
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": ".",
|
"name": "Cover letter frontend",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite --port 3000",
|
"dev": "vite --port 3000 --host",
|
||||||
"start": "vite --port 3000",
|
|
||||||
"build": "vite build && tsc",
|
"build": "vite build && tsc",
|
||||||
"serve": "vite preview",
|
"serve": "vite preview",
|
||||||
"test": "vitest run"
|
"test": "vitest run"
|
||||||
@@ -34,4 +33,5 @@
|
|||||||
"vitest": "^3.0.5",
|
"vitest": "^3.0.5",
|
||||||
"web-vitals": "^4.2.4"
|
"web-vitals": "^4.2.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
|
||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
// noinspection JSUnusedGlobalSymbols
|
||||||
|
|
||||||
|
// This file was automatically generated by TanStack Router.
|
||||||
|
// You should NOT make any changes in this file as it will be overwritten.
|
||||||
|
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
|
||||||
|
|
||||||
|
import { Route as rootRouteImport } from './routes/__root'
|
||||||
|
import { Route as IndexRouteImport } from './routes/index'
|
||||||
|
import { Route as DemoTanstackQueryRouteImport } from './routes/demo.tanstack-query'
|
||||||
|
import { Route as DemoFormSimpleRouteImport } from './routes/demo.form.simple'
|
||||||
|
import { Route as DemoFormAddressRouteImport } from './routes/demo.form.address'
|
||||||
|
|
||||||
|
const IndexRoute = IndexRouteImport.update({
|
||||||
|
id: '/',
|
||||||
|
path: '/',
|
||||||
|
getParentRoute: () => rootRouteImport,
|
||||||
|
} as any)
|
||||||
|
const DemoTanstackQueryRoute = DemoTanstackQueryRouteImport.update({
|
||||||
|
id: '/demo/tanstack-query',
|
||||||
|
path: '/demo/tanstack-query',
|
||||||
|
getParentRoute: () => rootRouteImport,
|
||||||
|
} as any)
|
||||||
|
const DemoFormSimpleRoute = DemoFormSimpleRouteImport.update({
|
||||||
|
id: '/demo/form/simple',
|
||||||
|
path: '/demo/form/simple',
|
||||||
|
getParentRoute: () => rootRouteImport,
|
||||||
|
} as any)
|
||||||
|
const DemoFormAddressRoute = DemoFormAddressRouteImport.update({
|
||||||
|
id: '/demo/form/address',
|
||||||
|
path: '/demo/form/address',
|
||||||
|
getParentRoute: () => rootRouteImport,
|
||||||
|
} as any)
|
||||||
|
|
||||||
|
export interface FileRoutesByFullPath {
|
||||||
|
'/': typeof IndexRoute
|
||||||
|
'/demo/tanstack-query': typeof DemoTanstackQueryRoute
|
||||||
|
'/demo/form/address': typeof DemoFormAddressRoute
|
||||||
|
'/demo/form/simple': typeof DemoFormSimpleRoute
|
||||||
|
}
|
||||||
|
export interface FileRoutesByTo {
|
||||||
|
'/': typeof IndexRoute
|
||||||
|
'/demo/tanstack-query': typeof DemoTanstackQueryRoute
|
||||||
|
'/demo/form/address': typeof DemoFormAddressRoute
|
||||||
|
'/demo/form/simple': typeof DemoFormSimpleRoute
|
||||||
|
}
|
||||||
|
export interface FileRoutesById {
|
||||||
|
__root__: typeof rootRouteImport
|
||||||
|
'/': typeof IndexRoute
|
||||||
|
'/demo/tanstack-query': typeof DemoTanstackQueryRoute
|
||||||
|
'/demo/form/address': typeof DemoFormAddressRoute
|
||||||
|
'/demo/form/simple': typeof DemoFormSimpleRoute
|
||||||
|
}
|
||||||
|
export interface FileRouteTypes {
|
||||||
|
fileRoutesByFullPath: FileRoutesByFullPath
|
||||||
|
fullPaths:
|
||||||
|
| '/'
|
||||||
|
| '/demo/tanstack-query'
|
||||||
|
| '/demo/form/address'
|
||||||
|
| '/demo/form/simple'
|
||||||
|
fileRoutesByTo: FileRoutesByTo
|
||||||
|
to: '/' | '/demo/tanstack-query' | '/demo/form/address' | '/demo/form/simple'
|
||||||
|
id:
|
||||||
|
| '__root__'
|
||||||
|
| '/'
|
||||||
|
| '/demo/tanstack-query'
|
||||||
|
| '/demo/form/address'
|
||||||
|
| '/demo/form/simple'
|
||||||
|
fileRoutesById: FileRoutesById
|
||||||
|
}
|
||||||
|
export interface RootRouteChildren {
|
||||||
|
IndexRoute: typeof IndexRoute
|
||||||
|
DemoTanstackQueryRoute: typeof DemoTanstackQueryRoute
|
||||||
|
DemoFormAddressRoute: typeof DemoFormAddressRoute
|
||||||
|
DemoFormSimpleRoute: typeof DemoFormSimpleRoute
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '@tanstack/react-router' {
|
||||||
|
interface FileRoutesByPath {
|
||||||
|
'/': {
|
||||||
|
id: '/'
|
||||||
|
path: '/'
|
||||||
|
fullPath: '/'
|
||||||
|
preLoaderRoute: typeof IndexRouteImport
|
||||||
|
parentRoute: typeof rootRouteImport
|
||||||
|
}
|
||||||
|
'/demo/tanstack-query': {
|
||||||
|
id: '/demo/tanstack-query'
|
||||||
|
path: '/demo/tanstack-query'
|
||||||
|
fullPath: '/demo/tanstack-query'
|
||||||
|
preLoaderRoute: typeof DemoTanstackQueryRouteImport
|
||||||
|
parentRoute: typeof rootRouteImport
|
||||||
|
}
|
||||||
|
'/demo/form/simple': {
|
||||||
|
id: '/demo/form/simple'
|
||||||
|
path: '/demo/form/simple'
|
||||||
|
fullPath: '/demo/form/simple'
|
||||||
|
preLoaderRoute: typeof DemoFormSimpleRouteImport
|
||||||
|
parentRoute: typeof rootRouteImport
|
||||||
|
}
|
||||||
|
'/demo/form/address': {
|
||||||
|
id: '/demo/form/address'
|
||||||
|
path: '/demo/form/address'
|
||||||
|
fullPath: '/demo/form/address'
|
||||||
|
preLoaderRoute: typeof DemoFormAddressRouteImport
|
||||||
|
parentRoute: typeof rootRouteImport
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const rootRouteChildren: RootRouteChildren = {
|
||||||
|
IndexRoute: IndexRoute,
|
||||||
|
DemoTanstackQueryRoute: DemoTanstackQueryRoute,
|
||||||
|
DemoFormAddressRoute: DemoFormAddressRoute,
|
||||||
|
DemoFormSimpleRoute: DemoFormSimpleRoute,
|
||||||
|
}
|
||||||
|
export const routeTree = rootRouteImport
|
||||||
|
._addFileChildren(rootRouteChildren)
|
||||||
|
._addFileTypes<FileRouteTypes>()
|
||||||
@@ -2,7 +2,7 @@ import { createFileRoute } from '@tanstack/react-router'
|
|||||||
|
|
||||||
import { useAppForm } from '../hooks/demo.form'
|
import { useAppForm } from '../hooks/demo.form'
|
||||||
|
|
||||||
export const Route = createFileRoute('/demo/form')({
|
export const Route = createFileRoute('/demo/form/address')({
|
||||||
component: AddressForm,
|
component: AddressForm,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { z } from 'zod'
|
|||||||
|
|
||||||
import { useAppForm } from '../hooks/demo.form'
|
import { useAppForm } from '../hooks/demo.form'
|
||||||
|
|
||||||
export const Route = createFileRoute('/demo/form')({
|
export const Route = createFileRoute('/demo/form/simple')({
|
||||||
component: SimpleForm,
|
component: SimpleForm,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { createFileRoute } from '@tanstack/react-router'
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
import logo from '../logo.svg'
|
import logo from "../logo.svg";
|
||||||
|
|
||||||
export const Route = createFileRoute('/')({
|
export const Route = createFileRoute("/")({
|
||||||
component: App,
|
component: App,
|
||||||
})
|
});
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
@@ -35,5 +35,5 @@ function App() {
|
|||||||
</a>
|
</a>
|
||||||
</header>
|
</header>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user