Overview
SociApp is a full-stack web application built with modern web technologies, designed for managing social organization activities, members, and projects. The application follows a client-server architecture with clear separation of concerns.Technology Stack
Frontend
- Framework: Vue.js 3.5.27 with Composition API
- State Management: Pinia 3.0.4
- Routing: Vue Router 5.0.2
- Styling: Tailwind CSS 4.1.18
- Build Tool: Vite 7.3.1
- HTTP Client: Axios 1.13.5
- Charts: Chart.js 4.5.1 with Vue-ChartJS 5.3.3
- PDF Handling: pdfjs-dist 5.4.624
Backend
- Framework: NestJS 11.0.1
- Runtime: Node.js (^20.19.0 || >=22.12.0)
- Database ORM: TypeORM 0.3.28
- Database: MySQL 3.16.3
- Authentication: JWT with Passport (passport-jwt 4.0.1)
- Password Hashing: bcrypt 6.0.0
- Email: Nodemailer 8.0.1 with @nestjs-modules/mailer 1.8.1
- File Upload: Multer 2.0.0
- Rate Limiting: @nestjs/throttler 6.5.0
- Caching: @nestjs/cache-manager 3.1.0
System Architecture Diagram
Frontend-Backend Communication
API Communication Pattern
- Base Configuration: Frontend uses Axios with a configured base URL
- Authentication: JWT tokens stored in localStorage and sent via Authorization header
- Credentials: CORS configured with
credentials: truefor cookie support - Request Flow:
- Client initiates request through Pinia store action
- Axios interceptor adds JWT token to headers
- Backend validates token through JwtAuthGuard
- RolesGuard checks user permissions
- Controller receives validated request
- Service processes business logic
- Repository handles database operations
- Response flows back through the chain
API Endpoints Structure
Authentication Flow
Registration & Verification Process
JWT Token Strategy
Login Flow
File Structure
Backend Structure
Frontend Structure
Technology Choices & Rationale
Why Vue.js 3?
- Composition API: Better code organization and reusability
- Performance: Virtual DOM with optimized reactivity system
- Developer Experience: Excellent TypeScript support, Vue DevTools
- Ecosystem: Rich ecosystem with Pinia, Vue Router, Vite
Why NestJS?
- TypeScript-first: Strong typing for better code quality
- Modular Architecture: Clean separation of concerns
- Built-in Features: Guards, interceptors, pipes, decorators
- Enterprise-ready: Scalable architecture for growing applications
- Dependency Injection: Easy testing and maintainability
Why TypeORM?
- TypeScript Support: Native TypeScript decorators
- Active Record & Data Mapper: Flexible patterns
- Migration Support: Version control for database schema
- Relationship Handling: Clean entity relationships
Why Pinia over Vuex?
- Simpler API: Less boilerplate, more intuitive
- TypeScript Support: Better type inference
- Composition API: Native support for Vue 3 patterns
- DevTools: Excellent debugging capabilities
- Modular: Each store is independent
Security Features
Backend Security
-
Password Security
- bcrypt hashing with 12 salt rounds
- Passwords never stored in plain text
-
Authentication
- JWT-based stateless authentication
- Separate access and refresh tokens
- Token expiration (15min access, 7 day refresh)
-
Authorization
- Role-based access control (RBAC)
- Route guards: JwtAuthGuard + RolesGuard
- Supported roles: ‘monitor’, ‘admin’
-
Input Validation
- Global ValidationPipe with whitelist: true
- Rejects unknown properties (forbidNonWhitelisted)
- DTO-based validation with class-validator
-
Rate Limiting
- Throttler: 10 requests per 60 seconds
- Prevents brute force attacks
-
CORS Protection
- Configurable allowed origins from env
- Credentials enabled for cookie support
- Specific methods and headers whitelisted
-
Email Verification
- 6-digit verification codes
- 15-minute expiration
- Auto-deletion of unverified accounts
Frontend Security
-
Token Storage
- Access tokens in localStorage
- Automatic injection into Axios headers
-
Route Protection
- Router beforeEach guards
- Authentication and role checks
- Automatic redirects for unauthorized access
-
State Management
- Centralized auth state
- Automatic token refresh handling
- Session persistence
Performance Optimizations
Frontend
- Code Splitting: Dynamic imports for routes
- Lazy Loading: Components loaded on demand
- Vite Build: Fast HMR and optimized production builds
- Component Transitions: Smooth UX with fade effects
Backend
- Caching: Cache Manager with 60s TTL, max 100 items
- Database Indexing: Primary keys and foreign keys
- Static File Serving: Efficient upload serving via ServeStaticModule
- Connection Pooling: MySQL connection pool management
Environment Configuration
Backend Environment Variables
Frontend Environment Variables
Deployment Considerations
- Database Migrations:
synchronize: falsein production - File Uploads: Persistent storage for
/uploads - CORS: Update FRONTEND_URL for production domain
- HTTPS: Enable SSL/TLS in production
- Environment Secrets: Use secure secret management
- Logging: Implement structured logging for monitoring
- Error Handling: Global exception filters
