How silvsane/microservices-architecture-to-do-list works
Purpose and topology
This is a Node.js microservice-style task application: a frontend is served separately, an API gateway fronts backend services, an authentication service issues/manages credentials, and a task service exposes protected task operations. No persistent database or deployment manifests are present; service state appears to be process-local stores.
Process entry points
• Auth service bootstraps from auth-service/src/app.js, with environment/config loading in auth-service/src/config/config.js.
• Gateway bootstraps from gateway/src/app.js and is the intended backend-facing integration boundary.
• Task service has a root entry point at task-service/app.js; its domain routes and implementation live under task-service/src/.
• Frontend is served by frontend/server.js; static/UI content is likely rooted around frontend/test/index.html.
Authentication service
Authentication is layered as HTTP routes → controller → service → in-memory stores:
• auth-service/src/routes/auth.routes.js
• auth-service/src/controllers/auth.controller.js
• auth-service/src/services/auth.service.js
User records and refresh-token state are isolated behind auth-service/src/store/users.store.js and auth-service/src/store/refTokens.store.js. This service owns credential validation and token lifecycle rather than allowing task APIs to access user data directly.
Gateway boundary
gateway/src/app.js is the cross-service ingress point and likely forwards frontend API traffic to auth and task backends. Environment examples at gateway/.env.example and auth-service/.env.example indicate service URLs, ports, secrets, or similar runtime settings are externally configured. The gateway is the principal place to centralize routing, exposure policy, and service discovery/configuration rather than coupling the frontend directly to internal services.
Task domain service
Task HTTP handling follows the same layered design:
• task-service/src/routes/task.routes.js
• task-service/src/controllers/task.controller.js
• task-service/src/services/task.service.js
Task state is encapsulated in task-service/src/store/tasks.store.js. The lack of database adapters, migrations, or ORM files means tasks are likely volatile and reset on service restart; replacing this store is the natural persistence boundary.
Authorization flow
Protected task requests enter task-service/src/middlewares/auth.middleware.js before reaching task routes. The expected control flow is frontend → gateway → task service middleware → task controller/service/store. Authentication/token issuance flows instead target the auth service. The middleware is the trust boundary: it should validate propagated credentials and establish authenticated request context before task business logic runs.
Runtime and operational constraints
Each component has its own package.json and lockfile (auth-service/package.json, gateway/package.json, task-service/package.json, frontend/package.json), implying independently installable/runnable Node.js processes. .env.example files exist for auth, gateway, and task services, while the frontend has no equivalent shown. No container orchestration, database, message broker, or external SaaS integration is represented in the repository tree.
Main entry points: src/app.js API gateway · auth.service.js Auth service · index.html Static UI · src/app.js Auth app
Components 15
Frontend
- Frontend server
frontend/server.js - Static UI
frontend/test/index.html
Gateway
- API gateway · Public backend integration boundary.
gateway/src/app.js
Auth Service
- Auth app
auth-service/src/app.js - Auth routes
auth-service/src/routes/auth.routes.js - Auth controller
auth-service/src/controllers/auth.controller.js - Auth service · Owns credential validation and token lifecycle.
auth-service/src/services/auth.service.js - Users store · Volatile user records.
auth-service/src/store/users.store.js - Refresh token store · Volatile refresh-token state.
auth-service/src/store/refTokens.store.js
Task Service
- Task app
task-service/app.js - Auth middleware · Validates credentials and establishes request context.
task-service/src/middlewares/auth.middleware.js - Task routes
task-service/src/routes/task.routes.js - Task controller
task-service/src/controllers/task.controller.js - Task service
task-service/src/services/task.service.js - Tasks store · Natural boundary for adding persistence.
task-service/src/store/tasks.store.js
Connections 14
- Frontend server → Static UI: serves
- Static UI → API gateway: API requests
- API gateway → Auth app: forwards auth traffic
- API gateway → Task app: forwards task traffic
- Auth app → Auth routes: mounts
- Auth routes → Auth controller: dispatches
- Auth controller → Auth service: uses
- Auth service → Users store: reads/writes users
- Auth service → Refresh token store: manages tokens
- Task app → Auth middleware: protected requests
- Auth middleware → Task routes: authorized requests
- Task routes → Task controller: dispatches
- Task controller → Task service: uses
- Task service → Tasks store: reads/writes tasks