A full-stack web application template featuring Angular frontend, Go backend, Redis for caching, and PostgreSQL for data persistence.
- Frontend: Angular 20+ with standalone components, reactive forms, and modern routing
- Backend: Go with Gin framework, JWT authentication, and clean architecture
- Database: PostgreSQL with migration system
- Cache: Redis for session management and caching
- Authentication: JWT-based authentication with protected routes
- Docker: Complete containerization with docker-compose
- Development: Hot reload, linting, testing, and automated setup
- Node.js 18+ and npm
- Go 1.21+
- Docker and Docker Compose
- Git
# Clone the repository
git clone https://github.com/setsudan/angular-n-go-template
cd angular-n-go-template
# Start all services with Docker (includes database setup)
docker-compose up -d
# Wait for services to be ready, then check logs
docker-compose logs -f
# Access the application
# Frontend: http://localhost:4200
# Backend: http://localhost:8080# 1. Install dependencies
make install
# 2. Start database services
docker-compose up -d postgres redis
# 3. Run database migrations
make migrate
# 4. Start development servers
make dev# Run complete setup (installs dependencies, starts services, runs migrations)
make setup
# Start development servers
make dev- Frontend: http://localhost:4200
- Backend API: http://localhost:8080
- API Documentation: http://localhost:8080/health
angular-n-go-template/
├── backend/ # Go backend application
│ ├── controllers/ # HTTP request handlers
│ ├── middleware/ # Custom middleware
│ ├── models/ # Data models and DTOs
│ ├── repositories/ # Data access layer
│ ├── services/ # Business logic
│ ├── security/ # Authentication and security
│ ├── migrations/ # Database migrations
│ ├── scripts/ # Utility scripts
│ └── main.go # Application entry point
├── frontend/ # Angular frontend application
│ ├── src/
│ │ └── app/
│ │ ├── components/ # Angular components
│ │ ├── services/ # API services
│ │ ├── guards/ # Route guards
│ │ └── interceptors/ # HTTP interceptors
│ └── package.json
├── docker-compose.yml # Docker services configuration
└── Makefile # Development commands
make dev- Start both frontend and backend in development modemake run- Run backend onlymake build- Build both applicationsmake test- Run tests for both frontend and backend
make docker-up- Start all services with Dockermake docker-down- Stop all Docker servicesmake docker-build- Build Docker imagesmake logs- View Docker logs
make migrate- Run database migrationsmake db-shell- Connect to PostgreSQL shellmake redis-cli- Connect to Redis CLI
make install- Install all dependenciesmake clean- Clean build artifactsmake setup- Complete environment setup
The application uses JWT-based authentication:
- Register: Create a new account at
/register - Login: Authenticate at
/login - Protected Routes: Access dashboard and user management
- Auto-logout: Automatic logout on token expiration
POST /api/v1/auth/register- Register new userPOST /api/v1/auth/login- User loginGET /api/v1/auth/profile- Get user profilePOST /api/v1/auth/logout- User logout
GET /api/v1/users- List users (with pagination)GET /api/v1/users/:id- Get user by IDPUT /api/v1/users/:id- Update userDELETE /api/v1/users/:id- Delete user
id(UUID, Primary Key)email(VARCHAR, Unique)username(VARCHAR, Unique)password(VARCHAR, Hashed)first_name(VARCHAR)last_name(VARCHAR)is_active(BOOLEAN)created_at(TIMESTAMP)updated_at(TIMESTAMP)
id(UUID, Primary Key)request_id(VARCHAR, Unique)method(VARCHAR)path(VARCHAR)user_agent(TEXT)ip_address(INET)user_id(UUID, Foreign Key)status_code(INTEGER)response_time_ms(INTEGER)created_at(TIMESTAMP)
When using docker-compose up, environment variables are automatically configured. No .env file needed.
Create a .env file in the project root:
# Copy the example file
cp env.example .envThen edit .env with your local settings:
# Database Configuration (for local development)
DATABASE_URL=postgres://user:password@localhost:5432/angular_n_go_template?sslmode=disable
# Redis Configuration (for local development)
REDIS_URL=redis://localhost:6379
# JWT Configuration
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
JWT_EXPIRY=24h
# Server Configuration
PORT=8080
GIN_MODE=debug
# CORS Configuration
CORS_ORIGIN=http://localhost:4200- Docker: Uses service names (
postgres,redis) for internal communication - Local: Uses
localhostfor direct connections
The frontend automatically uses the correct API URL based on the environment:
- Development:
http://localhost:8080/api/v1(direct backend connection) - Production/Docker:
/api/v1(proxied through nginx)
cd frontend
npm run testcd backend
go test ./...cd frontend
npm run e2e# Build and start all services
docker-compose up -d
# View logs
docker-compose logs -f-
Build the applications:
make build
-
Set up production environment variables
-
Run database migrations:
make migrate
-
Start the backend server:
cd backend && ./bin/main
-
Serve the frontend (using nginx or similar)
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.
- Port conflicts: Make sure ports 4200, 5432, 6379, and 8080 are available
- Database connection: Ensure PostgreSQL is running and accessible
- Redis connection: Verify Redis is running and accessible
- CORS issues: Check that CORS_ORIGIN matches your frontend URL
- Docker build failures:
- Frontend: Ensure Node.js version is 20+ (updated in Dockerfile)
- Backend: Check Go version compatibility
- Environment variables:
- For Docker: Variables are set automatically in docker-compose.yml
- For local development: Create
.envfile fromenv.example
# Check if services are healthy
docker-compose ps
# Check database logs
docker-compose logs postgres
# Restart services
docker-compose restart# Check Node.js version in container
docker-compose exec frontend node --version
# Rebuild frontend
docker-compose build --no-cache frontend# Stop all services
docker-compose down
# Remove volumes (WARNING: This deletes all data)
docker-compose down -v
# Clean Docker system
docker system prune -f
# Rebuild and start
docker-compose up -d --build