How sisovin/lynx-notes-app works
Main components
• Frontend Components: Graphical UI/UX elements including LoginForm, SignupForm, NoteForm, and NoteList. These reside in the "src/components" directory.
• API/Controller Layer: The “src/controllers” directory holds the logic for authentication and notes management (authController.ts & notesController.ts), which process requests coming from the frontend.
• Routing Layer: Routes defined in "src/routes" (authRoutes.ts and noteRoutes.ts) that map incoming HTTP requests to the appropriate controller actions.
• Middleware: Found in "src/middleware" (authMiddleware.ts) to handle cross-cutting concerns like authentication.
• Models: Business logic layer in "src/models" (noteModel.ts and userModel.ts) that interact with the SQLite database, representing the domain data.
• Utility Layer: Includes files for cryptographic operations (argon2Utils.ts), JWT handling (jwtUtils.ts), and the Redis client (redisClient.ts) under "src/utils".
• Database: SQLite database (initialized via a script in "src/utils/initDatabase.ts").
• External Services: Redis is used as a caching service.
Relationships and interactions
• The Frontend sends HTTP requests (sign-up, login, note CRUD operations) to the backend’s API endpoints.
• Routing directs these requests to the appropriate controllers.
• Controllers then utilize middleware (e.g., authMiddleware.ts for verifying JWT) and interact with models to process the request (read/write data from SQLite).
• Utility functions are used during these operations for authentication (Argon2 hashing, JWT generation/verification) and caching (Redis operations).
• The server is started with Bun and listens on the configured port (as indicated by the environment variable PORT).
Architectural patterns and design principles
• Layered Architecture: Clear separation between presentation (frontend), application logic (controllers and middleware), domain (models), and data access (SQLite database).
• MVC-Like Pattern: Routes initiate controller actions, middleware enforces security, and models encapsulate the data schema and database interactions.
• Service and Utility Separation: Additional functionality like caching (Redis) and secure hashing/token generation are abstracted out into utilities.
Relevant technologies
• Bun as the runtime for the server.
• TypeScript as the main programming language.
• Tailwind CSS for styling.
• SQLite as the persistence layer.
• Redis for caching.
• External libraries for Argon2 and JWT processing.
• Clear labels: Name each component (e.g., "Frontend UI", "Auth Controller", "Notes Controller", "Auth Middleware", "User Model", "Note Model", "SQLite Database", "Redis Cache", "Utility Functions").