How cenixeriadev/urlshortner works
Project Overview
• This project is a full-stack URL shortening service built using a Spring Boot backend and an Angular-based frontend. It is designed with a layered architecture that promotes separation of concerns and is built with horizontal scaling in mind. Although it currently runs as a single application, its structure paves the way for a transition to a more distributed or microservice-based architecture, complete with an API Gateway and load balancing.
And Represent Main System Components
• Frontend Component:
• Files and configurations from the “frontend” directory such as index.html, Angular modules, and routing (app.routes.ts).
• Backend Component:
▪ Controller Layer:
• ReadController and WriteController components.
• That controllers handle incoming HTTP requests and route them to proper services.
▪ Service Layer:
• Core services like UrlShortnerService, RedisService, and ZooKeeperService that implement business logic including URL shortening, caching, and unique sequence generation.
• Base62Converter utility as part of the business logic.
▪ Repository Layer:
• ShortUrlRepository, indicating its role in persisting URL mappings to PostgresSQL.
• API Gateway / Load Balancer:
• Even though the application currently works as a single backend service, include a representation of an “API Gateway / Load Balancer” component.
• That it maps HTTP methods (GET vs. POST/PUT/DELETE) to the respective read and write endpoints which could facilitate horizontal scaling.
• Database and Persistence:
• It via the Repository layer inside the backend.
• Caching Layer:
• “Redis” as a caching component, linked to the Service layer to illustrate faster retrieval for URL lookups.
• Distributed Coordination:
• Connection to the Service layer where Base62 encoding is applied.
• Environment/Infrastructure (Optional):
Defining Relationships and Interactions
• From “User/Client” to “Frontend” (for web interaction).
• From the “Frontend” to the “Backend” (REST API calls).
• Within the Backend:
Architectural Patterns and Design Principles
• Layered architecture (Separation of controllers, services, and repositories).
• That the system is designed with scalability in mind, with an architecture that can support an API gateway and load balancer for separating read and write operations.
• Optionally mention future extensibility towards a microservices architecture (e.g., separating read and write microservices).
Technical Technologies and Libraries
• Components with their relevant technologies:
• “Spring Boot” for the backend framework.
• “PostgresSQL” for database persistence.
• “Redis” for caching.
• “ZooKeeper (Apache Curator)” for distributed sequence generation.
• “Angular” for the frontend.
• “Maven” for build and dependency management.
• “Docker Compose” for container orchestration.