A modern React-based frontend application built with Vite and TypeScript. This application serves as the client interface for a full-stack serverless web application.
- Overview
- Tech Stack
- Project Structure
- Getting Started
- Available Scripts
- Configuration
- Features
- Folder Structure
- Contributing
This is a full-stack application frontend that communicates with AWS serverless backend services. The application provides user authentication, gallery management, and user profile features with a responsive React-based interface.
- React 19.2.0 - UI library
- TypeScript 5.9.3 - Type-safe JavaScript
- Vite 7.2.4 - Lightning-fast build tool and dev server
- React Router DOM 7.11.0 - Client-side routing
- dotenv 17.4.2 - Environment variable management
- ESLint 9.39.1 - Code quality and linting
frontend/my-app/
βββ src/
β βββ Components/ # Reusable React components
β βββ Shared/ # Shared utilities and constants
β βββ app/ # App-level configuration and setup
β βββ context/ # React Context API for state management
β βββ features/ # Feature-specific modules and logic
β βββ hooks/ # Custom React hooks
β βββ pages/ # Page components for routes
β βββ services/ # API services and external integrations
β βββ utils/ # Utility functions
β βββ index.css # Global styles
β βββ main.tsx # Application entry point
βββ public/ # Static assets
βββ .env # Environment variables (local)
βββ .env.example # Example environment variables
βββ eslint.config.js # ESLint configuration
βββ index.html # HTML template
βββ package.json # Project dependencies and scripts
βββ tsconfig.json # TypeScript configuration
βββ tsconfig.app.json # App-specific TypeScript config
βββ tsconfig.node.json # Node-specific TypeScript config
βββ vite.config.ts # Vite configuration
βββ package-lock.json # Dependency lock file
- Node.js (v16 or higher)
- npm (v7 or higher)
-
Navigate to the frontend directory:
cd frontend/my-app -
Install dependencies:
npm install
-
Create environment file:
cp .env.example .env
-
Configure environment variables: Update
.envwith your backend API endpoint and other required configuration.
Start the development server:
npm run devThe application will be available at http://localhost:5173 (default Vite port).
Starts the development server with hot module replacement (HMR).
Builds the TypeScript files and creates an optimized production build using Vite.
Runs ESLint to check code quality and formatting issues.
Previews the production build locally before deployment.
Create a .env file based on .env.example. Required variables:
VITE_API_BASE_URL=<your-backend-api-url>
VITE_JWT_TOKEN_KEY=authToken
# Add other required variablesThe project uses TypeScript for type safety. Configuration files:
tsconfig.json- Main TypeScript configurationtsconfig.app.json- Application-specific settingstsconfig.node.json- Node.js tooling settings
Configuration in vite.config.ts includes:
- React plugin with Babel refresh
- Port and proxy settings
- Build optimization options
- User Authentication - Sign up and login functionality
- User Profiles - View and manage user information
- Gallery Management - Upload and browse user galleries
- Responsive Design - Mobile-friendly interface
- Type Safety - Full TypeScript support
- Fast Development - Hot module replacement with Vite
- Code Quality - ESLint integration for code standards
Reusable UI components used across the application (buttons, cards, modals, etc.).
Page components corresponding to different routes (Home, Login, Gallery, Profile, etc.).
API service layer for communicating with the backend. Handles HTTP requests and data fetching.
React Context API setup for global state management (authentication state, user data, etc.).
Custom React hooks for reusable component logic (useAuth, useFetch, etc.).
Utility functions and helpers (formatters, validators, storage helpers, etc.).
Feature-specific modules that bundle components, services, and logic related to a specific feature.
The project uses ESLint with React-specific rules:
- React Hooks rules
- React Refresh compatibility
- Modern JavaScript standards
Run linting before committing:
npm run lintCreate an optimized production build:
npm run buildThe build output will be in the dist/ directory, ready for deployment.
Preview the production build locally:
npm run previewThis frontend communicates with the serverless backend API. Ensure the backend is deployed and configure the VITE_API_BASE_URL environment variable to point to your backend API endpoint.
POST /signup- User registrationPOST /login- User loginGET /users/{id}- Get user profileGET /users- Get all usersPOST /gallery/upload- Upload image to galleryGET /gallery/{email}- Get the user's gallery
A serverless backend application built with Node.js and AWS Lambda using the Serverless Framework. This application provides authentication, user management, and image gallery services powered by DynamoDB and S3.
- Overview
- Tech Stack
- Architecture
- Project Structure
- Getting Started
- Configuration
- API Endpoints
- Database Schema
- AWS Resources
- Deployment
- Environment Variables
- Contributing
This serverless backend provides RESTful API endpoints for user authentication, user management, and image gallery operations. It's built on AWS Lambda and integrates with DynamoDB for data storage and S3 for image uploads. The application uses JWT for authentication and bcryptjs for password hashing.
- Node.js 22.x - JavaScript runtime
- Serverless Framework - Infrastructure as Code for AWS Lambda
- AWS Lambda - Serverless compute service
- AWS DynamoDB - NoSQL database
- AWS S3 - Object storage for images
- AWS HTTP API - RESTful API gateway
- jsonwebtoken 9.0.3 - JWT token generation and validation
- bcryptjs 3.0.3 - Password hashing
- AWS SDK v3 - AWS service integration
- serverless-dotenv-plugin 6.0.0 - Environment variable management
βββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend Application (React) β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββ
β HTTP Requests
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββ
β AWS HTTP API Gateway β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββ
β
ββββββββββββΌβββββββββββ
βΌ βΌ βΌ
ββββββββββ ββββββββββ ββββββββββ
β Auth β β Users β βGallery β
β Lambda β β Lambda β β Lambda β
ββββββββββ ββββββββββ ββββββββββ
β β β
ββββββββββββΌβββββββββββ
β
ββββββββββββΌβββββββββββ
βΌ βΌ
ββββββββββββ ββββββββββββ
βDynamoDB β β S3 β
β Table β β Bucket β
ββββββββββββ ββββββββββββ
serverless/
βββ src/
β βββ handlers/ # Lambda function handlers
β β βββ auth/ # Authentication handlers
β β β βββ signup.ts # User registration
β β β βββ login.ts # User login
β β βββ users/ # User management handlers
β β β βββ getOne.ts # Fetch, single user
β β β βββ getAll.ts # Fetch all users
β β βββ gallery/ # Gallery handlers
β β βββ uploadImage.ts # Image upload
β β βββ getGallery.ts # Fetch gallery
β βββ middleware/ # Middleware functions
β βββ services/ # Business logic services
β βββ utils/ # Utility functions
β βββ config/ # Configuration files
βββ serverless.yml # Serverless configuration
βββ package.json # Dependencies and scripts
βββ package-lock.json # Dependency lock file
βββ .gitignore # Git ignore rules
βββ .env.example # Example environment variables
- Node.js (v22.x or higher)
- npm (v7 or higher)
- AWS Account with appropriate IAM permissions
- Serverless Framework CLI (
npm install -g serverless) - AWS CLI configured with credentials
-
Navigate to the backend directory:
cd serverless -
Install dependencies:
npm install
-
Create environment file:
cp .env.example .env
-
Configure environment variables:
JWT_SECRET=your_jwt_secret_key_here
To run the application locally for testing:
serverless offlineThis starts a local HTTP API gateway on http://localhost:3000.
The serverless.yml file defines:
- Service:
my-service - Provider: AWS with Node.js 22.x runtime
- Region: us-east-1 (configurable)
- HTTP API: With CORS enabled
- IAM Roles: DynamoDB and S3 permissions
- Resources: DynamoDB table and S3 bucket
Create a .env file:
# JWT Configuration
JWT_SECRET=your_secure_jwt_secret_key
# AWS Configuration (optional, uses AWS CLI credentials by default)
AWS_REGION=us-east-1Register a new user.
curl -X POST http://localhost:3000/signup \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "password123",
"name": "John Doe"
}'Response:
{
"id": "user-uuid",
"email": "user@example.com",
"name": "John Doe",
"token": "jwt-token"
}Authenticate the user and obtain a JWT.
curl -X POST http://localhost:3000/login \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "password123"
}'Response:
{
"id": "user-uuid",
"email": "user@example.com",
"token": "jwt-token"
}Fetch a specific user by ID.
curl -X GET http://localhost:3000/users/user-uuid \
-H "Authorization: Bearer jwt-token."Fetch all users.
curl -X GET http://localhost:3000/users \
-H "Authorization: Bearer jwt-token."Delete a user account.
curl -X DELETE http://localhost:3000/users/user-uuid \
-H "Authorization: Bearer jwt-token."Upload an image to the user's gallery.
curl -X POST http://localhost:3000/gallery/upload \
-H "Authorization: Bearer jwt-token" \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"imageBase64": "base64-encoded-image",
"filename": "photo.jpg"
}'Retrieve all images for a specific email.
curl -X GET http://localhost:3000/gallery/user@example.com \
-H "Authorization: Bearer jwt-token."Primary Key: id (String)
Global Secondary Index (GSI): EmailIndex on email attribute
Attributes:
{
id: string; // Unique user ID
email: string; // User email address
name: string; // User display name
password: string; // Hashed password (bcryptjs)
createdAt: number; // Timestamp
updatedAt: number; // Timestamp
}- Name:
users - Billing Mode: PAY_PER_REQUEST (on-demand)
- Partition Key:
id - Sort Key: None
- GSI:
EmailIndex(for email-based queries)
- Name:
my-user-uploads-unique-gallaries-2025 - Public Access: Allowed (configurable for security)
- CORS: Enabled for cross-origin requests
- Ownership: Bucket owner preferred
signup- Handles user registrationlogin- Handles user authenticationgetOne- Retrieves a single usergetAll- Retrieves all usersdeleteUser- Deletes a useruploadImage- Handles image uploads to S3getGallery- Retrieves the user's gallery
# Deploy to development stage
serverless deploy --stage dev
# Deploy to production stage
serverless deploy --stage prod# View logs for a specific function
serverless logs -f <function-name> --stage dev# Remove all AWS resources
serverless remove --stage dev- Password Security: Passwords are hashed using bcryptjs before storage
- JWT Authentication: All protected endpoints require valid JWT tokens
- CORS: Configure allowed origins in production
- IAM Roles: Functions have minimal required permissions
- Environment Variables: Sensitive data stored in environment variables, never in code
- Create a new handler file in
src/handlers/{feature}/. - Export a handler function:
export const handler = async (event) => {...} - Add the function definition to
serverless.yml - Define appropriate IAM permissions if needed
- Test locally with
serverless offline.
Standard error response format:
{
"statusCode": 400,
"body": {
"message": "Error description"
}
}Standard success response format:
{
"statusCode": 200,
"body": {
"data": {}
}
}@aws-sdk/client-dynamodb- AWS DynamoDB client@aws-sdk/lib-dynamodb- DynamoDB document clientjsonwebtoken- JWT token handlingbcryptjs- Password hashing
serverless-dotenv-plugin- Environment variable management
- Create a feature branch from
main. - Make your changes following the project structure
- Test with
serverless offline. - Submit a pull request with a description
This project is part of a full-stack serverless web application.
API Deployment Ready! π