How vck3000/proavalon works
Project Type and Purpose
ProAvalon is a full-stack Node.js Express application designed as an online platform for playing "The Resistance!" game. It facilitates real-time multiplayer interactions, user authentication, and integrates various external services to enhance functionality and user experience.
File Structure Analysis
• Top-Level Directories:
• assets: Contains frontend assets like avatars, game data, libraries (Bootstrap, jQuery UI, Summernote), images, scripts, stylesheets, and sounds.
• src: Holds the backend source code, organized into subdirectories such as clients, databaseAdapters, gameplay, metrics, models, modsadmins, myFunctions, rewards, routes, sockets, util, and views.
• .github: Contains GitHub Actions workflows for CI/CD.
• Key Patterns and Architectural Choices:
• MVC Pattern: Separation of concerns with models for data, views for frontend templates, and routes/controllers handling business logic.
• Microservices Elements: Presence of clients (e.g., Discord, Patreon, S3, VictoriaMetrics) suggesting modular interactions with external services.
• Real-Time Communication: sockets directory indicates extensive use of Socket.io for real-time features.
• Configuration and Deployment: Docker-related files (Dockerfile, docker-compose.yml) and Webpack configurations for building the frontend.
README Insights
• Technologies Used:
• Backend: Node.js, Express, Passport.js for authentication, Socket.io for real-time communication.
• Database: MongoDB managed via Docker.
• Object Storage: MinIO for handling file storage.
• Metrics and Monitoring: VictoriaMetrics and Grafana for monitoring and metrics visualization.
• CI/CD: GitHub Actions for automated builds and deployments.
• Deployment Workflow:
• Development and staging are managed via the master branch.
• Docker containers are built and pushed to DockerHub through GitHub Actions.
• Production deployment is handled on Digital Ocean.
• Additional Features:
• Server-wide caching for performance optimization.
• Middleware for authentication and other global functionalities.
• Comprehensive testing setup using Jest.
a. Main Components:
• Frontend:
• Assets: Static files including JavaScript, CSS, images, and sounds.
• Views: EJS templates rendering the user interface.
• Backend:
• Express Server (app.ts): Handles HTTP requests, serves APIs, and manages middleware.
• Authentication Module: Managed by Passport.js integrated with Socket.io via passport.socketio.
• Real-Time Communication: Socket.io server (sockets/sockets.ts) managing real-time events and interactions.
• Database:
• MongoDB: Managed through Mongoose (databaseAdapters/mongoose), handling data persistence.
• External Services:
• MinIO: Object storage for handling file uploads and storage.
• VictoriaMetrics: Metrics collection and monitoring.
• Discord & Patreon Clients: Integrations for community engagement and funding.
• CI/CD Pipeline:
• GitHub Actions: Automated workflows for building, testing, and deploying Docker containers.
• Deployment:
• Docker Containers: Encapsulate the application and its dependencies for consistent deployment across environments.
• Digital Ocean: Hosting platform for the production environment.
b. Relationships and Interactions:
• User Interaction Flow:
1. User Interface (Frontend) interacts with the Express Server (Backend) through HTTP requests for standard operations.
2. Real-Time Features are enabled via Socket.io, allowing bidirectional communication between the client and server.
• Backend to Services:
• Express Server communicates with MongoDB for data operations.
• MinIO handles file storage requests from the backend.
• External Clients (Discord, Patreon) interact with their respective APIs for integration features.
• Monitoring and Metrics:
• VictoriaMetrics collects data from the application, which is visualized using Grafana.
• CI/CD Workflow:
• GitHub Actions automates the building and testing of Docker containers, which are then deployed to Digital Ocean upon approval.
c. Architectural Patterns and Design Principles:
• Modularity: Clear separation of concerns with distinct modules for clients, database adapters, gameplay logic, and utilities.
• Scalability: Use of Docker for containerization allows the application to scale horizontally.
• Maintainability: Organized directory structure and adherence to MVC principles facilitate easier maintenance and feature additions.
• Security: User authentication managed by Passport.js, with middleware enforcing access controls.
d. Technologies, Frameworks, and Libraries:
• Backend: Node.js, Express, Socket.io, Passport.js, Mongoose, TypeScript.
• Frontend: EJS templating, Bootstrap, jQuery UI, Summernote.
• DevOps: Docker, Docker Compose, GitHub Actions.
• Testing: Jest.
• Monitoring: VictoriaMetrics, Grafana.
• Other Libraries: Various utility libraries for handling specific functionalities (e.g., captcha, VPN detection).
Elements
• Clear Labels: Each component (e.g., Frontend, Express Server, MongoDB, MinIO, Socket.io) should be distinctly labeled.
• Users interacting with the Frontend.
• Frontend making API calls to the Express Server.
• Express Server communicating with MongoDB and MinIO.
• Real-time events flowing through Socket.io between Frontend and Backend.
• External Services interacting with the Backend.
• CI/CD pipeline deploying to the Hosting Platform.