Skip to content

Commit 2d6a785

Browse files
committed
first commit
0 parents  commit 2d6a785

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+28484
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: Deploy Serverless Backend
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
env:
10+
AWS_REGION: us-west-1
11+
NODE_VERSION: "22.x"
12+
13+
jobs:
14+
dependency-cache:
15+
name: Setup Dependency Cache
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: ${{ env.NODE_VERSION }}
26+
cache: "npm"
27+
cache-dependency-path: backend/package-lock.json
28+
29+
- name: Verify lock file exists
30+
run: |
31+
cd backend
32+
if [ ! -f package-lock.json ]; then
33+
echo "❌ package-lock.json not found. Run 'npm install' locally first."
34+
exit 1
35+
fi
36+
37+
- name: Install dependencies
38+
run: |
39+
cd backend
40+
npm ci # Uses package-lock.json for exact versions
41+
42+
test:
43+
name: Run Tests
44+
runs-on: ubuntu-latest
45+
needs: dependency-cache
46+
47+
steps:
48+
- name: Checkout code
49+
uses: actions/checkout@v4
50+
51+
- name: Setup Node.js and restore cache
52+
uses: actions/setup-node@v4
53+
with:
54+
node-version: ${{ env.NODE_VERSION }}
55+
cache: "npm"
56+
cache-dependency-path: backend/package-lock.json
57+
58+
- name: Install dependencies (cached)
59+
run: |
60+
cd backend
61+
npm ci
62+
63+
- name: Validate dependencies
64+
run: |
65+
cd backend
66+
npm audit --audit-level moderate
67+
npx license-checker --summary
68+
69+
- name: Type check
70+
run: |
71+
cd backend
72+
npx tsc --noEmit --skipLibCheck
73+
74+
deploy-serverless-apis:
75+
name: Deploy Serverless REST APIs
76+
runs-on: ubuntu-latest
77+
needs: [test]
78+
if: github.ref == 'refs/heads/main'
79+
environment: dev
80+
81+
steps:
82+
- name: Checkout code
83+
uses: actions/checkout@v4
84+
85+
- name: Setup Node.js
86+
uses: actions/setup-node@v4
87+
with:
88+
node-version: ${{ env.NODE_VERSION }}
89+
cache: "npm"
90+
cache-dependency-path: backend/package-lock.json
91+
92+
- name: Install dependencies
93+
run: |
94+
cd backend
95+
npm ci # Critical: uses package-lock.json
96+
97+
- name: Build application
98+
run: |
99+
cd backend
100+
npm run build
101+
102+
- name: Verify production dependencies
103+
run: |
104+
cd backend
105+
npm ls --production --depth=0
106+
107+
- name: Configure AWS credentials
108+
uses: aws-actions/configure-aws-credentials@v4
109+
with:
110+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
111+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
112+
aws-region: ${{ env.AWS_REGION }}
113+
114+
- name: Deploy to AWS
115+
run: |
116+
cd backend
117+
npm run deploy:dev
118+
env:
119+
NODE_ENV: production
120+
CI: true
121+
122+
- name: Health check
123+
run: |
124+
# Wait for deployment to complete
125+
sleep 30
126+
# Test the API endpoint
127+
curl -f https://byit9b38a0.execute-api.us-west-1.amazonaws.com/dev/items/all || exit 1

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
frontend/.env
2+
frontend/build
3+
frontend/node_modules
4+
frontend/dist
5+
backend/node_modules
6+
backend/.env
7+
backend/dist
8+
backend/.serverless
9+
/ssh-keys

