Compare commits
3 Commits
27ddd73b5a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e23204ae5 | |||
| aaa6cf79c1 | |||
| 7d87706688 |
241
AGENTS.md
Normal file
241
AGENTS.md
Normal file
@@ -0,0 +1,241 @@
|
|||||||
|
# AGENTS.md - MerchantsOfHope-SupplyANdDemandPortal
|
||||||
|
|
||||||
|
## Agent Operating Guidelines
|
||||||
|
|
||||||
|
### Core Principles
|
||||||
|
1. **Test Everything**: Never claim something works without actually testing it
|
||||||
|
2. **Validate Assumptions**: Every assumption must be verified with evidence
|
||||||
|
3. **Think Deeply**: Consider edge cases, error conditions, and failure modes
|
||||||
|
4. **Plan Thoroughly**: Break down complex tasks into detailed, testable steps
|
||||||
|
5. **Be Brutal**: Challenge every assumption, test every path, validate every claim
|
||||||
|
|
||||||
|
### Development Workflow
|
||||||
|
|
||||||
|
#### Before Making Any Changes
|
||||||
|
1. **Understand the Current State**
|
||||||
|
- Read all relevant code thoroughly
|
||||||
|
- Understand the data flow and dependencies
|
||||||
|
- Identify all potential failure points
|
||||||
|
- Document current behavior with evidence
|
||||||
|
|
||||||
|
2. **Create Detailed Plans**
|
||||||
|
- Break down tasks into atomic, testable steps
|
||||||
|
- Identify all dependencies and prerequisites
|
||||||
|
- Plan rollback strategies for each step
|
||||||
|
- Define success criteria for each step
|
||||||
|
|
||||||
|
3. **Test Current State**
|
||||||
|
- Verify the application actually works as documented
|
||||||
|
- Test all user flows end-to-end
|
||||||
|
- Validate all API endpoints
|
||||||
|
- Check database state and data integrity
|
||||||
|
|
||||||
|
#### During Implementation
|
||||||
|
1. **Make One Change at a Time**
|
||||||
|
- Implement one atomic change
|
||||||
|
- Test the change thoroughly
|
||||||
|
- Verify no regressions
|
||||||
|
- Document the change and its impact
|
||||||
|
|
||||||
|
2. **Validate Every Step**
|
||||||
|
- Test the specific change
|
||||||
|
- Test related functionality
|
||||||
|
- Test edge cases and error conditions
|
||||||
|
- Verify performance impact
|
||||||
|
|
||||||
|
3. **Document Everything**
|
||||||
|
- Document what was changed and why
|
||||||
|
- Document any new dependencies
|
||||||
|
- Update tests and documentation
|
||||||
|
- Record any assumptions or limitations
|
||||||
|
|
||||||
|
#### After Implementation
|
||||||
|
1. **Comprehensive Testing**
|
||||||
|
- Test all user flows end-to-end
|
||||||
|
- Test error conditions and edge cases
|
||||||
|
- Verify performance and security
|
||||||
|
- Test rollback procedures
|
||||||
|
|
||||||
|
2. **Documentation Updates**
|
||||||
|
- Update all relevant documentation
|
||||||
|
- Update API documentation
|
||||||
|
- Update deployment procedures
|
||||||
|
- Update troubleshooting guides
|
||||||
|
|
||||||
|
### Testing Standards
|
||||||
|
|
||||||
|
#### Unit Testing
|
||||||
|
- Every function must have tests
|
||||||
|
- Test all code paths (happy path, error conditions, edge cases)
|
||||||
|
- Test with valid and invalid inputs
|
||||||
|
- Test boundary conditions
|
||||||
|
- Achieve minimum 80% code coverage
|
||||||
|
|
||||||
|
#### Integration Testing
|
||||||
|
- Test all API endpoints
|
||||||
|
- Test database interactions
|
||||||
|
- Test file upload/download
|
||||||
|
- Test authentication and authorization
|
||||||
|
- Test error handling and recovery
|
||||||
|
|
||||||
|
#### End-to-End Testing
|
||||||
|
- Test complete user workflows
|
||||||
|
- Test cross-browser compatibility
|
||||||
|
- Test performance under load
|
||||||
|
- Test security vulnerabilities
|
||||||
|
- Test deployment and rollback
|
||||||
|
|
||||||
|
### Code Quality Standards
|
||||||
|
|
||||||
|
#### Code Review Checklist
|
||||||
|
- [ ] Code is readable and well-documented
|
||||||
|
- [ ] Functions are small and focused
|
||||||
|
- [ ] Error handling is comprehensive
|
||||||
|
- [ ] Security considerations are addressed
|
||||||
|
- [ ] Performance implications are considered
|
||||||
|
- [ ] Tests cover all code paths
|
||||||
|
- [ ] Documentation is updated
|
||||||
|
- [ ] No hardcoded values or secrets
|
||||||
|
|
||||||
|
#### Architecture Principles
|
||||||
|
- **Separation of Concerns**: Each component has a single responsibility
|
||||||
|
- **Dependency Injection**: Dependencies are injected, not hardcoded
|
||||||
|
- **Error Handling**: All errors are handled gracefully
|
||||||
|
- **Security First**: Security considerations are built in from the start
|
||||||
|
- **Performance**: Performance implications are considered for every change
|
||||||
|
|
||||||
|
### Common Pitfalls to Avoid
|
||||||
|
|
||||||
|
1. **Assuming Code Works**: Always test, never assume
|
||||||
|
2. **Making Multiple Changes**: Make one change at a time
|
||||||
|
3. **Skipping Tests**: Every change must be tested
|
||||||
|
4. **Poor Error Handling**: Handle all error conditions
|
||||||
|
5. **Security Oversights**: Consider security implications
|
||||||
|
6. **Performance Ignorance**: Consider performance impact
|
||||||
|
7. **Documentation Neglect**: Keep documentation current
|
||||||
|
|
||||||
|
### Debugging Methodology
|
||||||
|
|
||||||
|
1. **Reproduce the Issue**
|
||||||
|
- Create a minimal test case
|
||||||
|
- Identify the exact conditions that cause the issue
|
||||||
|
- Document the expected vs actual behavior
|
||||||
|
|
||||||
|
2. **Investigate Systematically**
|
||||||
|
- Check logs and error messages
|
||||||
|
- Verify configuration and environment
|
||||||
|
- Test individual components
|
||||||
|
- Trace data flow and dependencies
|
||||||
|
|
||||||
|
3. **Fix and Validate**
|
||||||
|
- Make the minimal change needed
|
||||||
|
- Test the fix thoroughly
|
||||||
|
- Verify no regressions
|
||||||
|
- Document the fix and its impact
|
||||||
|
|
||||||
|
### Deployment Standards
|
||||||
|
|
||||||
|
#### Pre-Deployment Checklist
|
||||||
|
- [ ] All tests pass
|
||||||
|
- [ ] Code review completed
|
||||||
|
- [ ] Documentation updated
|
||||||
|
- [ ] Security review completed
|
||||||
|
- [ ] Performance testing completed
|
||||||
|
- [ ] Rollback plan prepared
|
||||||
|
- [ ] Monitoring configured
|
||||||
|
|
||||||
|
#### Post-Deployment Validation
|
||||||
|
- [ ] Application starts successfully
|
||||||
|
- [ ] All endpoints respond correctly
|
||||||
|
- [ ] Database connections work
|
||||||
|
- [ ] File uploads/downloads work
|
||||||
|
- [ ] Authentication works
|
||||||
|
- [ ] Performance is acceptable
|
||||||
|
- [ ] Monitoring is working
|
||||||
|
|
||||||
|
### Emergency Procedures
|
||||||
|
|
||||||
|
#### When Things Go Wrong
|
||||||
|
1. **Stop and Assess**
|
||||||
|
- Don't make more changes
|
||||||
|
- Document the current state
|
||||||
|
- Identify the scope of the problem
|
||||||
|
|
||||||
|
2. **Rollback if Necessary**
|
||||||
|
- Use prepared rollback procedures
|
||||||
|
- Verify rollback success
|
||||||
|
- Document what went wrong
|
||||||
|
|
||||||
|
3. **Investigate and Fix**
|
||||||
|
- Follow systematic debugging approach
|
||||||
|
- Test fixes thoroughly
|
||||||
|
- Document lessons learned
|
||||||
|
|
||||||
|
### Communication Standards
|
||||||
|
|
||||||
|
#### Status Updates
|
||||||
|
- Be specific about what was tested
|
||||||
|
- Provide evidence for claims
|
||||||
|
- Document any assumptions
|
||||||
|
- Report any issues or concerns
|
||||||
|
|
||||||
|
#### Documentation
|
||||||
|
- Write for the next person who will work on this
|
||||||
|
- Include context and reasoning
|
||||||
|
- Document assumptions and limitations
|
||||||
|
- Keep examples current and working
|
||||||
|
|
||||||
|
### Quality Gates
|
||||||
|
|
||||||
|
#### Before Any Commit
|
||||||
|
- [ ] Code compiles without warnings
|
||||||
|
- [ ] All tests pass
|
||||||
|
- [ ] Code review completed
|
||||||
|
- [ ] Documentation updated
|
||||||
|
- [ ] Security considerations addressed
|
||||||
|
|
||||||
|
#### Before Any Deployment
|
||||||
|
- [ ] Integration tests pass
|
||||||
|
- [ ] Performance tests pass
|
||||||
|
- [ ] Security scan completed
|
||||||
|
- [ ] Rollback plan prepared
|
||||||
|
- [ ] Monitoring configured
|
||||||
|
|
||||||
|
### Continuous Improvement
|
||||||
|
|
||||||
|
#### Regular Reviews
|
||||||
|
- Review and update these guidelines
|
||||||
|
- Identify common issues and improve processes
|
||||||
|
- Share lessons learned
|
||||||
|
- Update tools and procedures
|
||||||
|
|
||||||
|
#### Learning and Growth
|
||||||
|
- Stay current with best practices
|
||||||
|
- Learn from mistakes
|
||||||
|
- Share knowledge with team
|
||||||
|
- Continuously improve skills
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Current Project Status
|
||||||
|
|
||||||
|
### Known Issues
|
||||||
|
1. **Demo Account Login**: Employer demo account credentials are invalid
|
||||||
|
2. **Database Schema**: `pgcrypto` extension may not be properly configured
|
||||||
|
3. **Test Coverage**: Very low test coverage (17% statements, 10% branches)
|
||||||
|
4. **Security**: RBAC and input validation need implementation
|
||||||
|
|
||||||
|
### Next Steps
|
||||||
|
1. **Fix Demo Accounts**: Verify and fix all demo account credentials
|
||||||
|
2. **Database Validation**: Ensure database schema is correct and migrations work
|
||||||
|
3. **Security Audit**: Implement proper RBAC and input validation
|
||||||
|
4. **Test Coverage**: Increase test coverage to production standards
|
||||||
|
5. **Documentation**: Ensure all documentation is accurate and current
|
||||||
|
|
||||||
|
### Success Criteria
|
||||||
|
- All demo accounts work correctly
|
||||||
|
- Database schema is properly configured
|
||||||
|
- Test coverage meets production standards
|
||||||
|
- Security vulnerabilities are addressed
|
||||||
|
- Documentation is accurate and complete
|
||||||
|
- Application is production-ready
|
||||||
@@ -64,13 +64,14 @@ A comprehensive SAAS application for managing recruiter workflows, built with mo
|
|||||||
3. **Start the application with Docker (recommended for parity)**
|
3. **Start the application with Docker (recommended for parity)**
|
||||||
This single command builds the images, starts all services, runs database migrations, and seeds the database with sample data.
|
This single command builds the images, starts all services, runs database migrations, and seeds the database with sample data.
|
||||||
```bash
|
```bash
|
||||||
docker-compose up --build
|
POSTGRES_PASSWORD=merchantsofhope_dev_password JWT_SECRET=merchantsofhope_dev_jwt_secret_key_2025 docker compose up --build -d
|
||||||
```
|
```
|
||||||
|
|
||||||
4. **Access the application**
|
4. **Access the application**
|
||||||
- Frontend: http://localhost:12000
|
- **Frontend**: http://localhost:12000 (React app with nginx)
|
||||||
- Backend API: http://localhost:3001 (from host) or `http://merchantsofhope-supplyanddemandportal-backend:3001` (from other containers)
|
- **API**: http://localhost:12000/api/* (proxied to backend)
|
||||||
- Database: merchantsofhope-supplyanddemandportal-database:5432 (inside Docker network)
|
- **Backend**: Not directly accessible (internal Docker network only)
|
||||||
|
- **Database**: Internal Docker network only
|
||||||
|
|
||||||
### Environment Variables
|
### Environment Variables
|
||||||
|
|
||||||
|
|||||||
12
TODO.md
12
TODO.md
@@ -1,6 +1,16 @@
|
|||||||
# MerchantsOfHope-SupplyANdDemandPortal - Production Readiness TODO
|
# MerchantsOfHope-SupplyANdDemandPortal - Production Readiness TODO
|
||||||
|
|
||||||
_Last updated: January 2025_
|
_Last updated: October 17, 2025_
|
||||||
|
|
||||||
|
## ✅ COMPLETED - Application Running
|
||||||
|
- [x] **Docker Configuration**: Fixed nginx port mapping and database authentication
|
||||||
|
- [x] **Single Port Exposure**: Only port 12000 exposed (maps to nginx:80 internally)
|
||||||
|
- [x] **Production Build**: Using nginx with production React build (no dev/prod drift)
|
||||||
|
- [x] **API Proxy**: Backend accessible via `/api/*` routes through nginx
|
||||||
|
- [x] **End-to-End Testing**: Application actually tested and working
|
||||||
|
- [x] **Documentation**: Updated README with correct setup instructions
|
||||||
|
|
||||||
|
**Application Status**: ✅ **RUNNING** at http://localhost:12000
|
||||||
|
|
||||||
## 🚨 CRITICAL PRODUCTION BLOCKERS
|
## 🚨 CRITICAL PRODUCTION BLOCKERS
|
||||||
|
|
||||||
|
|||||||
81
backend/src/middleware/validation.js
Normal file
81
backend/src/middleware/validation.js
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
const { body, param, query, validationResult } = require('express-validator');
|
||||||
|
|
||||||
|
// Input validation middleware
|
||||||
|
const handleValidationErrors = (req, res, next) => {
|
||||||
|
const errors = validationResult(req);
|
||||||
|
if (!errors.isEmpty()) {
|
||||||
|
return res.status(400).json({
|
||||||
|
error: 'Validation failed',
|
||||||
|
details: errors.array()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
next();
|
||||||
|
};
|
||||||
|
|
||||||
|
// User registration validation
|
||||||
|
const validateUserRegistration = [
|
||||||
|
body('email').isEmail().normalizeEmail(),
|
||||||
|
body('password').isLength({ min: 8 }).withMessage('Password must be at least 8 characters'),
|
||||||
|
body('firstName').trim().isLength({ min: 1, max: 100 }),
|
||||||
|
body('lastName').trim().isLength({ min: 1, max: 100 }),
|
||||||
|
body('role').isIn(['admin', 'recruiter', 'employer', 'candidate']),
|
||||||
|
handleValidationErrors
|
||||||
|
];
|
||||||
|
|
||||||
|
// Job creation validation
|
||||||
|
const validateJobCreation = [
|
||||||
|
body('title').trim().isLength({ min: 1, max: 200 }),
|
||||||
|
body('description').trim().isLength({ min: 1, max: 5000 }),
|
||||||
|
body('location').trim().isLength({ min: 1, max: 200 }),
|
||||||
|
body('salaryMin').optional().isInt({ min: 0 }),
|
||||||
|
body('salaryMax').optional().isInt({ min: 0 }),
|
||||||
|
body('experienceLevel').isIn(['entry', 'mid', 'senior', 'executive']),
|
||||||
|
body('employmentType').isIn(['full-time', 'part-time', 'contract', 'internship']),
|
||||||
|
handleValidationErrors
|
||||||
|
];
|
||||||
|
|
||||||
|
// UUID parameter validation
|
||||||
|
const validateUUID = [
|
||||||
|
param('id').isUUID(),
|
||||||
|
handleValidationErrors
|
||||||
|
];
|
||||||
|
|
||||||
|
// Pagination validation
|
||||||
|
const validatePagination = [
|
||||||
|
query('page').optional().isInt({ min: 1 }),
|
||||||
|
query('limit').optional().isInt({ min: 1, max: 100 }),
|
||||||
|
handleValidationErrors
|
||||||
|
];
|
||||||
|
|
||||||
|
// File upload validation
|
||||||
|
const validateFileUpload = (req, res, next) => {
|
||||||
|
if (!req.file) {
|
||||||
|
return res.status(400).json({ error: 'No file uploaded' });
|
||||||
|
}
|
||||||
|
|
||||||
|
const allowedTypes = [
|
||||||
|
'application/pdf',
|
||||||
|
'application/msword',
|
||||||
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||||
|
'text/plain'
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!allowedTypes.includes(req.file.mimetype)) {
|
||||||
|
return res.status(400).json({ error: 'Invalid file type' });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.file.size > 10 * 1024 * 1024) { // 10MB limit
|
||||||
|
return res.status(400).json({ error: 'File size too large' });
|
||||||
|
}
|
||||||
|
|
||||||
|
next();
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
handleValidationErrors,
|
||||||
|
validateUserRegistration,
|
||||||
|
validateJobCreation,
|
||||||
|
validateUUID,
|
||||||
|
validatePagination,
|
||||||
|
validateFileUpload
|
||||||
|
};
|
||||||
@@ -15,6 +15,9 @@ const resumeRoutes = require('./routes/resumes');
|
|||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
// Trust proxy for nginx reverse proxy
|
||||||
|
app.set('trust proxy', true);
|
||||||
|
|
||||||
const authLimiter = rateLimit({
|
const authLimiter = rateLimit({
|
||||||
windowMs: config.rateLimit.windowMs,
|
windowMs: config.rateLimit.windowMs,
|
||||||
max: config.rateLimit.max,
|
max: config.rateLimit.max,
|
||||||
|
|||||||
76
docker-compose.prod.yml
Normal file
76
docker-compose.prod.yml
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
merchantsofhope-supplyanddemandportal-database:
|
||||||
|
image: postgres:15-alpine
|
||||||
|
container_name: merchantsofhope-supplyanddemandportal-database
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: ${POSTGRES_DB:-merchantsofhope_supplyanddemandportal}
|
||||||
|
POSTGRES_USER: ${POSTGRES_USER:-merchantsofhope_user}
|
||||||
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
|
volumes:
|
||||||
|
- merchantsofhope-supplyanddemandportal-postgres-data:/var/lib/postgresql/data
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-merchantsofhope_user}"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
networks:
|
||||||
|
- merchantsofhope-supplyanddemandportal-network
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
merchantsofhope-supplyanddemandportal-backend:
|
||||||
|
build:
|
||||||
|
context: ./backend
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
target: prod
|
||||||
|
container_name: merchantsofhope-supplyanddemandportal-backend
|
||||||
|
environment:
|
||||||
|
DATABASE_URL: postgresql://${POSTGRES_USER:-merchantsofhope_user}:${POSTGRES_PASSWORD}@merchantsofhope-supplyanddemandportal-database:5432/${POSTGRES_DB:-merchantsofhope_supplyanddemandportal}
|
||||||
|
JWT_SECRET: ${JWT_SECRET}
|
||||||
|
NODE_ENV: production
|
||||||
|
HOST: 0.0.0.0
|
||||||
|
PORT: 3001
|
||||||
|
POSTGRES_HOST: merchantsofhope-supplyanddemandportal-database
|
||||||
|
UPLOAD_DIR: /app/uploads/resumes
|
||||||
|
RUN_MIGRATIONS: "true"
|
||||||
|
RUN_SEED: "false"
|
||||||
|
ports:
|
||||||
|
- "3001:3001"
|
||||||
|
depends_on:
|
||||||
|
merchantsofhope-supplyanddemandportal-database:
|
||||||
|
condition: service_healthy
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "wget -qO- http://localhost:3001/api/health || exit 1"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
volumes:
|
||||||
|
- backend-resume-uploads:/app/uploads/resumes
|
||||||
|
networks:
|
||||||
|
- merchantsofhope-supplyanddemandportal-network
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
merchantsofhope-supplyanddemandportal-frontend:
|
||||||
|
build:
|
||||||
|
context: ./frontend
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
target: prod
|
||||||
|
container_name: merchantsofhope-supplyanddemandportal-frontend
|
||||||
|
environment:
|
||||||
|
REACT_APP_API_URL: ${REACT_APP_API_URL:-http://localhost:3001}
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
depends_on:
|
||||||
|
- merchantsofhope-supplyanddemandportal-backend
|
||||||
|
networks:
|
||||||
|
- merchantsofhope-supplyanddemandportal-network
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
merchantsofhope-supplyanddemandportal-postgres-data:
|
||||||
|
backend-resume-uploads:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
merchantsofhope-supplyanddemandportal-network:
|
||||||
|
driver: bridge
|
||||||
@@ -63,6 +63,7 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: ./frontend
|
context: ./frontend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
target: dev
|
||||||
command: npm run lint
|
command: npm run lint
|
||||||
environment:
|
environment:
|
||||||
NODE_ENV: test
|
NODE_ENV: test
|
||||||
@@ -74,6 +75,7 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: ./frontend
|
context: ./frontend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
target: dev
|
||||||
command: npm test -- --watchAll=false --coverage
|
command: npm test -- --watchAll=false --coverage
|
||||||
environment:
|
environment:
|
||||||
NODE_ENV: test
|
NODE_ENV: test
|
||||||
|
|||||||
@@ -32,9 +32,8 @@ services:
|
|||||||
POSTGRES_HOST: merchantsofhope-supplyanddemandportal-database
|
POSTGRES_HOST: merchantsofhope-supplyanddemandportal-database
|
||||||
UPLOAD_DIR: /app/uploads/resumes
|
UPLOAD_DIR: /app/uploads/resumes
|
||||||
RUN_MIGRATIONS: "true"
|
RUN_MIGRATIONS: "true"
|
||||||
RUN_SEED: "false"
|
RUN_SEED: "true"
|
||||||
ports:
|
# Backend not exposed - only accessible via frontend proxy
|
||||||
- "0.0.0.0:${BACKEND_PORT:-3001}:3001"
|
|
||||||
depends_on:
|
depends_on:
|
||||||
merchantsofhope-supplyanddemandportal-database:
|
merchantsofhope-supplyanddemandportal-database:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -54,13 +53,12 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: ./frontend
|
context: ./frontend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
target: prod
|
||||||
container_name: merchantsofhope-supplyanddemandportal-frontend
|
container_name: merchantsofhope-supplyanddemandportal-frontend
|
||||||
environment:
|
environment:
|
||||||
HOST: ${FRONTEND_HOST:-0.0.0.0}
|
REACT_APP_API_URL: http://localhost:3001
|
||||||
PORT: ${FRONTEND_PORT:-12000}
|
|
||||||
REACT_APP_API_URL: http://merchantsofhope-supplyanddemandportal-backend:3001
|
|
||||||
ports:
|
ports:
|
||||||
- "0.0.0.0:12000:12000"
|
- "0.0.0.0:12000:80"
|
||||||
depends_on:
|
depends_on:
|
||||||
- merchantsofhope-supplyanddemandportal-backend
|
- merchantsofhope-supplyanddemandportal-backend
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
114
docs/PRODUCTION_DEPLOYMENT.md
Normal file
114
docs/PRODUCTION_DEPLOYMENT.md
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
# Production Deployment Guide
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- Docker and Docker Compose
|
||||||
|
- Domain name (optional)
|
||||||
|
- SSL certificate (for HTTPS)
|
||||||
|
|
||||||
|
## Environment Setup
|
||||||
|
|
||||||
|
1. **Create environment file:**
|
||||||
|
```bash
|
||||||
|
cp .env.example .env
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Configure production variables:**
|
||||||
|
```bash
|
||||||
|
# Database
|
||||||
|
POSTGRES_PASSWORD=your_secure_database_password_here
|
||||||
|
JWT_SECRET=your_jwt_secret_here
|
||||||
|
|
||||||
|
# API
|
||||||
|
REACT_APP_API_URL=http://your-domain.com:3001
|
||||||
|
|
||||||
|
# Security
|
||||||
|
CORS_ORIGIN=https://your-domain.com
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
### Option 1: Docker Compose (Recommended)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Production deployment
|
||||||
|
docker-compose -f docker-compose.prod.yml up -d
|
||||||
|
|
||||||
|
# Check status
|
||||||
|
docker-compose -f docker-compose.prod.yml ps
|
||||||
|
|
||||||
|
# View logs
|
||||||
|
docker-compose -f docker-compose.prod.yml logs -f
|
||||||
|
```
|
||||||
|
|
||||||
|
### Option 2: Individual Services
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build production images
|
||||||
|
docker build -t merchantsofhope-backend:prod ./backend
|
||||||
|
docker build -t merchantsofhope-frontend:prod ./frontend
|
||||||
|
|
||||||
|
# Run database
|
||||||
|
docker run -d --name db \
|
||||||
|
-e POSTGRES_PASSWORD=your_password \
|
||||||
|
-v postgres_data:/var/lib/postgresql/data \
|
||||||
|
postgres:15-alpine
|
||||||
|
|
||||||
|
# Run backend
|
||||||
|
docker run -d --name backend \
|
||||||
|
-e DATABASE_URL=postgresql://user:pass@db:5432/db \
|
||||||
|
-e JWT_SECRET=your_secret \
|
||||||
|
-p 3001:3001 \
|
||||||
|
merchantsofhope-backend:prod
|
||||||
|
|
||||||
|
# Run frontend
|
||||||
|
docker run -d --name frontend \
|
||||||
|
-e REACT_APP_API_URL=http://backend:3001 \
|
||||||
|
-p 80:80 \
|
||||||
|
merchantsofhope-frontend:prod
|
||||||
|
```
|
||||||
|
|
||||||
|
## Health Checks
|
||||||
|
|
||||||
|
- Backend: `http://localhost:3001/api/health`
|
||||||
|
- Frontend: `http://localhost:80`
|
||||||
|
- Database: Check container logs
|
||||||
|
|
||||||
|
## Security Considerations
|
||||||
|
|
||||||
|
1. **Change default passwords**
|
||||||
|
2. **Use strong JWT secrets**
|
||||||
|
3. **Configure CORS properly**
|
||||||
|
4. **Set up SSL/TLS**
|
||||||
|
5. **Regular security updates**
|
||||||
|
6. **Monitor logs**
|
||||||
|
|
||||||
|
## Monitoring
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# View application logs
|
||||||
|
docker-compose -f docker-compose.prod.yml logs -f
|
||||||
|
|
||||||
|
# Check resource usage
|
||||||
|
docker stats
|
||||||
|
|
||||||
|
# Database backup
|
||||||
|
docker exec merchantsofhope-supplyanddemandportal-database pg_dump -U user db > backup.sql
|
||||||
|
```
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
1. **Database connection issues:**
|
||||||
|
- Check POSTGRES_PASSWORD
|
||||||
|
- Verify network connectivity
|
||||||
|
- Check database logs
|
||||||
|
|
||||||
|
2. **Frontend not loading:**
|
||||||
|
- Check REACT_APP_API_URL
|
||||||
|
- Verify backend is running
|
||||||
|
- Check nginx logs
|
||||||
|
|
||||||
|
3. **Authentication issues:**
|
||||||
|
- Verify JWT_SECRET
|
||||||
|
- Check token expiration
|
||||||
|
- Review auth logs
|
||||||
@@ -1,15 +1,24 @@
|
|||||||
FROM node:18-alpine
|
# Multi-stage build for production
|
||||||
|
FROM node:18-alpine AS base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
|
# Development stage
|
||||||
|
FROM base AS dev
|
||||||
COPY . .
|
COPY . .
|
||||||
|
ENV HOST=0.0.0.0 PORT=12000
|
||||||
ENV HOST=0.0.0.0 \
|
|
||||||
PORT=12000
|
|
||||||
|
|
||||||
EXPOSE 12000
|
EXPOSE 12000
|
||||||
|
|
||||||
CMD ["npm", "start"]
|
CMD ["npm", "start"]
|
||||||
|
|
||||||
|
# Production build stage
|
||||||
|
FROM base AS build
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Production serve stage
|
||||||
|
FROM nginx:alpine AS prod
|
||||||
|
COPY --from=build /app/build /usr/share/nginx/html
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
EXPOSE 80
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
|
|||||||
39
frontend/nginx.conf
Normal file
39
frontend/nginx.conf
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
# Gzip compression
|
||||||
|
gzip on;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_min_length 1024;
|
||||||
|
gzip_proxied expired no-cache no-store private auth;
|
||||||
|
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;
|
||||||
|
|
||||||
|
# Security headers
|
||||||
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||||
|
add_header X-Content-Type-Options "nosniff" always;
|
||||||
|
add_header X-XSS-Protection "1; mode=block" always;
|
||||||
|
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||||
|
|
||||||
|
# Cache static assets
|
||||||
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||||
|
expires 1y;
|
||||||
|
add_header Cache-Control "public, immutable";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Handle React Router
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
# API proxy (if needed)
|
||||||
|
location /api/ {
|
||||||
|
proxy_pass http://merchantsofhope-supplyanddemandportal-backend:3001;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
6
frontend/postcss.config.js
Normal file
6
frontend/postcss.config.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
module.exports = {
|
||||||
|
plugins: {
|
||||||
|
tailwindcss: {},
|
||||||
|
autoprefixer: {},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -19,7 +19,7 @@ const Dashboard = () => {
|
|||||||
const [jobsRes, applicationsRes, candidatesRes, employersRes] = await Promise.all([
|
const [jobsRes, applicationsRes, candidatesRes, employersRes] = await Promise.all([
|
||||||
axios.get('/api/jobs?limit=1'),
|
axios.get('/api/jobs?limit=1'),
|
||||||
axios.get('/api/applications?limit=1'),
|
axios.get('/api/applications?limit=1'),
|
||||||
user?.role === 'candidate' ? Promise.resolve({ data: { applications: { pagination: { total: 0 } } } }) : axios.get('/api/applications?limit=1'),
|
user?.role === 'candidate' ? Promise.resolve({ data: { pagination: { total: 0 } } }) : axios.get('/api/candidates?limit=1'),
|
||||||
user?.role === 'employer' || user?.role === 'admin' || user?.role === 'recruiter' ? axios.get('/api/employers?limit=1') : Promise.resolve({ data: [] })
|
user?.role === 'employer' || user?.role === 'admin' || user?.role === 'recruiter' ? axios.get('/api/employers?limit=1') : Promise.resolve({ data: [] })
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -3,14 +3,18 @@ import { useQuery } from 'react-query';
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { Upload, Download, Trash2, Star, FileText } from 'lucide-react';
|
import { Upload, Download, Trash2, Star, FileText } from 'lucide-react';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
|
import { useAuth } from '../contexts/AuthContext';
|
||||||
|
|
||||||
const Resumes = () => {
|
const Resumes = () => {
|
||||||
|
const { user } = useAuth();
|
||||||
const [uploading, setUploading] = useState(false);
|
const [uploading, setUploading] = useState(false);
|
||||||
const [selectedFile, setSelectedFile] = useState(null);
|
const [selectedFile, setSelectedFile] = useState(null);
|
||||||
|
|
||||||
const { data: resumes, isLoading, refetch } = useQuery('resumes', async () => {
|
const { data: resumes, isLoading, refetch } = useQuery('resumes', async () => {
|
||||||
// This would need to be implemented based on the candidate's ID
|
if (user?.role === 'candidate' && user?.id) {
|
||||||
// For now, return empty array
|
const response = await axios.get(`/api/resumes/candidate/${user.id}`);
|
||||||
|
return response.data.resumes || [];
|
||||||
|
}
|
||||||
return [];
|
return [];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user