A complete full-stack starter template combining a Flutter mobile application with a Spring Boot REST API backend, featuring secure JWT authentication, clean architecture, and production-ready project structure.
This starter project provides a professional foundation for building modern applications with:
- Frontend: Flutter mobile app with onboarding, authentication, and user management
- Backend: Spring Boot REST API with JWT-based security and token refresh mechanism
- Database: PostgreSQL with Docker Compose setup
- β User registration with email validation
- β Login with email & password
- β JWT access tokens with configurable expiry
- β Refresh tokens for automatic token renewal
- β Global exception handling
- β Validation
- β Swagger/OpenAPI documentation
- β Docker Compose setup for PostgreSQL
- β Spring Security configuration
- β Complete onboarding flow with interactive screens
- β Secure user authentication (registration & login)
- β JWT token management with automatic refresh
- β Secure token storage using Flutter Secure Storage
- β Home dashboard and profile screens
- β State management with Riverpod
- β Declarative routing with GoRouter
- β Robust HTTP client with Dio and interceptors
- β Logging and error handling
- Framework: Spring Boot 4.x
- Language: Java 21+
- Build Tool: Maven 3.9+
- Database: PostgreSQL
- Security: Spring Security + JWT
- API Docs: Swagger/OpenAPI
- Containerization: Docker & Docker Compose
- Framework: Flutter 3.10.4+
- Language: Dart 3.10.4+
- State Management: Riverpod
- HTTP Client: Dio
- Routing: GoRouter
- Secure Storage: Flutter Secure Storage
- Local Storage: SharedPreferences
flutter-springboot-starter/
βββ backend/ # Spring Boot REST API
β βββ src/
β β βββ main/
β β β βββ java/com/naarith/fsp/
β β β β βββ common/ # Shared components
β β β β βββ user/ # User management
β β β β βββ auth/ # Authentication & JWT
β β β βββ resources/ # Configuration files
β β βββ test/
β βββ docker-compose.yml # PostgreSQL setup
β βββ pom.xml # Maven configuration
β βββ README.md # Backend documentation
β
βββ mobile/ # Flutter mobile application
β βββ lib/
β β βββ main.dart # App entry point
β β βββ app.dart # Main app widget
β β βββ core/ # Shared utilities & configuration
β β β βββ routing/ # GoRouter setup
β β β βββ network/ # HTTP client & interceptors
β β β βββ storage/ # Secure & local storage
β β β βββ constants/ # App constants
β β β βββ widgets/ # Reusable widgets
β β βββ features/ # Feature modules
β β βββ auth/ # Authentication
β β βββ onboarding/ # Onboarding flow
β β βββ home/ # Home dashboard
β β βββ profile/ # User profile
β βββ pubspec.yaml # Flutter dependencies
β βββ android/ # Android native code
β βββ ios/ # iOS native code
β βββ README.md # Mobile documentation
β
βββ README.md # This file
- Git
- Java 21 or higher
- Maven 3.9 or higher
- Docker & Docker Compose
- Flutter SDK (^3.10.4)
- Dart SDK (^3.10.4)
-
Start PostgreSQL Database
cd backend docker-compose up -dPostgreSQL will be accessible at
localhost:5432. Update credentials insrc/main/resources/application.yamlif needed. -
Build the Project
./mvnw clean package
-
Run the Application
./mvnw spring-boot:run
The server listens on
http://localhost:8222by default. -
Access Swagger Documentation
http://localhost:8222/swagger-ui/index.html
-
Get Dependencies
cd mobile flutter pub get -
Run the App
flutter run
-
Build for Production
flutter build apk # Android flutter build ios # iOS flutter build web # Web
-
Register:
POST /api/v1/auth/register- Body:
{ email, password }
- Body:
-
Login:
POST /api/v1/auth/login- Body:
{ email, password } - Response:
{ email, accessToken }
- Body:
-
Refresh Token:
GET /api/v1/auth/refresh- Header cookie:
{ refresh_token } - Response:
{ email, accessToken }
- Header cookie:
All authenticated endpoints require:
Authorization: Bearer <accessToken>
- User registers or logs in via mobile app
- Backend validates credentials and returns JWT tokens (access + refresh)
- Mobile app stores tokens securely
- For API requests, mobile app includes access token in
Authorizationheader - If access token expires, mobile app automatically uses refresh token to get a new one
- Auth interceptor handles token refresh transparently
- REST API: Spring Boot with Spring Security
- Database: PostgreSQL with JPA/Hibernate
- Exception Handling: Global exception handler with custom error responses
- Security: JWT-based stateless authentication
- Presentation Layer: Riverpod notifiers + Flutter widgets
- Data Layer: Repositories for API calls and local storage
- Core Layer: Network client, routing, storage, and shared utilities
- Clean Architecture: Clear separation of concerns
- Backend README - Detailed backend documentation
- Mobile README - Detailed mobile documentation
Edit backend/src/main/resources/application.yaml:
- Server port
- Database credentials
- JWT expiration times
- Logging levels
Edit mobile/lib/core/constants/ and mobile/pubspec.yaml:
- API base URL
- Route constants
- Storage keys
- Tokens automatically refresh without user intervention
- All sensitive data (tokens) stored securely on mobile
- Both platforms follow industry best practices for security
- Database and API are containerized for easy deployment
- Configure database credentials for your environment
- Update API endpoints in mobile app configuration
- Customize authentication flows as needed
- Add your business logic features
- Deploy to production
Happy coding! π