Skip to content

Latest commit

Β 

History

History
251 lines (192 loc) Β· 6.28 KB

File metadata and controls

251 lines (192 loc) Β· 6.28 KB

πŸš€ GONews Developer Quick Start Guide

Welcome to the GONews project! This guide will help you get started with the newly organized codebase.

πŸ“ Project Structure Overview

GONews/
β”œβ”€β”€ πŸ“„ README.md                    # You are here!
β”œβ”€β”€ πŸ› οΈ Makefile                     # Build commands
β”œβ”€β”€ 🐳 docker-compose.yml           # Main Docker setup
β”œβ”€β”€ πŸ“Š docs/                        # All documentation
β”œβ”€β”€ πŸ§ͺ tests/                       # Tests and test scripts
β”œβ”€β”€ πŸš€ deployments/                 # Deployment configurations
β”œβ”€β”€ πŸ“ˆ monitoring/                   # Observability setup
β”œβ”€β”€ πŸ—οΈ cmd/                         # Application entry points
β”œβ”€β”€ πŸ”’ internal/                    # Private application code
β”œβ”€β”€ πŸ“¦ bin/                         # Compiled binaries (auto-generated)
└── πŸ› οΈ scripts/                     # Utility scripts

πŸƒβ€β™‚οΈ Quick Start Commands

1. Environment Setup

# Clone and enter the project
cd /Users/madraka/GONews

# Copy environment file
cp .env.example .env  # Edit with your settings

# Install dependencies
go mod download

2. Database Setup

# Start database and services
make db-up

# Run migrations
make migrate-up

# Verify setup
make migrate-status

3. Development Modes

Local Development

# Build and run locally
make build && make run

# Or use hot reload with Air
air

Docker Development

# Start all services (API + Database + Monitoring)
make dev-all-up

# View logs
docker-compose logs -f api

# Stop all services
make dev-all-down

4. Testing

# Run unit tests
make test

# Run integration tests
make integration-test

# Test API endpoints
./tests/scripts/quick_test.sh

# Test observability stack
./tests/scripts/test_observability.sh

πŸ“ Key File Locations

Need to find something? Here's where to look:

What you need Where to find it
πŸ”§ API Handlers internal/handlers/
πŸ›£οΈ Routes internal/routes/
πŸ—ƒοΈ Database Models internal/models/
πŸ” Middleware internal/middleware/
πŸ“‹ API Documentation docs/api/swagger.json
πŸ§ͺ Test Scripts tests/scripts/
🐳 Docker Configs deployments/docker/
πŸ“Š Monitoring monitoring/
πŸ”§ Build Scripts scripts/build/

Quick Navigation Commands

# Jump to key directories
cd internal/handlers     # API handlers
cd docs/api             # API documentation  
cd tests/scripts        # Test scripts
cd deployments/dev      # Development configs
cd monitoring/          # Observability configs

πŸ”¨ Common Development Tasks

Adding a New API Endpoint

  1. Create Handler: Add to internal/handlers/
  2. Add Route: Register in internal/routes/
  3. Add Tests: Create test in tests/
  4. Update Docs: Run swag init to update Swagger

Working with Database

# Create new migration
make migrate-create name=add_new_table

# Apply migrations
make migrate-up

# Rollback migration
make migrate-down

# Check migration status
make migrate-status

Testing Your Changes

# Quick API test
./tests/scripts/quick_test.sh

# Verify handlers work
./tests/scripts/verify_handlers.sh

# Test with authentication
./tests/scripts/test_api_authenticated.sh

Monitoring and Observability

# Start monitoring stack
make metrics-up

# View metrics: http://localhost:9090 (Prometheus)
# View dashboards: http://localhost:3000 (Grafana)
# API metrics: http://localhost:8080/metrics

πŸ“– Documentation Guide

Where to Find Information

Topic Location Description
API Reference docs/api/ Swagger documentation, API guides
Setup Guides docs/guides/ Implementation and configuration guides
Test Results docs/reports/ Test reports and deployment status
Database docs/migration/ Migration guides and database docs

Key Documentation Files

  • πŸ“‹ API Docs: docs/api/swagger.json - Complete API specification
  • πŸ” Observability: docs/guides/OBSERVABILITY_GUIDE.md - Monitoring setup
  • πŸ” Security: docs/guides/enhanced_security_guide.md - Security best practices
  • πŸ€– AI Integration: docs/guides/ai_integration_guide.md - AI features guide

πŸ› Debugging and Troubleshooting

Health Checks

# Check API health
curl http://localhost:8080/health

# Check all container status
docker-compose ps

# View container logs
docker-compose logs api

Debug Tools

# Run debug server (in debug/ directory)
make debug-server

# Run debug client
make debug-client

# Check metrics endpoint
curl http://localhost:8080/metrics

Common Issues

  1. Port conflicts: Check if ports 8080, 5432, 6379 are available
  2. Database connection: Ensure PostgreSQL is running (make db-up)
  3. Redis connection: Ensure Redis is running
  4. Missing migrations: Run make migrate-up

🎯 Best Practices

Code Organization

  • βœ… Place handlers in internal/handlers/
  • βœ… Keep business logic in internal/services/
  • βœ… Put tests near the code they test
  • βœ… Update documentation when adding features

Git Workflow

  • βœ… Binaries are auto-ignored (in bin/)
  • βœ… Use meaningful commit messages
  • βœ… Test before committing
  • βœ… Keep .env files out of git

Development Environment

  • βœ… Use make dev-all-up for full development stack
  • βœ… Use make test before pushing changes
  • βœ… Check make lint for code quality
  • βœ… Update Swagger docs with swag init

πŸ†˜ Getting Help

Resources

  • πŸ“– Full Documentation: Browse docs/ directory
  • πŸ§ͺ Test Examples: Check tests/scripts/ for examples
  • πŸ”§ Build Commands: Run make help for all available commands
  • πŸ“Š Monitoring: Access Grafana at http://localhost:3000

Quick Reference

# See all available make commands
make help

# Check project status
make status

# Run comprehensive tests
make test-all

# View API documentation
open http://localhost:8080/swagger/index.html

πŸŽ‰ Happy coding! The project is now well-organized and ready for development. All documentation is in English and properly categorized for easy access.