- Project Overview
- Dependencies
- Project Structure
- API Standards
- Authentication & Authorization
- File Handling and Storage
- Error Handling and Logging
- Testing
- Version Control
- Deployment Conventions
- Naming, Git & Development Workflow
This is a server-side application built with Node.js and Express. It provides a backend service for a client-side application, with features like authentication, file storage with AWS S3, email notifications, and payment integration via Stripe.
Key dependencies for this project include:
- @aws-sdk/client-s3: Handles AWS S3 interactions for file storage.
- bcryptjs: Password hashing.
- body-parser: Parses request bodies.
- cookie-parser: Parses cookies for session management.
- cors: Enables Cross-Origin Resource Sharing.
- dotenv: Manages environment variables.
- express: Server framework.
- jsonwebtoken: Manages JSON web tokens for authentication.
- mysql2: MySQL database driver.
- nodemailer: Sends emails.
- sequelize: ORM for managing database interactions.
- stripe: Processes payments.
- validator: Validates and sanitizes input data.
Refer to package.json
for a complete list of dependencies and their versions.
- index.js: Server entry point.
- /config: Environment variables and database configuration.
- /controllers: Business logic for each route.
- /middlewares: Custom middleware (e.g., authentication).
- /models: Sequelize models for database entities.
- /routes: API endpoints.
- /services: Service layer for third-party API integrations.
- /utils: Helper functions (e.g., error handling, file utilities).
- /logs: Stores server logs.
- Use REST principles for structuring endpoints.
- HTTP Status Codes:
- 200 OK for successful operations.
- 201 Created for successful resource creation.
- 400 Bad Request for validation errors.
- 401 Unauthorized for authentication issues.
- 500 Internal Server Error for unhandled exceptions.
- JWT is used for session management.
- bcryptjs hashes passwords before storing them in the database.
- Role-based access control (RBAC) manages permissions:
- Admin: Full access.
- User: Limited access based on permissions.
- AWS S3 is used for storing files.
- Multer: Handles file uploads.
- Sharp: Optimizes and resizes images before uploading to S3.
- Morgan logs HTTP requests.
- Custom error-handling middleware sends JSON error responses to the client.
- html-to-text: Converts HTML to text for logging purposes.
- Jest and Supertest are recommended for unit and integration tests.
- Testing strategy:
- Unit tests for services and utilities.
- Integration tests for controllers and routes.
- Feature-Branch workflow:
- main: Stable release.
- develop: Ongoing development.
- Branch naming convention:
feature/<feature-name>
,bugfix/<bug-name>
,hotfix/<hotfix-name>
.
- Platform: Deployed on an AWS EC2 instance with Docker for containerization.
- Nginx serves as a reverse proxy to handle traffic.
- Steps:
- Set Up EC2:
- Create and configure an EC2 instance.
- SSH into the instance.
ssh -i your-key.pem ubuntu@your-ec2-instance-ip
- Environment Configuration:
- Use
.env
for sensitive information.
- Use
- Docker:
- Use Docker to containerize the app.
docker build -t your-app-name . docker run -d -p 80:80 your-app-name
- Set Up EC2:
- Use
camelCase
for variables and functions. - Use
PascalCase
for classes and model names. - Use
snake_case
for database tables and columns.
- Branching Workflow:
- Follow a consistent branching model.
- Use branches for each new feature or bug fix.
- Branch names should reflect the task (e.g.,
feature/add-auth
).
- GitHub Actions for automated CI/CD pipeline.
- Automated tests and linting before merge.
💡 Note: Ensure commit messages are concise and clear.
For further details and configuration options, refer to additional documentation within each module directory.