AuthService Microservice β MVP Setup (2025-07-27)
Author: Jeet Solanki
Overviewβ
This document outlines the initial setup and architecture of the AuthService microservice for the Junior project.
It explains what has been implemented, how the service is organized, current capabilities, and outstanding tasks.
What I Didβ
1. Project Structureβ
- Created a modular Java Spring Boot project with the following packages:
config/
β Security and app configurationcontroller/
β REST API endpointsdto/
β Data Transfer Objects for requests/responsesentity/
β (Reserved for future, not used in database-less auth)exception/
β (Reserved for future custom exceptions)repository/
β (Not used in database-less auth)security/
β (Reserved for future, e.g., filters)service/
β Business logic (AuthService)util/
β Utility classes (e.g., JWT utilities)
2. Environment Configurationβ
- Split configuration into:
application.properties
(shared, non-sensitive)application-dev.properties
(MySQL, dev settings)application-test.properties
(H2, test settings)
- JWT secret is now referenced as an environment variable (
JWT_SECRET
), not hardcoded.
3. DTOs and Auth Logicβ
- Created DTOs for login, authentication response, and refresh token.
- AuthService is database-less: it delegates user validation to a separate UserService (microservice).
- JWT tokens are generated with user ID as the subject and username as a claim, following industry standards.
4. Securityβ
- Configured stateless JWT-based authentication.
- No sensitive data is committed to the repo.
.dockerignore
and.gitignore
are set up to exclude dev and secret files.
5. CI/CDβ
- GitHub Actions workflow runs tests and builds Docker images.
- CI uses the
test
profile, ensuring safe, isolated builds.
What We Can Do Nowβ
- Accept login and refresh token requests via REST API.
- Generate and validate JWT tokens with user ID as the subject.
- Communicate with a UserService microservice for user validation.
- Run automated tests and builds in CI/CD with safe, environment-specific config.
- Easily extend the service for new features (e.g., logout, token blacklist, etc.).
Whatβs Needed for Productionβ
- Set the
JWT_SECRET
environment variable securely in production. - Implement the UserService microservice for user registration, validation, and profile management.
- Add more tests (unit, integration, security).
- Add exception handling and error responses.
- Add monitoring/health checks (Spring Boot Actuator).
- (Optional) Add rate limiting, logging, and audit features.
What Remains / Next Stepsβ
- Write test cases
- Implement UserService and connect it to a real database.
- Add registration, password reset, and user profile endpoints.
- Harden security (token blacklist, refresh token rotation, etc.).
- Write more documentation for each new feature or milestone.
- Regularly update the
docs/
folder with new design decisions and features.
How to Use This Documentationβ
- Keep this file in
docs/
as a permanent record of the MVP setup. - For each new feature or milestone, add a new markdown file in
docs/
(e.g.,2025-07-27-registration-feature.md
). - Copy/paste or link these docs to your knowledge base repo as needed.
Last updated: 2025-08-05
Author: Jeet Solanki