Backend & Infrastructure
This page covers the core parts of the backend whicih works with Spring Boot.
Consider taking a proper look at the SpringBoot's documentation. It is not hard, most of the backend code are basic spring boot elements and concepts
https://docs.spring.io/spring-boot/index.html
1. Technical Core
- Language/Framework: Java 21 (Eclipse Temurin) using Spring Boot 3.4.0.
- Build System: Gradle. The project is built inside the container using
./gradlew build. - API Port: The backend runs internally on port
8081.
2. The Bootstrap Logic (Admin Seeder)
We have a custom safety mechanism called AdminUserSeeder.java.
- The Purpose: If the database is fresh (0 users), the app will automatically create a "Super User."
- Requirement: You must provide
ADMIN_USERandADMIN_PASSenvironment variables in your.envfile for the first startup. - Behavior: If an admin already exists in the
admin_userstable, this seeder does nothing.
3. Security & Session Management
We use a hybrid security model to ensure the team can always access the dashboard.
- Google OAuth 2.0: Primary login for team members. Emails must be whitelisted in the Google Cloud Console.
- Spring Session (JDBC): Unlike standard apps, we store sessions in the PostgreSQL database (table:
SPRING_SESSION).- Benefit: If the backend container restarts or updates, users are not logged out.
- Cookie Policy:
SameSite=LaxandHttpOnlyare enabled.- Note: In full production with HTTPS,
server.servlet.session.cookie.secureshould be set totrue.
- Note: In full production with HTTPS,
4. Database & Persistence
We use PostgreSQL 15 as our source of truth.
- JPA/Hibernate: Configured with
ddl-auto: update. This automatically creates tables based on Java Entities. - File Uploads: News images and team photos are stored in
/app/uploads. - Volumes: To ensure data isn't lost when containers stop, we use two named volumes:
postgres_data: For all SQL records.uploads_data: For all physical images.
No comments to display
No comments to display