A comprehensive Smart Campus Management System backend built with modern Spring Boot architecture, providing enterprise-grade RESTful APIs for managing academic institutions' complete operations. This system demonstrates advanced Java programming concepts, Spring Boot best practices, design patterns, and production-ready deployment strategies.
SmartCampus follows a modern layered architecture with clear separation of concerns:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Presentation Layer β
β (REST Controllers + OpenAPI Documentation) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Service Layer β
β (Business Logic + Transaction Management + Caching) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Repository Layer β
β (Data Access + JPA Repositories + Queries) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Domain Layer β
β (JPA Entities + Domain Models) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Infrastructure Layer β
β (Database + Cache + External APIs + File System) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Student Lifecycle Management: Complete student management from admission to graduation
- Course Management: Course creation, scheduling, prerequisite handling, and capacity management
- Enrollment System: Automated enrollment with real-time availability and waitlist management
- Grading System: Flexible grading schemes, assignment tracking, and GPA calculation
- Department Management: Academic department organization and faculty assignment
- Multi-Role Authentication: JWT-based authentication with role-based access control (Students, Faculty, Admin)
- Audit Trail: Complete audit logging for compliance and security monitoring
- Caching Strategy: Multi-level caching with in-memory and distributed cache
- Concurrent Processing: Async operations for bulk enrollment and notifications
- Event-Driven Architecture: Domain events for loose coupling and scalability
- File Management: Document upload, storage, and retrieval system
- RESTful API Design: Well-documented APIs with OpenAPI/Swagger
- Security Framework: Comprehensive security with input validation and SQL injection prevention
- Performance Optimization: Database query optimization and connection pooling
- Testing Suite: Unit, integration, and functional testing with high coverage
- Containerization: Docker support with multi-environment configurations
- Modern Java Features: Records, sealed classes, pattern matching, and functional programming
Core Framework
- Spring Boot 3.2.x: Enterprise application framework
- Spring Security: Authentication and authorization
- Spring Data JPA: Data access with Hibernate ORM
- Spring Cache: Caching abstraction with Redis integration
Database & Persistence
- PostgreSQL: Primary relational database
- Redis: High-performance caching and session storage
- Flyway: Database migration and versioning
Documentation & Testing
- OpenAPI 3/Swagger: Interactive API documentation
- JUnit 5: Modern testing framework
- TestContainers: Integration testing with real database instances
- Mockito: Mocking framework for unit tests
Build & Deployment
- Maven: Dependency management and build automation
- Docker: Containerization with multi-stage builds
- GitHub Actions: CI/CD pipeline automation
- Java 17+ (OpenJDK or Oracle JDK)
- Apache Maven 3.8+
- PostgreSQL 13+ (or Docker for containerized setup)
- Git for version control
Optional but Recommended
- Redis 6.0+ for caching
- Docker & Docker Compose for easy setup
- IDE with Spring Boot support (IntelliJ IDEA, Eclipse STS, VS Code)
# Clone the repository
git clone https://github.com/SatvikPraveen/SmartCampus.git
cd SmartCampus
# Start all services with Docker Compose
docker-compose up -d
# Verify services are running
docker-compose ps
# View application logs
docker-compose logs -f smartcampus-backendAvailable Services:
- API Server: http://localhost:8080
- API Documentation: http://localhost:8080/swagger-ui.html
- Database: localhost:5432
- Redis Cache: localhost:6379
1. Database Setup
# Create PostgreSQL database
createdb smartcampus
# Or using Docker for database only
docker run --name smartcampus-db \
-e POSTGRES_DB=smartcampus \
-e POSTGRES_USER=smartcampus \
-e POSTGRES_PASSWORD=smartcampus123 \
-p 5432:5432 -d postgres:152. Application Build and Run
# Install dependencies and build
mvn clean install
# Run with development profile
mvn spring-boot:run -Dspring.profiles.active=dev
# Alternative: Run as JAR
java -jar target/smartcampus-backend.jar --spring.profiles.active=dev3. Verification
# Check application health
curl http://localhost:8080/actuator/health
# View API documentation
open http://localhost:8080/swagger-ui.htmlsrc/
βββ main/
β βββ java/
β β βββ annotations/ # Custom annotations (@Entity, @Audited, @Cacheable)
β β βββ app/ # Main application class
β β βββ cache/ # Caching strategies and LRU implementation
β β βββ com/smartcampus/ # Main application package
β β βββ concurrent/ # Async processing and concurrent operations
β β βββ enums/ # System enumerations (roles, status, etc.)
β β βββ events/ # Event-driven architecture implementation
β β βββ exceptions/ # Custom exception hierarchy
β β βββ functional/ # Functional programming utilities
β β βββ interfaces/ # Core system interfaces
β β βββ io/ # File I/O and external system integration
β β βββ models/ # JPA entities and domain models
β β βββ patterns/ # Design pattern implementations
β β βββ reflection/ # Reflection-based utilities
β β βββ repositories/ # Data access layer
β β βββ security/ # Security implementation
β β βββ services/ # Business logic layer
β β βββ utils/ # Utility classes and helpers
β βββ resources/
β βββ application.yml # Main configuration
β βββ config/ # External configurations
β βββ data/ # Sample data files (CSV)
β βββ sql/ # Database scripts and migrations
β βββ templates/ # Email and report templates
βββ test/
βββ java/
β βββ functional/ # End-to-end tests
β βββ integration/ # Integration tests
β βββ unit/ # Unit tests
βββ resources/
βββ fixtures/ # Test fixtures and mock data
βββ test-data/ # Test-specific data files
- JWT Token-based Authentication: Stateless authentication with refresh tokens
- Role-Based Access Control (RBAC): Multi-level authorization (STUDENT, FACULTY, ADMIN)
- Method-Level Security: Fine-grained access control with
@PreAuthorizeand@PostAuthorize - Password Security: BCrypt hashing with configurable strength
- Input Validation: Comprehensive validation using Bean Validation API
- SQL Injection Prevention: Parameterized queries and JPA protection
- XSS Protection: Input sanitization and output encoding
- CORS Configuration: Configurable cross-origin resource sharing
- Audit Trail: Automatic auditing of all entity changes
- Security Event Logging: Authentication attempts, access violations, and security events
- Data Retention: Configurable data retention policies
- Multi-Level Caching: L1 (Caffeine) + L2 (Redis) caching
- Cache Abstraction: Spring Cache with configurable TTL and eviction policies
- Query Result Caching: Database query result caching for improved performance
- Connection Pooling: HikariCP for high-performance connection management
- Query Optimization: Optimized JPA queries with fetch strategies
- Database Migrations: Versioned database schema management with Flyway
- Concurrent Operations: Async processing for bulk operations and notifications
- Thread Pool Management: Configurable thread pools for different operation types
- Batch Processing: Efficient bulk data processing capabilities
- Actuator Endpoints: Comprehensive health monitoring endpoints
- Custom Health Indicators: Database, cache, and external service health checks
- Readiness and Liveness Probes: Kubernetes-ready health probes
- Application Metrics: Performance metrics with Micrometer
- Structured Logging: JSON-formatted logs for production environments
- Audit Logging: Complete audit trail for compliance requirements
- Unit Tests: Service and utility class testing with Mockito
- Integration Tests: Repository and API endpoint testing with TestContainers
- Functional Tests: End-to-end workflow testing
- Performance Tests: Load testing and concurrent operation testing
# Run all tests
mvn clean test
# Run specific test categories
mvn test -Dtest="*Test" # Unit tests
mvn test -Dtest="*IT,*Integration*" # Integration tests
mvn test -Dtest="*Functional*" # Functional tests
# Generate coverage report
mvn test jacoco:report- Development (
dev): H2 database, debug logging, hot reload - Test (
test): TestContainers, isolated test database - Production (
prod): PostgreSQL, optimized settings, security hardening
# Database Configuration
export DB_HOST=localhost
export DB_PORT=5432
export DB_NAME=smartcampus
export DB_USERNAME=smartcampus
export DB_PASSWORD=your_password
# Security Configuration
export JWT_SECRET=your-jwt-secret-key
export JWT_EXPIRATION=86400000
# Cache Configuration
export REDIS_HOST=localhost
export REDIS_PORT=6379Authentication
POST /api/auth/login # User authentication
POST /api/auth/refresh # Token refresh
POST /api/auth/logout # User logoutUser Management
GET /api/users # List users (paginated)
GET /api/users/{id} # Get user by ID
POST /api/users # Create new user
PUT /api/users/{id} # Update user
DELETE /api/users/{id} # Delete userAcademic Management
GET /api/students # List students
POST /api/students # Create student
GET /api/courses # List courses
POST /api/courses # Create course
POST /api/enrollments # Enroll student
GET /api/grades # Get grades
POST /api/grades # Submit gradeAccess the Swagger UI at: http://localhost:8080/swagger-ui.html
# Start development environment
docker-compose -f docker-compose.dev.yml up -d
# View logs
docker-compose logs -f smartcampus-backend# Build production image
docker build -t smartcampus/backend:latest .
# Deploy production environment
docker-compose -f docker-compose.yml up -d
# Scale application
docker-compose up --scale smartcampus-backend=3- Builder Pattern: Complex object construction (CourseBuilder, StudentBuilder)
- Factory Pattern: Service instantiation (ServiceFactory, UniversityFactory)
- Singleton Pattern: Configuration management (DatabaseConnection)
- Repository Pattern: Data access abstraction
- Adapter Pattern: External service integration (AdapterService)
- Facade Pattern: Service layer abstraction
- Observer Pattern: Event-driven architecture (EventManager)
- Strategy Pattern: Caching strategies and algorithms
- Command Pattern: Operation encapsulation (CommandProcessor)
- Template Method Pattern: Common processing workflows
- Follow Java naming conventions
- Use meaningful variable and method names
- Implement proper error handling
- Write comprehensive JavaDoc for public APIs
- Maintain consistent code formatting
- Minimum 85% code coverage
- Unit tests for all service methods
- Integration tests for API endpoints
- Functional tests for critical workflows
# Create feature branch
git checkout -b feature/your-feature-name
# Make changes and commit
git add .
git commit -m "feat: add new feature description"
# Push and create pull request
git push origin feature/your-feature-nameWe welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
- All contributions require code review
- Automated CI/CD pipeline validation
- Manual testing verification
- Documentation updates when needed
- Application Startup: < 45 seconds
- Average Response Time: < 150ms (95th percentile < 500ms)
- Throughput: 2,000+ requests/second
- Memory Usage: 512MB baseline, 1.5GB under load
- Database Connection Pool: 50 connections, 60% average utilization
- GraphQL API implementation
- Real-time notifications with WebSocket
- Advanced search with Elasticsearch
- Mobile API optimizations
- Enhanced bulk operations
- Machine Learning integration for recommendations
- Advanced analytics and reporting
- Multi-tenant support
- Microservices architecture migration
- OAuth2 integration
Application won't start
# Check port availability
lsof -i :8080
# Check database connection
pg_isready -h localhost -p 5432
# View detailed logs
mvn spring-boot:run -XDatabase connection issues
# Test database connectivity
psql -h localhost -U smartcampus -d smartcampus
# Check Docker database status
docker-compose ps postgresMemory issues
# Increase JVM memory
export JAVA_OPTS="-Xms1g -Xmx2g"
mvn spring-boot:run- Issues: GitHub Issues
- Discussions: GitHub Discussions
This project is licensed under the MIT License - see the LICENSE file for details.
- Spring Framework team for the comprehensive ecosystem
- PostgreSQL community for the robust database system
- Open source community for the incredible tools and libraries
- All contributors and users of this project
Built with β€οΈ using modern Java technologies and Spring Boot best practices.
For more information, visit: https://github.com/SatvikPraveen/SmartCampus