Skip to content

akarazhev/ai-driven-development-101

Repository files navigation

AI-Driven-Development-101

Full-stack Confluence Publisher App implementing the course project (Chapter 06).

Stack

  • Backend: Spring Boot 3.4, JPA/Hibernate, SQLite
  • Frontend: Angular 20 + TypeScript + TailwindCSS

Prerequisites

  • Java 21+
  • Gradle 8+ (or use included gradlew)
  • Node.js 18+ and npm

Setup

  1. Start backend
cd backend
./gradlew bootRun
  1. Frontend
cd frontend
npm install
npm start
# or
ng serve

Open http://localhost:4200 and ensure the backend is running on http://localhost:8080.

Project structure

backend/
  src/main/java/com/confluence/publisher/
    controller/     # REST controllers (Page, Attachment, Schedule, Confluence, AI)
    service/        # Business logic (PageService, AttachmentService, PublishService, ScheduleService)
    repository/     # JPA repositories
    entity/         # JPA entities (Page, Attachment, Schedule, PublishLog, etc.)
    dto/            # Request/Response DTOs
    provider/       # Provider adapter pattern (BaseProvider, ConfluenceStubProvider)
    scheduler/      # Background scheduler for queued pages
    config/         # Spring configuration and properties
    exception/      # Global exception handling
  src/main/resources/
    application.yml # Application configuration
frontend/
  src/pages/      # ComposePage, Schedules
  src/app/        # app component and routing
data/             # sqlite database (gitignored)
storage/attachments/ # uploaded files (gitignored)

API quickstart

  • Health: GET /api/health
  • Upload attachment: POST /api/attachments (multipart: file, description?)
  • Create page: POST /api/pages { title, content, spaceKey, attachmentIds }
  • Publish now: POST /api/confluence/publish { pageId }
  • Schedule: POST /api/schedules { pageId, scheduledAt? }
  • List schedules: GET /api/schedules

Tests

cd backend
./gradlew test

Notes

  • The Confluence provider is a stub by default; configure real Confluence API integration for production.
  • For production, configure a proper database and storage, secure API tokens, and harden CORS.
  • Confluence URL and space configuration available via environment variables.

Containerization (Docker/Podman)

The repo includes Dockerfiles for backend and frontend and a docker-compose.yml for local runs with Docker or Podman.

Quickstart (Docker)

Quickstart (Podman)

  • macOS hosts require the Podman VM:
    podman machine start
  • Build and run
    podman-compose -f podman-compose.yaml up --build
  • Open
  • Stop / clean
    podman-compose -f podman-compose.yaml down
    podman-compose -f podman-compose.yaml down -v

Note: Both containers run as non-root users for rootless Podman compatibility. Nginx listens on port 8080 (non-privileged) inside the container.

Compose services and ports

  • backend
    • Image: built from backend/Dockerfile (Spring Boot 3.4, JDK 21)
    • Port: 8080:8080 (host:container)
    • Runs as non-root user (appuser, UID 1000)
    • Volumes: named data (SQLite at /data/app.db), attachments (/storage/attachments)
    • Env (loaded from .env file):
      • CONFLUENCE_URL, CONFLUENCE_USERNAME, CONFLUENCE_API_TOKEN
      • CONFLUENCE_DEFAULT_SPACE, CONFLUENCE_PROVIDER
      • SCHEDULER_INTERVAL_SECONDS, CORS_ORIGINS
  • frontend
    • Image: built from frontend/Dockerfile (Angular 20, nginx)
    • Port: 4200:8080 (host:container, nginx on non-privileged port)
    • Build arg: NG_APP_API_BASE=http://localhost:8080 so the browser calls the backend via host port 8080.

Customizing configuration

  • Backend environment variables (Spring Boot properties with APP_ prefix):
    • APP_DATABASE_URL (default jdbc:sqlite:./data/app.db in dev, jdbc:sqlite:///data/app.db in container)
    • APP_ATTACHMENT_DIR (default storage/attachments, container uses /storage/attachments)
    • APP_CONFLUENCE_URL (Confluence instance URL)
    • APP_CONFLUENCE_DEFAULT_SPACE (default Confluence space key)
    • APP_CONFLUENCE_API_TOKEN (API token for authentication)
    • APP_PROVIDER (confluence-stub by default)
    • APP_SCHEDULER_INTERVAL_SECONDS (default 5)
    • APP_CORS_ORIGINS comma-separated list of allowed origins
  • Frontend API base
    • Set at build time via compose build.args.NG_APP_API_BASE (default http://localhost:8080).
    • Change when deploying behind another host/port, then rebuild the frontend image.

Build images manually (optional)

# Backend image
docker build -t confluence-backend -f backend/Dockerfile .
docker run --rm -p 8080:8080 \
  -e APP_DATABASE_URL=jdbc:sqlite:///data/app.db \
  -e APP_ATTACHMENT_DIR=/storage/attachments \
  -v confluence_data:/data -v confluence_attachments:/storage/attachments \
  confluence-backend

# Frontend image
docker build -t confluence-frontend \
  --build-arg NG_APP_API_BASE=http://localhost:8080 \
  -f frontend/Dockerfile .
docker run --rm -p 4200:8080 confluence-frontend

Data persistence

  • Compose uses named volumes: data for the SQLite DB and attachments for uploaded files.
  • Remove volumes with docker compose down -v (or podman compose down -v). This will delete your DB and uploaded attachments.

Troubleshooting

  • Port already in use
    • Change host ports in docker-compose.yml (e.g., 8081:8080 for backend, 4201:8080 for frontend).
  • CORS blocked
    • Add your origin to CORS_ORIGINS in .env file and recreate containers.
  • Frontend cannot reach backend
    • Ensure backend is mapped to host port 8080 and frontend is built with NG_APP_API_BASE pointing to http://localhost:8080.
    • Rebuild the frontend image after changing NG_APP_API_BASE.
  • Podman on SELinux hosts (Linux)
    • If you bind host directories instead of volumes, append :Z to volume mounts for proper labeling.
  • macOS Podman
    • Ensure podman machine start before running compose commands.
  • Slow or stale frontend
    • Rebuild frontend: docker compose build frontend (or Podman equivalent).

Course documentation

Additional resources

About

AI-Driven Development 101: a practical course + full‑stack project (FastAPI + React). Learn agents, prompting, and ship a social media automation app.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors