w3-gateway
Purpose
Apollo Federation gateway and web entrypoint. It handles Cognito login, token exchange, and routes users to the various web apps, while proxying GraphQL traffic to subgraphs.
Architecture
- Express app with Apollo Gateway (
IntrospectAndCompose) for subgraph composition. - Subgraphs are configured via
FEDERATED_SERVICE(name=url pairs); requests are forwarded to<subgraph>/graphql. - Authentication is enforced at
/graphqlby verifying Cognito JWTs. - User access is tracked via DynamoDB (
recordUserTracking). - OAuth callbacks for Gmail/Microsoft/GitHub exchange auth codes for tokens and persist them in MongoDB via
DbUser. - Loads runtime config from AWS SSM Parameter Store before reading
.env.
HTTP routes
GET /renders the welcome view.GET /auth/loginredirects to Cognito Hosted UI.GET /auth/callbackexchanges Cognito auth code and renders an app selector.GET /app-selectorrenders the app selector view.GET /email-managementrenders the email management app.GET /email-viewerrenders the email viewer.GET /github-searchrenders the GitHub search app.GET /picture-viewerrenders the picture viewer.GET /learn-vocabrenders the learn-vocab manager.POST /graphqlexecutes the federated GraphQL request with auth.GET /google/oauth2callbackhandles Gmail token exchange and stores it.GET /microsoft/oauth2callbackhandles Microsoft token exchange and stores it.GET /github/callbackhandles GitHub token exchange and stores it.
Configuration highlights
FEDERATED_SERVICE: subgraph list (e.g.services=http://host:4001;picture=http://host:4002).- Cognito:
COGNITO_DOMAIN,COGNITO_CLIENT_ID,COGNITO_CLIENT_SECRET,COGNITO_REDIRECT_URI, scopes/response type. - OAuth providers:
GITHUB_CLIENT_ID,GITHUB_CLIENT_SECRET,GITHUB_REDIRECT_URI.