A modern web application for selling digital templates and hosting a company blog, built with Node.js, TypeScript, PostgreSQL, and AWS services.
This project follows a clean architecture pattern with:
- Backend: Node.js with TypeScript and Express.js framework
- ORM: TypeORM for database management
- Database: PostgreSQL (production) / SQLite (development)
- Storage: AWS S3 with CloudFront CDN
- Authentication: AWS Cognito
- Payments: Stripe integration
- Email: SendGrid for notifications
- Frontend: Vanilla HTML/CSS/JS with Tailwind CSS
- Node.js 18.0 or higher
- npm 9.0 or higher
- PostgreSQL 13 or higher (for production)
- Docker (optional, for containerized development)
- AWS CLI (for deployment)
The easiest way to get started:
# Clone the repository
git clone <repository-url>
cd template-store-project
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Edit .env with your configuration values
# Start development server with hot reload
npm run devThis will automatically:
- âś… Start the backend API server on port 8080
- âś… Connect to the database (PostgreSQL or SQLite)
- âś… Enable hot reload for development
- âś… Set up TypeORM with automatic synchronization
If you prefer manual setup or need to customize the configuration:
# 1. Clone and setup
git clone <repository-url>
cd template-store-project
# 2. Install dependencies
npm install
# 3. Set up environment variables
cp .env.example .env
# Edit .env with your configuration values
# 4. Set up PostgreSQL (for production)
createdb template_store
# Or use SQLite for development (automatic)
# 5. Build the project
npm run build
# 6. Start the server
npm startOnce started, you can access:
- Frontend: http://localhost:3000 (served from web/ directory)
- Backend API: http://localhost:8080/api/v1/
- Health Check: http://localhost:8080/api/v1/health
- API Documentation: See swagger.yaml
Available npm scripts for development:
npm run dev # Start development server with hot reload
npm run build # Compile TypeScript to JavaScript
npm start # Start production server
npm run lint # Run ESLint code analysis
npm run format # Format code with Prettier
npm run typecheck # Type-check without emitting files# Initial setup
npm install # Install all dependencies
# Daily development
npm run dev # Start dev server (watches for changes)
# Before committing
npm run lint # Check code style
npm run format # Format code
npm run typecheck # Verify types
# Production build
npm run build # Build for production
npm start # Run production servertemplate-store-project/
├── src/ # TypeScript source code
│ ├── config/ # Configuration management
│ ├── database/ # Database connection setup
│ ├── models/ # TypeORM entities (10 models)
│ ├── routes/ # API route handlers (7 modules)
│ ├── middleware/ # Authentication & RBAC middleware
│ ├── services/ # Business logic layer (9 services)
│ ├── utils/ # Utility functions (logger, etc.)
│ └── server.ts # Main application entry point
├── dist/ # Compiled JavaScript output
├── web/ # Frontend assets (HTML/CSS/JS)
├── node_modules/ # Dependencies
├── logs/ # Application logs
├── scripts/ # Utility scripts
├── package.json # npm dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── .env.example # Environment variables template
└── docs/ # Documentation (*.md files)
The backend provides comprehensive REST APIs:
POST /register- User registrationPOST /login- User loginPOST /forgot-password- Password reset requestPOST /reset-password- Password reset confirmationPOST /change-password- Change password (authenticated)
GET /- Get user profilePUT /- Update user profileGET /orders- List user ordersGET /purchased-templates- List purchased templates
GET /- List all templatesGET /:id- Get template detailsPOST /- Create template (author/admin)PUT /:id- Update template (author/admin)DELETE /:id- Delete template (author/admin)
GET /- List blog postsGET /:id- Get blog postPOST /- Create post (author/admin)PUT /:id- Update post (author/admin)DELETE /:id- Delete post (author/admin)
POST /checkout- Create Stripe checkout sessionPOST /webhooks/stripe- Stripe webhook handler
For full API documentation, see swagger.yaml.
See .env.example for all available configuration options including:
- Database connection settings
- AWS Cognito configuration
- AWS S3 credentials
- Stripe API keys
- SendGrid API key
# Type checking
npm run typecheck
# Linting
npm run lint
# Format checking
npm run format
# Note: Unit and integration tests are planned for future implementation# Build TypeScript to JavaScript
npm run build
# Output will be in dist/ directory
# Run with: npm start# Run with hot reload (recommended)
npm run dev
# Run with Docker (if docker-compose.yml configured)
docker-compose upThe application is designed to be deployed on AWS with the following setup:
- Compute: AWS ECS/EC2 or any Node.js hosting platform
- Database: AWS RDS PostgreSQL
- Storage: AWS S3 for file uploads
- CDN: CloudFront for content delivery
- Authentication: AWS Cognito user pools
-
Build the application:
npm run build
-
Set environment variables:
- Set
NODE_ENV=production - Configure all AWS credentials
- Set database connection strings
- Configure Stripe and SendGrid API keys
- Set
-
Run the production server:
npm start
-
Process Management:
- Use PM2, systemd, or Docker for process management
- Example with PM2:
npm install -g pm2 pm2 start dist/server.js --name template-store pm2 save
- Set
NODE_ENV=production - Use PostgreSQL (not SQLite)
- Disable TypeORM
synchronize(use migrations) - Configure proper CORS settings
- Enable HTTPS/TLS
- Set up monitoring and logging
- Configure backup strategy
- Set up CI/CD pipeline
- Language: TypeScript 5.7
- Runtime: Node.js 18+
- Framework: Express.js 4.x
- ORM: TypeORM 0.3.x
- Database: PostgreSQL / SQLite
- Logging: Winston
- AWS Cognito: User authentication
- AWS S3: File storage
- Stripe: Payment processing
- SendGrid: Email notifications
- HTML/CSS/JS: Vanilla JavaScript
- CSS Framework: Tailwind CSS
- Markdown: Marked library for blog rendering
The application includes 10 TypeORM entities:
- User - User accounts and profiles
- Category - Content categories
- Template - Digital templates for sale
- BlogPost - Blog articles with Markdown support
- Order - Purchase orders and transaction history
- LoginHistory - User login tracking
- ActivityLog - User activity tracking
- PasswordResetToken - Password reset tokens
- EmailVerificationToken - Email verification tokens
- UserPreferences - User settings and preferences
This project was recently migrated from Go to Node.js/TypeScript. For details, see:
- BACKEND_MIGRATION.md - Complete migration documentation
- CLEANUP_SUMMARY.md - Cleanup details
Additional documentation is available:
- API_DOCUMENTATION.md - API reference
- AUTHENTICATION_SUMMARY.md - Authentication details
- PAYMENT_INTEGRATION_SUMMARY.md - Payment integration
- BLOG_MANAGEMENT_GUIDE.md - Blog management
- swagger.yaml - OpenAPI specification
- Fork the repository
- Create a feature branch
- Make your changes
- Run linting and type checking:
npm run lint npm run typecheck npm run format
- Test your changes thoroughly
- Submit a pull request
MIT License
For support and questions:
- Create an issue on GitHub
- Check existing documentation in the docs folder
- Review the migration guide if you have questions about the architecture