Dev#20
Open
Smanikanta21 wants to merge 36 commits into
Open
Conversation
- Added user registration and login routes with JWT token generation. - Created user model and database connection configuration. - Implemented middleware for token authentication. - Added integration tests for authentication endpoints. - Updated client-side with login, signup, and dashboard pages. - Created reusable components for layout, navbar, and footer. - Integrated API service for handling authentication requests. - Enhanced CORS configuration for API access.
- Added ESLint for linting JavaScript code with a custom configuration. - Updated package.json to include ESLint as a dev dependency and configured lint script. - Created a GitHub Actions CI workflow for linting and testing on push and pull request events. - Implemented Jest configuration for running tests in a Node environment. - Refactored database connection handling in index.js to ensure the server starts only after a successful connection. - Minor code cleanup in auth routes and test files for consistency and clarity.
feat: add deployment workflow to EC2 with SSH and PM2 management
…automated JSON test reporting
…th CI pipeline integration
…itional logic, and streamlining image tagging and deployment steps
…er environment variables
There was a problem hiding this comment.
Pull request overview
This PR introduces a full-stack deployment setup for ShopSmart: Terraform-managed AWS infrastructure (S3/ECR/ECS/ALB), backend authentication + DB wiring with tests, a routed React UI with Tailwind styling, and a GitHub Actions CI/CD pipeline.
Changes:
- Add Terraform to provision AWS networking, ECR, ECS Fargate services, ALB routing, and S3 artifacts bucket.
- Add backend auth endpoints (
/api/auth/*), MongoDB connection bootstrap, Jest tests, and ESLint config. - Add frontend routing/pages (Home/Products/ProductDetail/Login/Signup/Dashboard), Axios API client, Tailwind setup, Dockerfiles, and CI pipeline + Dependabot.
Reviewed changes
Copilot reviewed 43 out of 46 changed files in this pull request and generated 21 comments.
Show a summary per file
| File | Description |
|---|---|
terraform/main.tf |
Defines AWS infra (VPC, ALB, ECS, ECR, S3) and service/task configuration. |
terraform/variables.tf |
Adds Terraform variables including region/env and sensitive config. |
terraform/outputs.tf |
Outputs core infra identifiers (ALB DNS, repos, cluster). |
server/src/app.js |
Adds CORS configuration and mounts auth routes. |
server/src/routes/auth.Routes.js |
Implements register/login/me endpoints with JWT auth middleware. |
server/src/configs/db.Config.js |
Adds MongoDB connection helper. |
server/src/index.js |
Boots app after DB connection. |
server/src/models/db.Users.js |
Adds User model schema. |
server/tests/*.test.js |
Adds Jest unit/integration tests. |
server/eslint.config.js / server/jest.config.js |
Adds lint/test configuration. |
server/Dockerfile |
Adds production container build with healthcheck. |
client/src/services/api.js |
Adds Axios client and auth API wrapper. |
client/src/pages/* |
Adds routed UI pages + tests and product data. |
client/src/components/* |
Adds Layout/Navbar/Footer shell. |
client/vite.config.js / client/src/index.css |
Adds Tailwind Vite plugin and Tailwind CSS import. |
.github/workflows/ci.yml |
Adds CI (tests + reports) and CD (Terraform + ECR push + ECS update). |
docker-compose.yml |
Adds local multi-service setup (frontend/backend/mongo). |
.github/dependabot.yml |
Adds dependency update automation. |
.gitignore |
Adds ignores for reports, Terraform artifacts, and PEM files. |
client/aws.pem |
Adds a private key file (credential material). |
client/test-report.json / server/test-report.json |
Adds generated test report artifacts. |
Files not reviewed (2)
- client/package-lock.json: Language not supported
- server/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+81
to
+84
| } | ||
|
|
||
| const token = jwt.sign({ userId: user._id }, process.env.JWT_SECRET, { expiresIn: '1h' }); | ||
| console.log('[Login] User logged in:', user); |
Comment on lines
+1
to
+3
| const mongoose = require('mongoose'); | ||
| const User = require('../src/models/db.Users'); | ||
|
|
Comment on lines
+1
to
+27
| -----BEGIN RSA PRIVATE KEY----- | ||
| MIIEowIBAAKCAQEArOcslhfQiyHrvN7E9mGbGEbxHjgXrl54JDT+KV4POLjpSC6A | ||
| 4G4KFCOEqG9r31AM9IA8z4xelwsj56I3uun2vm7Nos2Wc9ATKOkiotxrsg3qECGb | ||
| z4h2t/GMR0cN1Zrf0vIE3R9Z78qXw2LMncG3m8h6R+y8mNn3Z77bkY91H2xRU/PV | ||
| 9mHPyJdFl5MKSyWVhQwA/YrLhX+H8xQXaq8ugpWc4nj8XxzH1am02rvb8NbxABdV | ||
| o79ir0NZJNkKVNU8lpLg8ZGGjKQW0fgEJwB/Jf+FalbGRf3HGdwJk8dABNG8k4a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NyJgwIV9HlOAI2FG9QGDbsHxPrpEpE | ||
| ppJKZAw1beym8gdyCJgH3j8FooRs7C1orAhsygQ3vQRl/ZQjkluOvWQJyxwI2AsV | ||
| Rb9t8QKBgGmVcF9r4rtIJyWOP9NbU8sqTQhTEEpWxiFS5rMIRxIqAVMoy2DTtqvT | ||
| eWbzqk729GX92xwZxyBB1r7/XqN640uN02sdvtDPYcQeKh945wGviFPU8CdBvTlo | ||
| 4H5NjXh9OJa2dmdkpQtyN5jBFOht0sKr2+N44nArGR1ls3/3iO+C | ||
| -----END RSA PRIVATE KEY----- No newline at end of file |
Comment on lines
+182
to
+187
| ingress { | ||
| from_port = 0 | ||
| to_port = 65535 | ||
| protocol = "tcp" | ||
| security_groups = [aws_security_group.alb.id] | ||
| } |
Comment on lines
+20
to
+24
| EXPOSE 5000 | ||
|
|
||
| # Healthcheck configured | ||
| HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ | ||
| CMD wget --no-verbose --tries=1 --spider http://localhost:5000/ || exit 1 |
| @@ -0,0 +1 @@ | |||
| {"numFailedTestSuites":0,"numFailedTests":0,"numPassedTestSuites":2,"numPassedTests":8,"numPendingTestSuites":0,"numPendingTests":0,"numRuntimeErrorTestSuites":0,"numTodoTests":0,"numTotalTestSuites":2,"numTotalTests":8,"openHandles":[],"snapshot":{"added":0,"didUpdate":false,"failure":false,"filesAdded":0,"filesRemoved":0,"filesRemovedList":[],"filesUnmatched":0,"filesUpdated":0,"matched":0,"total":0,"unchecked":0,"uncheckedKeysByFile":[],"unmatched":0,"updated":0},"startTime":1777534066524,"success":true,"testResults":[{"assertionResults":[{"ancestorTitles":["User Model Unit Tests"],"duration":4,"failureDetails":[],"failureMessages":[],"fullName":"User Model Unit Tests should throw a validation error if required fields are missing","invocations":1,"location":null,"numPassingAsserts":3,"retryReasons":[],"status":"passed","title":"should throw a validation error if required fields are missing"},{"ancestorTitles":["User Model Unit Tests"],"duration":1,"failureDetails":[],"failureMessages":[],"fullName":"User Model Unit Tests should create a valid user instance when all fields are provided","invocations":1,"location":null,"numPassingAsserts":3,"retryReasons":[],"status":"passed","title":"should create a valid user instance when all fields are provided"}],"endTime":1777534067041,"message":"","name":"/Users/abhinaysiraparapu/Library/Mobile Documents/com~apple~CloudDocs/Projects/shopsmart/server/tests/user.test.js","startTime":1777534066618,"status":"passed","summary":""},{"assertionResults":[{"ancestorTitles":["Auth integration tests"],"duration":62,"failureDetails":[],"failureMessages":[],"fullName":"Auth integration tests should signup successfully with 201","invocations":1,"location":null,"numPassingAsserts":4,"retryReasons":[],"status":"passed","title":"should signup successfully with 201"},{"ancestorTitles":["Auth integration tests"],"duration":2,"failureDetails":[],"failureMessages":[],"fullName":"Auth integration tests should fail duplicate signup","invocations":1,"location":null,"numPassingAsserts":2,"retryReasons":[],"status":"passed","title":"should fail duplicate signup"},{"ancestorTitles":["Auth integration tests"],"duration":58,"failureDetails":[],"failureMessages":[],"fullName":"Auth integration tests should login successfully and return token","invocations":1,"location":null,"numPassingAsserts":3,"retryReasons":[],"status":"passed","title":"should login successfully and return token"},{"ancestorTitles":["Auth integration tests"],"duration":57,"failureDetails":[],"failureMessages":[],"fullName":"Auth integration tests should fail login with wrong password","invocations":1,"location":null,"numPassingAsserts":2,"retryReasons":[],"status":"passed","title":"should fail login with wrong password"},{"ancestorTitles":["Auth integration tests"],"duration":3,"failureDetails":[],"failureMessages":[],"fullName":"Auth integration tests should access /me with valid token","invocations":1,"location":null,"numPassingAsserts":4,"retryReasons":[],"status":"passed","title":"should access /me with valid token"},{"ancestorTitles":["Auth integration tests"],"duration":1,"failureDetails":[],"failureMessages":[],"fullName":"Auth integration tests should return unauthorized for /me without token","invocations":1,"location":null,"numPassingAsserts":2,"retryReasons":[],"status":"passed","title":"should return unauthorized for /me without token"}],"endTime":1777534067854,"message":"","name":"/Users/abhinaysiraparapu/Library/Mobile Documents/com~apple~CloudDocs/Projects/shopsmart/server/tests/app.test.js","startTime":1777534066618,"status":"passed","summary":""}],"wasInterrupted":false} | |||
Comment on lines
+3
to
+4
| const userScheme = new mongoose.Schema({ | ||
| name:{ type: String, required: true }, |
Comment on lines
+19
to
+30
| variable "mongo_uri" { | ||
| description = "MongoDB connection string" | ||
| type = string | ||
| sensitive = true | ||
| default = "mongodb://localhost:27017/shopsmart" | ||
| } | ||
|
|
||
| variable "jwt_secret" { | ||
| description = "JWT secret for authentication" | ||
| type = string | ||
| sensitive = true | ||
| default = "supersecretjwtkey_12345" |
Comment on lines
+6
to
+10
| app.use(cors({ | ||
| origin: [process.env.FRONTEND_URL], | ||
| methods: ['GET', 'POST', 'PUT', 'DELETE'], | ||
| allowedHeaders: ['Content-Type', 'Authorization'] | ||
| })); |
Comment on lines
+374
to
+377
| environment = [ | ||
| { name = "PORT", value = "4000" }, | ||
| { name = "MONGO_URI", value = var.mongo_uri }, | ||
| { name = "JWT_SECRET", value = var.jwt_secret }, |
…structure resource imports in CI pipeline
…ogic to be more robust
…port logic in CI workflow
…ces to current VPC and cluster name
…p steps from CI pipeline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.