Update architecture and decisions docs with auth refinements
This commit is contained in:
@@ -23,20 +23,20 @@ Rules:
|
||||
| Layer | Package | Purpose | Status |
|
||||
|-------|---------|---------|--------|
|
||||
| **CLI** | `cmd` | Cobra root command | 🛠 WIP |
|
||||
| | `cmd/serve.go` | `mygo serve` — wire deps, start HTTP | 🛠 WIP |
|
||||
| | `cmd/serve.go` | `mygo serve` — wire deps, start HTTP | ✅ |
|
||||
| | `cmd/config.go` | `mygo config` — config subcommand | 🛠 WIP |
|
||||
| | `cmd/status.go` | `mygo status` — health check | 🛠 WIP |
|
||||
| **Config** | `internal/config` | Viper load (YAML + env + flags) | 🛠 WIP |
|
||||
| **Config** | `internal/config` | Viper load (YAML + env + flags), typed Duration config via built-in decode hook | ✅ |
|
||||
| **App** | `internal/app` | Runtime dependency container and build metadata | 🛠 WIP |
|
||||
| **HTTP** | `internal/server` | Gin router init, route registration, graceful shutdown | 🛠 WIP |
|
||||
| **HTTP** | `internal/server` | Gin router init, route registration (public/protected split), graceful shutdown | ✅ |
|
||||
| | `internal/handler` | HTTP handlers (auth, file, admin, webdav...) | 🛠 WIP |
|
||||
| | `internal/middleware` | Gin middleware (logger, cors, auth) | 🛠 WIP |
|
||||
| **Business** | `internal/service` | Business logic (auth, file, admin) | 🛠 WIP |
|
||||
| | `internal/model` | Domain types (User, File, errors) | 🛠 WIP |
|
||||
| **Data** | `internal/repository` | Repository interfaces + GORM implementations | 🛠 WIP |
|
||||
| | `internal/middleware` | Gin middleware (logger, jwt, cors, auth) | 🛠 WIP |
|
||||
| **Business** | `internal/service` | Business logic: `AuthService` (register, login, refresh, logout, passkey CRUD) | ✅ |
|
||||
| | `internal/model` | Domain types (User, File, Credential, Session), error codes | ✅ |
|
||||
| **Data** | `internal/repository` | Repository interfaces + GORM implementations (User, Session, File, Credential) | ✅ |
|
||||
| | `internal/storage` | Storage backend interface + local disk impl | 🛠 WIP |
|
||||
| **Util** | `internal/auth` | JWT sign/verify, context helpers | 🛠 WIP |
|
||||
| | `internal/api` | Error body helpers | 🛠 WIP |
|
||||
| **Util** | `internal/auth` | JWT sign/verify (HS256), token type discrimination (access/refresh), password hashing (bcrypt), app passkey tokens | ✅ |
|
||||
| | `internal/api` | Unified JSON error response helpers | ✅ |
|
||||
|
||||
## API Routes (v0)
|
||||
|
||||
@@ -76,7 +76,8 @@ Applied to protected groups: auth (JWT validation, inject user into gin.Context)
|
||||
|
||||
## Server Responsibilities
|
||||
|
||||
- `cmd/serve.go` loads config, creates `app.WebApp`, builds the router, and starts the HTTP server.
|
||||
- `cmd/serve.go` loads config, calls `app.Bootstrap` to initialize DB + services, builds the router, and starts the HTTP server.
|
||||
- `app.WebApp` carries runtime dependencies and build metadata needed to assemble handlers.
|
||||
- `internal/server` owns Gin router setup (`router.go`), route registration split into `routes_public.go` and `routes_protected.go`, and HTTP server lifecycle.
|
||||
- `internal/server` owns Gin router setup (`router.go`), route registration split into `routes_public.go` (public auth) and `routes_protected.go` (JWT-protected account).
|
||||
- Each route group creates its own handler instance: `routes_public.go` creates `AuthHandler`, `routes_protected.go` creates `AccountHandler` — no shared handler state between public and protected routes.
|
||||
- `RunWithGracefulShutdown` stops accepting new requests on termination and gives in-flight requests time to finish.
|
||||
|
||||
Reference in New Issue
Block a user