A microservice responsible for user management, authentication, and account operations within the Arithmetic Calculator ecosystem. Built on AWS Lambda with .NET 8.
- User Management: Registration, authentication, and profile management
- Account Management: Create accounts and manage balances
- Security: JWT-based authentication with refresh token support
- Serverless Architecture: Deployed as AWS Lambda functions
This project follows Clean Architecture principles with a clear separation of concerns:
├── Domain - Core business logic and entities
├── Application - Use cases, DTOs and service interfaces
├── Infrastructure - External concerns (persistence, security)
└── Presentation - API endpoints and request handling
- .NET 8 SDK
- AWS CLI (configured)
- AWS Lambda Tools for .NET
dotnet tool install -g Amazon.Lambda.Tools
- Docker (optional, for containerized development)
-
Clone the repository
git clone https://github.com/luangrezende/arithmetic-calculator-user-api.git cd arithmetic-calculator-user-api
-
Set up environment variables
# Windows (PowerShell) $env:JWT_SECRET_KEY="your-secret-key" $env:MYSQL_CONNECTION_STRING="Server=localhost;Database=calculator;User=root;Password=password;" $env:PROMOTIONAL_AMOUNT="10" # Linux/macOS export JWT_SECRET_KEY="your-secret-key" export MYSQL_CONNECTION_STRING="Server=localhost;Database=calculator;User=root;Password=password;" export PROMOTIONAL_AMOUNT="10"
-
Restore dependencies
dotnet restore
-
Run locally using Lambda Test Tool
cd src/ArithmeticCalculatorUserApi.Presentation dotnet lambda run-server
The API will be accessible at http://localhost:5000
.
-
Build the Docker image
docker build -t arithmetic-calculator-user-api .
-
Run the container
docker run -p 5000:5000 \ -e JWT_SECRET_KEY="your-secret-key" \ -e MYSQL_CONNECTION_STRING="Server=host.docker.internal;Database=calculator;User=root;Password=password;" \ -e PROMOTIONAL_AMOUNT="10" \ arithmetic-calculator-user-api
-
Package the application
cd src/ArithmeticCalculatorUserApi.Presentation dotnet lambda package --configuration Release
-
Deploy to AWS Lambda
dotnet lambda deploy-function ArithmeticCalculatorUserApi
This project includes a CI/CD pipeline using GitHub Actions. To set up:
-
Add the following secrets to your GitHub repository:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
LAMBDA_EXECUTION_ROLE_ARN
MYSQL_CONNECTION_STRING
JWT_SECRET_KEY
-
See GitHub Actions Setup for detailed configuration.
- GET /user/health - Health check endpoint for monitoring
- POST /v1/user/auth/register - Register new user
- POST /v1/user/auth/login - User login
- POST /v1/user/auth/refresh - Refresh authentication token
- POST /v1/user/auth/logout - Logout (invalidate token)
- GET /v1/user/profile - Get authenticated user profile
- POST /v1/user/account/balance - Add funds to account
- PUT /v1/user/account/balance - Withdraw funds from account
Run the test suite with:
dotnet test
The project includes unit tests for domain, application, and infrastructure layers.
The AWS Lambda configuration is in aws-lambda-tools-defaults.json
:
{
"profile": "default",
"region": "us-east-1",
"configuration": "Release",
"framework": "net8.0",
"function-runtime": "dotnet8",
"function-memory-size": 1024,
"function-timeout": 60,
"function-handler": "ArithmeticCalculatorUserApi.Presentation::ArithmeticCalculatorUserApi.Presentation.Function::FunctionHandler",
"function-name": "ArithmeticCalculatorUserApi",
"function-description": "Lambda function for Arithmetic Calculator User API",
"package-type": "Zip"
}
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.