How bui-danh-tung-bengo4/file-uploader works
Main Components
• Frontend Application:
• Built with Vue (as evident from the “frontend” directory files like App.vue, main.ts, router, components, etc.)
• Handles user interactions for registration, login, file uploads, file lists, search, etc.
• Communicates with backend APIs (using services like FileApiService.ts and UserApiService.ts).
• Backend Application:
• Implemented in Go (files such as main.go, various controllers, services, usecases).
• Divided into functional areas:
• Authentication (under backend/controller/auth and corresponding usecases for login and registration)
• File Management (controllers for file operations, file usecases, repository for file data in MySQL or MinIO storage)
• Notification/SSE (backend/controller/sse and backend/sse directory that manage server-sent events)
• Logging & Error Handling (backend/controller/error and utils for logging request info)
• Architectural layering patterns are visible (controllers → usecases → repositories/infra)
• Database & Storage Components:
• The backend/containers include a directory for database initialization scripts (DDL and test data) suggesting an underlying MySQL database.
• Cloud storage integration is handled via AWS (aws/s3.go and aws/ses.go in infra) and a MinIO implementation is available (in backend/infra/storage/minio). Also, a phpMyAdmin container is provided for easy database viewing.
• External & Containerized Services:
• Docker Compose is used (docker-compose.yml) to manage the multi-container environment.
• GitHub workflows exist to run CI/CD processes.
• Containers include a database server and phpMyAdmin for management.
Relationships and Interactions
• The frontend sends HTTP API requests (likely RESTful calls) to the backend.
• The backend controllers act as the entry point for different business operations (authentication, file uploads, file listing, and search).
• Controllers delegate logic to “usecase” packages where business rules are implemented.
• Repositories in the “infra” package (for MySQL and cloud storage like AWS/MinIO) are used by usecases to load or persist model data.
• When a file is uploaded, the backend may interact with cloud storage (e.g., AWS S3 or a MinIO server) as well as with the MySQL database to update file metadata.
• Components such as SSE controllers indicate that real-time notifications or logs may be streamed to the frontend.
Architectural Patterns and Principles
• Separation of concerns: The clear division between controllers, use cases, and infra packages shows adherence to layered architecture.
• RESTful API design: The endpoints (as seen in routes.json) are likely designed following RESTful principles.
• Containerization: Docker Compose helps in orchestrating multiple services (database, phpMyAdmin, Go backend, and possibly the frontend if containerized).
Relevant Technologies/Frameworks/Libraries
• Frontend: Vue.js, Vite, TypeScript (indicated by .ts and .d.ts files), and Vue Router.
• Backend: Go (with controllers, models, usecases, and repositories), likely using popular libraries for routing and sessions (e.g., Gorilla sessions as seen in mocks), and AWS SDKs for cloud storage operations.
• Database: MySQL (with initialization scripts provided).
• Storage: MinIO for S3 compatible storage and direct AWS integrations.
• CI/CD: GitHub Actions as seen in the .github/workflows/cicd.yml.