Enterprise-grade REST API for NexaSphere community platform with real-time data synchronization
Spring Boot 3 backend service providing:
- ✓ Event management (CRUD operations)
- ✓ Core team member management
- ✓ User form submission handling
- ✓ Admin authentication & authorization
- ✓ Real-time data synchronization
| Specification | Details |
|---|---|
| Runtime | Java 17+ |
| Framework | Spring Boot 3 |
| Build Tool | Maven 3.8+ |
| Default Database | H2 (development) |
| Production Database | PostgreSQL |
| Port | 8080 |
Before starting, ensure you have:
| Tool | Version | Download |
|---|---|---|
| Java JDK | 17+ | https://www.oracle.com/java/technologies/ |
| Maven | 3.8+ | https://maven.apache.org/download.cgi |
| PostgreSQL | Latest | https://www.postgresql.org/download/ |
cd server-java
mvn clean installWhat this does:
- Downloads all dependencies
- Compiles source code
- Runs unit tests
- Creates executable JAR
Using H2 (in-memory database):
mvn spring-boot:run✅ Server Running on: http://localhost:8080
Setup PostgreSQL:
# Export environment variables
export DB_URL=jdbc:postgresql://localhost:5432/nexasphere
export DB_DRIVER=org.postgresql.Driver
export DB_USER=postgres
export DB_PASS=yourpassword
# Run the server
mvn spring-boot:run| Variable | Example | Purpose |
|---|---|---|
| ADMIN_EMAIL | [email protected] | Admin login email |
| ADMIN_PASSWORD | your-secure-password | Admin login password |
| CORS_ORIGIN | http://localhost:5173 | Allowed frontend origins |
| Variable | Dev Value | Prod Value |
|---|---|---|
| DB_URL | jdbc:h2:mem:nexaspheredb | jdbc:postgresql://host:5432/nexasphere |
| DB_DRIVER | org.h2.Driver | org.postgresql.Driver |
| DB_USER | sa | postgres |
| DB_PASS | (empty) | your-password |
Create src/main/resources/application.properties:
# ========== Server Configuration ==========
server.port=8080
spring.profiles.active=dev
# ========== Database (H2 - Development) ==========
spring.datasource.url=jdbc:h2:mem:nexaspheredb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
# ========== Database (PostgreSQL - Production) ==========
# Uncomment for production
# spring.datasource.url=jdbc:postgresql://localhost:5432/nexasphere
# spring.datasource.driverClassName=org.postgresql.Driver
# spring.datasource.username=postgres
# spring.datasource.password=yourpassword
# ========== JPA/Hibernate Configuration ==========
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.show-sql=false
spring.jpa.properties.hibernate.format_sql=true
# ========== Admin Credentials — set via environment variables only, never commit real values ==========
app.admin.email[email protected]
app.admin.password=your-secure-password
# ========== CORS Configuration ==========
app.cors.origin=http://localhost:5173,https://nexasphere-glbajaj.vercel.app
# ========== Logging ==========
logging.level.root=INFO
logging.level.org.nexasphere=DEBUG
logging.level.org.springframework.web=DEBUGserver-java/
│
├── src/
│ ├── main/
│ │ ├── java/org/nexasphere/
│ │ │ ├── NexaSphereApplication.java ← Spring Boot Entry Point
│ │ │ ├── controller/ ← REST Endpoints
│ │ │ ├── service/ ← Business Logic
│ │ │ ├── model/ ← JPA Entities
│ │ │ ├── repository/ ← Data Access Layer
│ │ │ ├── config/ ← Spring Configuration
│ │ │ ├── exception/ ← Custom Exceptions
│ │ │ └── util/ ← Utility Classes
│ │ └── resources/
│ │ ├── application.properties ← Configuration
│ │ └── data.sql ← Seed Data
│ └── test/
│ └── java/org/nexasphere/
│ └── NexaSphereApplicationTests.java
│
├── pom.xml ← Maven Dependencies
├── mvnw & mvnw.cmd ← Maven Wrapper
└── README.md
mvn testmvn clean test jacoco:report📊 View Coverage: target/site/jacoco/index.html
mvn verify
|
|
|
|
GET /api/content/events
GET /api/content/events/{id}
GET /api/content/activity-events/{activityKey}
GET /api/content/core-team
GET /api/content/core-team/{id}
POST /api/forms/membership
POST /api/forms/recruitment
POST /api/core-team/apply
POST /api/admin/events
PUT /api/admin/events/{id}
DELETE /api/admin/events/{id}
POST /api/admin/core-team
PUT /api/admin/core-team/{id}
DELETE /api/admin/core-team/{id}
POST /api/admin/login
POST /api/admin/logout
NexaSphere includes interactive API documentation powered by OpenAPI 3 (Swagger UI). Once the server is running, you can access the documentation using the following URLs:
- Swagger UI: http://localhost:8080/swagger-ui.html
- OpenAPI 3 JSON Data: http://localhost:8080/v3/api-docs
To test secure admin endpoints directly from Swagger UI, click the Authorize button and input your Bearer JWT token obtained from /api/admin/login.
curl -X POST http://localhost:8080/api/admin/login \
-H "Content-Type: application/json" \
-d '{
"email":"<ADMIN_EMAIL>",
"password":"<ADMIN_PASSWORD>"
}'{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiresIn": 3600
}curl -H "Authorization: Bearer YOUR_JWT_TOKEN" \
http://localhost:8080/api/admin/eventsAutomatic Setup:
- ✓ Creates in-memory database on startup
- ✓ Creates tables from JPA entities
- ✓ Loads seed data from
data.sql - ✓ No manual configuration needed
Step 1: Create Database
createdb nexasphereStep 2: Configure Connection
Update application.properties with PostgreSQL credentials
Step 3: Initialize
Spring Boot auto-creates tables on startup via JPA
1. Install Railway CLI
npm i -g @railway/cli2. Login & Deploy
railway login
cd server-java
railway init
railway up3. Set Environment Variables
In Railway Dashboard, add:
[email protected]
ADMIN_PASSWORD=your-secure-password
CORS_ORIGIN=https://nexasphere-glbajaj.vercel.app
DB_URL=jdbc:postgresql://[rail-host]:5432/railway
DB_DRIVER=org.postgresql.Driver
DB_USER=postgres
DB_PASS=[from-dashboard]
❌ Maven command not found
# Solution: Add Maven to PATH
# Or use Maven wrapper
./mvnw clean install❌ Java 17 not found
# Solution: Download Java 17+
# Verify: java -version❌ Connection refused on port 8080
# Solution: Port already in use
# Change port in application.properties
server.port=9090❌ Database connection failed
# Solution: Verify PostgreSQL is running
# Check credentials in application.propertiesQuestions? 📧 Contact [email protected]
Backend Version: 1.0 | Last Updated: May 2026