A GraphQL-based user authentication API built with Go and the Serverless Framework, designed to run on AWS Lambda.
- Go 1.21+
- Docker
- Docker Compose
- Serverless Framework
- AWS Account and configured credentials
-
Clone the repository:
git clone [email protected]:ahummel25/user-auth-api.git cd user-auth-api
-
Install dependencies:
go mod download go mod tidy npm install -g serverless npm install
-
Set up local environment variables:
# Copy the example env file and modify as needed cp .env.example .env
-
Start local MongoDB:
make dev-deps
-
Run the development server:
make local
The API will be available at:
- GraphQL API: http://localhost:8080/graphql
- GraphiQL Playground: http://localhost:8080/graphiql
- Apollo Playground: http://localhost:8080/apollo
# Start MongoDB
make dev-deps
# Run local server
make local
# View MongoDB logs
make logs-mongo
# Run tests
go test ./...
# Clean build artifacts
make clean
.
├── cmd/ # Command line tools
│ └── local/ # Local development server
├── config/ # Configuration management
├── db/ # Database layer
├── graphql/ # GraphQL schema and resolvers
│ ├── directives/ # GraphQL directives
│ ├── generated/ # Generated GraphQL code
│ ├── model/ # GraphQL models
│ ├── resolvers/ # GraphQL resolvers
│ └── schema/ # GraphQL schema definitions
├── lambda/ # AWS Lambda functions
│ └── graphql/ # GraphQL API Lambda
├── service/ # Business logic services
└── utils/ # Utility functions
The API is deployed using the Serverless Framework to AWS Lambda.
-
Configure AWS credentials:
aws configure
-
Deploy to AWS:
# Deploy to dev export TF_WORKSPACE=dev make deploy # Deploy to prod export TF_WORKSPACE=prod make deploy
- Local: Local development environment
- Dev: Development environment in AWS
- Prod: Production environment in AWS
- API logs are visible in the terminal running
make local
- MongoDB logs can be viewed with
make logs-mongo
- CloudWatch Logs
- X-Ray Tracing (enabled for API Gateway and Lambda)