Prerequisites
Before you begin, ensure you have the following installed on your system:PostgreSQL
Version 12 or higher. Download from postgresql.org
Maven
Included with the project via Maven Wrapper (mvnw)
Git
For cloning the repository
The project includes Maven Wrapper (
mvnw), so you don’t need to install Maven separately. The wrapper script will download the correct Maven version automatically.Step 1: Clone the Repository
Start by cloning the Daily Tracker API repository:Step 2: Set Up PostgreSQL Database
Create a new PostgreSQL database for Daily Tracker:PostgreSQL
Step 3: Configure Environment Variables
Daily Tracker API requires several environment variables. Create them in your shell or use a.env file:
Required Variables
.env
Optional Variables
Optional
Environment Variable Details
| Variable | Description | Required | Default |
|---|---|---|---|
DATABASE_URL | PostgreSQL connection string. Supports both Prisma format and standard JDBC URLs | Yes | - |
JWT_SECRET | Secret key for signing JWT tokens. Must be at least 32 characters | Yes | - |
FRONTEND_URL | URL of your frontend application for CORS and OAuth redirects | Yes | http://localhost:5173 |
GOOGLE_CLIENT_ID | Google OAuth2 Client ID from Google Cloud Console | No* | - |
GOOGLE_CLIENT_SECRET | Google OAuth2 Client Secret from Google Cloud Console | No* | - |
AES_SECRET | AES encryption key for storing sensitive API keys (32 characters) | Yes | - |
PORT | Port number for the API server | No | 3000 |
*Google OAuth credentials are only required if you want to enable Google social login. The API will work without them using email/password authentication.
Step 4: Generate JWT Secret
You need a strong, random secret key for JWT tokens. Generate one using:JWT_SECRET environment variable.
Step 5: Set Up Google OAuth2 (Optional)
If you want to enable Google login, follow these steps:Create Google Cloud Project
Go to Google Cloud Console and create a new project or select an existing one.
Create OAuth2 Credentials
Navigate to Credentials → Create Credentials → OAuth 2.0 Client ID
- Application type: Web application
- Authorized redirect URIs:
http://localhost:3000/auth/google/callback
Step 6: Run the Application
Now you’re ready to start the API server. Use the Maven wrapper to run the application:- Download dependencies (first run only)
- Run Flyway migrations to set up the database schema
- Start the Spring Boot application
- Listen on port
3000(or your configuredPORT)
The first run may take a few minutes as Maven downloads all dependencies. Subsequent runs will be much faster.
Step 7: Verify Installation
Check that the API is running by calling the health check endpoint:cURL
Step 8: Make Your First API Request
Now let’s register a user and make an authenticated request.Register a New User
cURL
Login to Get JWT Token
cURL
Get User Profile (Authenticated)
Use the token from the login response to make an authenticated request:cURL
YOUR_TOKEN_HERE with the actual token from the login response.
Response:
Create Your First Task
cURL
What’s Next?
Congratulations! You now have Daily Tracker API running locally. Here’s what to explore next:Authentication Guide
Deep dive into JWT authentication, token refresh, and OAuth2 flows
API Reference
Explore all available endpoints with detailed schemas and examples
Environment Variables
Complete guide to all configuration options
Deployment Guide
Learn how to deploy to production environments
Troubleshooting
Database Connection Errors
If you see errors about database connections:- Verify PostgreSQL is running:
pg_isready - Check your
DATABASE_URLformat and credentials - Ensure the database exists:
psql -l - Check PostgreSQL logs for connection issues
JWT Secret Too Short
If you see “JWT secret must be at least 32 characters”:- Generate a new secret using the commands in Step 4
- Ensure your
JWT_SECRETenvironment variable is set correctly
Port Already in Use
If port 3000 is already in use:- Set a different port:
export PORT=8080 - Or stop the process using port 3000
Maven Dependencies Not Downloading
If Maven can’t download dependencies:- Check your internet connection
- Try clearing Maven cache:
rm -rf ~/.m2/repository - Run with verbose output:
./mvnw spring-boot:run -X