README.md

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
# 🏆 Product Inventory Management
2+
3+
<p align="center">
4+
<img src="docs/screenshots/frontend.png" alt="Prodcut Inventory" width="100%" />
5+
<br>
6+
<i>Product Inventory Manager - http://62.72.6.16:3000</i>
7+
</p>
8+
9+
<p align="center">
10+
<img src="docs/screenshots/workflow.png" alt="Github CI/CD Pipeline" width="100%" />
11+
<br>
12+
<i>GitHub CI/CD Pipeline</i>
13+
</p>
14+
15+
## 🖥️ Backend: Serverless REST API (AWS)
16+
17+
### 📂 Project Structure
18+
19+
```
20+
backend/
21+
package.json
22+
serverless.yml
23+
tsconfig.json
24+
webpack.config.js
25+
scripts/
26+
src/
27+
config/
28+
index.ts
29+
handlers/
30+
auth/
31+
authorizer.ts
32+
getCurrentUser.ts
33+
signIn.ts
34+
signUp.ts
35+
items/
36+
all.ts
37+
create.ts
38+
delete.ts
39+
get.ts
40+
list.ts
41+
update.ts
42+
libs/
43+
apiGateway.ts
44+
dynamoDB.ts
45+
types/
46+
auth.ts
47+
item.ts
48+
utils/
49+
dynamodb.ts
50+
tests/
51+
```
52+
53+
### 🚀 Tech Stack & Architecture
54+
55+
- **Node.js + TypeScript**
56+
- **Serverless Framework** for Infrastructure as Code (IAC)
57+
- **AWS Lambda** functions for each CRUD operation
58+
- **AWS API Gateway** for RESTful endpoints
59+
- **AWS DynamoDB** for persistent storage
60+
- **AWS Cognito** for secure authentication (sign up, sign in, user management)
61+
- **Multi-stage deployments**: dev & prod environments
62+
- **CI/CD**: Designed for integration with GitHub Actions, AWS CodePipeline, or Serverless Pro CI/CD (auto-deploy on master branch push)
63+
- **YAML organization**: Clean, modular `serverless.yml` with resources, outputs, and function definitions
64+
65+
### 🛠️ Features
66+
67+
- **CRUD Lambdas**:
68+
- Create, Read (single & all), Update, Delete items
69+
- No direct API Gateway → DynamoDB proxy; all logic in Lambda
70+
- Endpoints:<br/>
71+
GET - https://byit9b38a0.execute-api.us-west-1.amazonaws.com/dev/items/all<br/>
72+
POST - https://byit9b38a0.execute-api.us-west-1.amazonaws.com/dev/auth/signup<br/>
73+
POST - https://byit9b38a0.execute-api.us-west-1.amazonaws.com/dev/auth/signin<br/>
74+
GET - https://byit9b38a0.execute-api.us-west-1.amazonaws.com/dev/auth/me<br/>
75+
POST - https://byit9b38a0.execute-api.us-west-1.amazonaws.com/dev/items<br/>
76+
GET - https://byit9b38a0.execute-api.us-west-1.amazonaws.com/dev/items/{id}<br/>
77+
GET - https://byit9b38a0.execute-api.us-west-1.amazonaws.com/dev/items<br/>
78+
PUT - https://byit9b38a0.execute-api.us-west-1.amazonaws.com/dev/items/{id}<br/>
79+
DELETE - https://byit9b38a0.execute-api.us-west-1.amazonaws.com/dev/items/{id}<br/>
80+
- **Authentication**:
81+
- Cognito User Pool & Client for user management
82+
- Custom authorizer Lambda for protected routes
83+
- **Automated Infrastructure**:
84+
- DynamoDB table creation
85+
- Cognito resources provisioned via IAC
86+
- **Extensible**:
87+
- Easily add more resources or functions
88+
- IAM roles scoped for least privilege
89+
- **Testing**:
90+
- Structure supports unit/integration tests (see `/tests` folder)
91+
92+
### 🧑‍💻 Developer Experience
93+
94+
- **Frequent commits** for traceable progress
95+
- **Documented template** for easy onboarding
96+
- **Video walkthrough** (Loom) for code, IAC, and deployment explanation
97+
- **Optional scripts** for deployment and packaging
98+
99+
---
100+
101+
## 🌐 Frontend: React Application
102+
103+
### 📂 Project Structure
104+
105+
```
106+
frontend/
107+
public/
108+
index.html
109+
src/
110+
App.tsx
111+
declarations.d.ts
112+
index.css
113+
index.tsx
114+
material-tailwind.d.ts
115+
assets/
116+
svg/
117+
check.svg
118+
close.svg
119+
error.svg
120+
logout.svg
121+
refresh.svg
122+
components/
123+
Dashboard.tsx
124+
ItemForm.tsx
125+
ItemList.tsx
126+
LoadingSpinner.tsx
127+
Modal.tsx
128+
ProductCard.tsx
129+
SignInForm.tsx
130+
SignUpForm.tsx
131+
config/
132+
index.ts
133+
contexts/
134+
AuthContext.tsx
135+
services/
136+
api.ts
137+
auth.ts
138+
types/
139+
auth.ts
140+
item.ts
141+
eslint.config.js
142+
package.json
143+
postcss.config.js
144+
tailwind.config.js
145+
tsconfig.json
146+
webpack.config.js
147+
```
148+
149+
### ⚛️ Tech Stack & Architecture
150+
151+
- **React + TypeScript**
152+
- **Tailwind CSS** for modern, responsive design
153+
- **Webpack** for bundling
154+
- **Context API** for authentication state
155+
- **Service layer** for API communication
156+
157+
### 🎨 Features
158+
159+
- **Full CRUD UI**:
160+
- Create, Read, Update, Delete items via backend API
161+
- **Authentication**:
162+
- Sign up, sign in, protected routes (dashboard, item management)
163+
- Auth context for user state
164+
- **Modern Design**:
165+
- Tailwind CSS for clean, professional look
166+
- SVG icons for visual feedback (✔️, ❌, 🔄, etc.)
167+
- **Responsive**:
168+
- Adapts to 4+ device sizes (mobile, tablet, desktop, large screens)
169+
- **Component-based**:
170+
- Dashboard, ItemForm, ItemList, Modal, ProductCard, LoadingSpinner, etc.
171+
- **Deployment-ready**:
172+
- Flexible deployment options (Netlify, Vercel, S3, etc.)
173+
- Entry point URL to be provided
174+
175+
### 🧑‍💻 Developer Experience
176+
177+
- **TypeScript types** for safety
178+
- **Organized assets** (SVGs, CSS, config)
179+
- **Easy API integration** via service layer
180+
- **Extensible for business cases** (custom item fields, user roles, etc.)
181+
182+
---
183+
184+
## 📦 CI/CD & Automation
185+
186+
- **Multi-stage pipeline**: dev & prod
187+
- **Auto-deploy on master push**
188+
- **Screenshots & documentation** for setup
189+
- **Supports GitHub Actions, AWS CodePipeline, Serverless Pro CI/CD**
190+
191+
---
192+
193+
## 🔒 Security & Best Practices
194+
195+
- **AWS Cognito** for secure user management
196+
- **Protected API routes**
197+
- **IAM roles with least privilege**
198+
- **No direct DynamoDB proxy from API Gateway**
199+
200+
---

0 commit comments

Comments
 (0)