Microservices-based notes app stack with:
- JWT Auth API (
services/lab-js-jwt-auth-api) - Notes CRUD API (
services/lab-js-notes-crud-api) - React frontend (
services/lab-js-notes-frontend) - MongoDB
- Redis (used by Auth API rate limiting when enabled)
Everything is orchestrated with Docker Compose from this repository.
.
├── docker-compose.yml
├── docker/
│ ├── auth-api.Dockerfile
│ ├── notes-crud-api.Dockerfile
│ └── notes-frontend.Dockerfile
├── services/
│ ├── lab-js-jwt-auth-api/
│ ├── lab-js-notes-crud-api/
│ └── lab-js-notes-frontend/
└── setup.sh
frontend(Vite + React): exposed onhttp://localhost:5173auth(Express): exposed onhttp://localhost:3000(base path/api/v1)notes(Express): exposed onhttp://localhost:3001(base path/api/v1)mongo(MongoDB): exposed onmongodb://localhost:27017redis(Redis): exposed onredis://localhost:6379
- Docker + Docker Compose
- Git
./setup.shThis script:
- Clones or updates the three service repositories into
services/ - Creates
.envfrom.env.exampleif missing - Runs
docker compose up --build
docker compose up --buildStop stack:
docker compose downStop and remove Mongo volume:
docker compose down -vCompose reads environment files from:
services/lab-js-jwt-auth-api/.envservices/lab-js-notes-crud-api/.envservices/lab-js-notes-frontend/.env(used by Vite build/dev runtime)
Base path: /api/v1
POST /api/v1/auth/registerPOST /api/v1/auth/loginPOST /api/v1/auth/refreshPOST /api/v1/auth/logoutPOST /api/v1/auth/verifyGET /api/v1/profile(requires access token)GET /api/v1/health
Base path: /api/v1/notes
POST /api/v1/notesGET /api/v1/notesGET /api/v1/notes/:idPUT /api/v1/notes/:idDELETE /api/v1/notes/:idGET /health
Symptoms:
- Network errors in browser for
authornoteshosts - CORS errors on requests from
http://localhost:5173
Checks:
- Frontend must use
localhostAPI URLs inservices/lab-js-notes-frontend/.env, not Docker DNS names:- Correct:
http://localhost:3000/api/v1,http://localhost:3001/api/v1 - Incorrect (for browser):
http://auth:3000/api/v1,http://notes:3001/api/v1
- Correct:
- Both APIs must allow browser origin via CORS:
CORS_ORIGIN=http://localhost:5173
- Rebuild after env changes:
docker compose up --buildIf ports 3000, 3001, 5173, 27017, or 6379 are in use, free them or remap ports in docker-compose.yml.
- Frontend runs Vite dev server with
--hostin container. notesservice talks toauthservice through Docker network (http://auth:3000/api/v1).- Mongo credentials are set in Compose and consumed via
MONGO_URIin each API. - Auth API can use Redis for rate limiting via
RATE_LIMIT_STORE=redis.