Overview
Huellitas Pet Shop consists of two main components:- Backend API: .NET 9.0 API deployed to Render using Docker
- Frontend: React + Vite application deployed to GitHub Pages
Backend Deployment to Render
Prerequisites
- GitHub account with the Huellitas repository
- Render account (free tier available)
- PostgreSQL database (Neon or Render PostgreSQL)
Dockerfile Configuration
The backend uses a multi-stage Dockerfile for optimal image size:- Multi-stage build: Reduces final image size by separating build and runtime
- Port 8080: Standard port for Render web services
- ASP.NET Core 9.0: Latest .NET runtime
Render Setup Steps
1. Create New Web Service
- Log in to Render Dashboard
- Click New + → Web Service
- Connect your GitHub repository
- Select the
huellitasBackEnddirectory
2. Configure Service Settings
| Setting | Value |
|---|---|
| Name | huellitas-api |
| Region | Choose closest to your users |
| Branch | main or master |
| Root Directory | huellitasBackEnd/Huellitas.API |
| Runtime | Docker |
| Instance Type | Free (or paid for production) |
3. Environment Variables
Add these environment variables in Render dashboard:4. Deploy
Render will automatically:- Build the Docker image
- Run database migrations (if configured)
- Deploy the container
- Assign a public URL (e.g.,
https://huellitas-api.onrender.com)
Database Configuration
The API connects to PostgreSQL using Entity Framework Core:- Create a free PostgreSQL database at Neon.tech
- Copy the connection string
- Add to Render environment variables
- Format:
Host=ep-xxx.region.aws.neon.tech;Database=huellitas;Username=user;Password=pass;SSL Mode=Require
CORS Configuration
Configure CORS to allow frontend requests:For production, replace
AllowAnyOrigin() with specific frontend URLs:Health Checks
Render automatically monitors your service. The API exposes endpoints:/api/productos- Products endpoint/api/auth/login- Authentication/swagger- API documentation (development only)
Troubleshooting
Build Failures:- Check Dockerfile path is correct
- Verify .csproj file exists in root directory
- Review build logs in Render dashboard
- Verify all environment variables are set
- Check database connection string format
- Ensure port 8080 is exposed in Dockerfile
- Confirm PostgreSQL allows external connections
- Check SSL mode requirement (Neon requires SSL)
- Verify credentials are correct
Frontend Deployment to GitHub Pages
Prerequisites
- GitHub repository with frontend code
- Node.js 18+ installed locally
- npm or yarn package manager
Vite Configuration
Configure the base path for GitHub Pages:The
base path must match your repository name for GitHub Pages to work correctly.Package.json Scripts
The frontend includes deployment scripts:Deployment Steps
1. Install Dependencies
2. Build for Production
dist/ directory.
3. Deploy to GitHub Pages
- Runs
predeployscript (builds the app) - Publishes
distfolder togh-pagesbranch - GitHub Pages automatically serves from that branch
4. Configure GitHub Repository
- Go to repository Settings → Pages
- Select Source: Deploy from branch
- Select Branch:
gh-pages/root - Save and wait for deployment
https://yourusername.github.io/petshopHuellitas/
Environment Configuration
Update API endpoint for production:Automatic Deployment with GitHub Actions
Create.github/workflows/deploy.yml for automatic deployment:
Asset Optimization
Vite automatically optimizes assets during build:- Code splitting: Splits JavaScript into chunks
- Tree shaking: Removes unused code
- Minification: Compresses HTML, CSS, JS
- Image optimization: Optimizes images in public folder
Custom Domain (Optional)
To use a custom domain:-
Create
public/CNAMEfile: -
Configure DNS records:
- Enable HTTPS in GitHub Pages settings
Production Checklist
Backend
- Environment variables configured
- Database migrations applied
- JWT secret key is secure (32+ characters)
- CORS restricted to frontend domain
- Swagger disabled in production
- Logging configured
- Health check endpoint working
Frontend
- API endpoint points to production URL
- Base path matches repository name
- Build succeeds without warnings
- Environment variables set
- Error boundaries implemented
- Loading states for API calls
- 404 page configured
Testing
- Test all API endpoints from frontend
- Verify authentication flow
- Check mobile responsiveness
- Test on multiple browsers
- Verify error handling
Monitoring and Maintenance
Render Monitoring
- View logs in Render dashboard
- Set up email alerts for downtime
- Monitor response times and errors
- Check database connection pool
GitHub Pages Analytics
- Enable GitHub Pages insights
- Use Google Analytics for visitor tracking
- Monitor Core Web Vitals
Free Tier Limitations
Render Free Tier:- Service spins down after 15 minutes of inactivity
- First request after spin-down takes 30-60 seconds
- 750 hours/month free (enough for one service)
- 1GB repository size limit
- 100GB bandwidth/month
- 10 builds/hour limit
Next Steps
Data Pipeline
Learn how to populate your database with products and users
Admin Dashboard
Explore admin panel features and analytics